diff --git a/sdk/iothub/azure-mgmt-iothub/_meta.json b/sdk/iothub/azure-mgmt-iothub/_meta.json index 1e15d4ff063d..742553113042 100644 --- a/sdk/iothub/azure-mgmt-iothub/_meta.json +++ b/sdk/iothub/azure-mgmt-iothub/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "1f327d204d0c1835d7ee675d93b423028341a6b7", + "commit": "e574f66c7fa09787ae5db1b12df5d51877a23177", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/iothub/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/iothub/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/iothub/resource-manager/readme.md" } \ No newline at end of file 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 7a56f8497059..b1d4bbf2aaf3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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 7bc8275a0cc3..4ac0266fd3db 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 @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -70,12 +69,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(IotHubClient, self).__init__( 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 bcb59dbd5672..51c9f055ca69 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 @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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 92ad0119e2e9..dd5873c5b9a0 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 @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -68,12 +68,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(IotHubClient, self).__init__( diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py index 04a16f26b961..6e6027d8fc1d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2016_02_03/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py index 7c66155ebf72..9119653bc5df 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_iot_hub_client.py @@ -6,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations @@ -32,48 +30,54 @@ class IotHubClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json index 4989a0a94e69..fea5ebde91cf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "iot_hub_resource": "IotHubResourceOperations" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py index 374ac889a2d7..b421ff804730 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2016_02_03/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py index 1671dff2185d..6724987d2c6c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_iot_hub_client.py @@ -6,70 +6,79 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2016_02_03.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2016_02_03.aio.operations.IotHubResourceOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py index 7e51870c2283..25aa4329f8d7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -116,39 +114,28 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -160,8 +147,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -185,15 +175,20 @@ async def begin_create_or_update( :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,27 +200,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -237,6 +226,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -250,34 +240,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -293,8 +272,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -311,15 +293,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription or + ~azure.mgmt.iothub.v2016_02_03.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -333,24 +320,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -362,8 +342,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -373,8 +355,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -382,34 +366,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,17 +401,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -445,8 +426,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hubs. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -454,35 +437,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -495,17 +474,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -530,33 +511,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -565,8 +536,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -582,8 +556,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -591,36 +567,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -633,17 +606,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -651,7 +626,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -663,8 +639,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -672,37 +650,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -715,17 +691,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -756,35 +734,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -793,8 +761,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -825,35 +796,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -862,8 +823,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -894,35 +858,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -930,13 +884,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -946,8 +903,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -955,36 +914,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -997,17 +953,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1015,7 +973,8 @@ async def get_job( 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. 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. @@ -1036,34 +995,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1072,8 +1021,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1089,8 +1041,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1098,36 +1052,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1140,17 +1091,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1173,36 +1126,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(operation_inputs, 'OperationInputs') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1211,15 +1154,19 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1229,8 +1176,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1238,36 +1187,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1280,17 +1226,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1298,7 +1246,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1319,34 +1268,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1355,8 +1294,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1364,7 +1306,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1386,38 +1330,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1426,8 +1360,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1435,7 +1372,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1457,38 +1396,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1497,4 +1426,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py index 52b3c6647377..a89eff43c517 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/__init__.py @@ -6,66 +6,36 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import OperationInputs - from ._models_py3 import OperationsMonitoringProperties - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties -except (SyntaxError, ImportError): - from ._models import CloudToDeviceProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationsMonitoringProperties # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import OperationInputs +from ._models_py3 import OperationsMonitoringProperties +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py index f50511bf1858..80da5a05a045 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,21 +31,21 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -68,7 +53,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -77,21 +62,21 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -102,7 +87,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -117,7 +102,7 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operations monitoring level. """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models.py deleted file mode 100644 index 0d8e6e2c47ff..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models.py +++ /dev/null @@ -1,1108 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - :param tags: A set of tags. The tags. - :type tags: dict[str, str] - :param id: The Event Hub-compatible consumer group identifier. - :type id: str - :param name: The Event Hub-compatible consumer group name. - :type name: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: The array of Event Hub-compatible consumer group names. - :type value: list[str] - :ivar next_link: The next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2016_02_03.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param subscriptionid: Required. The subscription identifier. - :type subscriptionid: str - :param resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. - :type resourcegroup: str - :param 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2016_02_03.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2016_02_03.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}, - 'subscriptionid': {'required': True}, - 'resourcegroup': {'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}'}, - 'subscriptionid': {'key': 'subscriptionid', 'type': 'str'}, - 'resourcegroup': {'key': 'resourcegroup', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.subscriptionid = kwargs['subscriptionid'] - self.resourcegroup = kwargs['resourcegroup'] - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2016_02_03.models.IpFilterRule] - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar host_name: The name of the host. - :vartype host_name: str - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to - this dictionary are events and operationsMonitoringEvents. Both of these keys have to be - present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2016_02_03.models.EventHubProperties] - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2016_02_03.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2016_02_03.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2016_02_03.models.CloudToDeviceProperties - :param comments: Comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. - The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, - DeviceIdentityOperations, FileUploadOperations. - :type operations_monitoring_properties: - ~azure.mgmt.iothub.v2016_02_03.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2016_02_03.models.Capabilities - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'host_name': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - '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'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.operations_monitoring_properties = kwargs.get('operations_monitoring_properties', None) - self.features = kwargs.get('features', None) - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'current_value': {'key': 'CurrentValue', 'type': 'long'}, - 'max_value': {'key': 'MaxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". - :vartype tier: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuTier - :param capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'capacity': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs['capacity'] - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2016_02_03.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2016_02_03.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2016_02_03.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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/en-us/azure/iot-hub/iot-hub-devguide-file-upload. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: - https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationsMonitoringProperties(msrest.serialization.Model): - """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations. - - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2016_02_03.models.OperationMonitoringLevel] - """ - - _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsMonitoringProperties, self).__init__(**kwargs) - self.events = kwargs.get('events', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2016_02_03.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py index f97b61ce6d61..08560b2ead5b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/models/_models_py3.py @@ -18,16 +18,16 @@ class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2016_02_03.models.FeedbackProperties + :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.v2016_02_03.models.FeedbackProperties """ _validation = { @@ -48,6 +48,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2016_02_03.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -87,6 +99,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -97,12 +111,12 @@ def __init__( class EventHubConsumerGroupInfo(msrest.serialization.Model): """The properties of the EventHubConsumerGroupInfo object. - :param tags: A set of tags. The tags. - :type tags: dict[str, str] - :param id: The Event Hub-compatible consumer group identifier. - :type id: str - :param name: The Event Hub-compatible consumer group name. - :type name: str + :ivar tags: A set of tags. The tags. + :vartype tags: 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 """ _attribute_map = { @@ -119,6 +133,14 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags. + :paramtype tags: dict[str, str] + :keyword id: The Event Hub-compatible consumer group identifier. + :paramtype id: str + :keyword name: The Event Hub-compatible consumer group name. + :paramtype name: str + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.tags = tags self.id = id @@ -130,8 +152,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of Event Hub-compatible consumer group names. - :type value: list[str] + :ivar value: The array of Event Hub-compatible consumer group names. + :vartype value: list[str] :ivar next_link: The next link. :vartype next_link: str """ @@ -151,6 +173,10 @@ def __init__( value: Optional[List[str]] = None, **kwargs ): + """ + :keyword value: The array of Event Hub-compatible consumer group names. + :paramtype value: list[str] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -161,13 +187,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -197,6 +223,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -210,11 +245,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -234,6 +269,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -242,17 +284,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -273,6 +315,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -284,10 +339,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -307,6 +362,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -346,6 +407,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -366,10 +429,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -394,6 +457,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -415,22 +484,22 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param subscriptionid: Required. The subscription identifier. - :type subscriptionid: str - :param resourcegroup: Required. The name of the resource group that contains the IoT hub. A + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] + :ivar subscriptionid: Required. The subscription identifier. + :vartype subscriptionid: str + :ivar resourcegroup: Required. The name of the resource group that contains the IoT hub. A resource group name uniquely identifies the resource group within the subscription. - :type resourcegroup: str - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :vartype resourcegroup: 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2016_02_03.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: The properties of an IoT hub. + :vartype properties: ~azure.mgmt.iothub.v2016_02_03.models.IotHubProperties + :ivar sku: Required. Information about the SKU of the IoT hub. + :vartype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo """ _validation = { @@ -468,6 +537,24 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + :keyword subscriptionid: Required. The subscription identifier. + :paramtype subscriptionid: str + :keyword resourcegroup: Required. The name of the resource group that contains the IoT hub. A + resource group name uniquely identifies the resource group within the subscription. + :paramtype resourcegroup: 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: The properties of an IoT hub. + :paramtype properties: ~azure.mgmt.iothub.v2016_02_03.models.IotHubProperties + :keyword sku: Required. Information about the SKU of the IoT hub. + :paramtype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.subscriptionid = subscriptionid self.resourcegroup = resourcegroup @@ -481,8 +568,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -502,6 +589,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -517,8 +608,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -538,6 +629,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -549,45 +644,46 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2016_02_03.models.IpFilterRule] + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2016_02_03.models.IpFilterRule] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar host_name: The name of the host. :vartype host_name: str - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to this dictionary are events and operationsMonitoringEvents. Both of these keys have to be present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2016_02_03.models.EventHubProperties] - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2016_02_03.models.EventHubProperties] + :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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2016_02_03.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2016_02_03.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2016_02_03.models.CloudToDeviceProperties - :param comments: Comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. + :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.v2016_02_03.models.CloudToDeviceProperties + :ivar comments: Comments. + :vartype comments: str + :ivar operations_monitoring_properties: The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations. - :type operations_monitoring_properties: + :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2016_02_03.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2016_02_03.models.Capabilities + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2016_02_03.models.Capabilities """ _validation = { @@ -625,6 +721,44 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2016_02_03.models.IpFilterRule] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys + to this dictionary are events and operationsMonitoringEvents. Both of these keys have 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.v2016_02_03.models.EventHubProperties] + :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.v2016_02_03.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2016_02_03.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.v2016_02_03.models.CloudToDeviceProperties + :keyword comments: Comments. + :paramtype comments: str + :keyword operations_monitoring_properties: The operations monitoring properties for the IoT + hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, + DeviceIdentityOperations, FileUploadOperations. + :paramtype operations_monitoring_properties: + ~azure.mgmt.iothub.v2016_02_03.models.OperationsMonitoringProperties + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2016_02_03.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -669,6 +803,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -680,8 +816,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -701,6 +837,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -715,10 +855,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2016_02_03.models.IotHubCapacity + :ivar sku: Required. Information about the SKU of the IoT hub. + :vartype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo + :ivar capacity: Required. IoT Hub capacity information. + :vartype capacity: ~azure.mgmt.iothub.v2016_02_03.models.IotHubCapacity """ _validation = { @@ -740,6 +880,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. Information about the SKU of the IoT hub. + :paramtype sku: ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuInfo + :keyword capacity: Required. IoT Hub capacity information. + :paramtype capacity: ~azure.mgmt.iothub.v2016_02_03.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -751,8 +897,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -772,6 +918,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -784,13 +934,13 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSku + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :vartype name: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuTier - :param capacity: Required. The number of provisioned IoT Hub units. See: + :ivar capacity: Required. The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -812,6 +962,13 @@ def __init__( capacity: int, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :paramtype name: str or ~azure.mgmt.iothub.v2016_02_03.models.IotHubSku + :keyword capacity: Required. The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :paramtype capacity: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -823,14 +980,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2016_02_03.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2016_02_03.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -853,6 +1010,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2016_02_03.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -911,6 +1078,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -927,8 +1096,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2016_02_03.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2016_02_03.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -948,6 +1117,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2016_02_03.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -956,16 +1129,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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/en-us/azure/iot-hub/iot-hub-devguide-file-upload. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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/en-us/azure/iot-hub/iot-hub-devguide-file-upload. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -986,6 +1159,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :keyword lock_duration_as_iso8601: The lock duration. See: + https://docs.microsoft.com/en-us/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/en-us/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/en-us/azure/iot-hub/iot-hub-devguide-file-upload. + :paramtype max_delivery_count: int + """ super(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -997,8 +1182,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1015,6 +1200,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1022,8 +1211,9 @@ def __init__( class OperationsMonitoringProperties(msrest.serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations. - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2016_02_03.models.OperationMonitoringLevel] + :ivar events: Dictionary of :code:``. + :vartype events: dict[str, str or + ~azure.mgmt.iothub.v2016_02_03.models.OperationMonitoringLevel] """ _attribute_map = { @@ -1036,6 +1226,11 @@ def __init__( events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, **kwargs ): + """ + :keyword events: Dictionary of :code:``. + :paramtype events: dict[str, str or + ~azure.mgmt.iothub.v2016_02_03.models.OperationMonitoringLevel] + """ super(OperationsMonitoringProperties, self).__init__(**kwargs) self.events = events @@ -1069,6 +1264,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1080,20 +1277,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2016_02_03.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2016_02_03.models.AccessRights """ _validation = { @@ -1117,6 +1314,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2016_02_03.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -1129,8 +1342,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -1150,6 +1364,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1160,16 +1379,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -1191,6 +1410,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py index 3d1bb9d52598..3083dd943d56 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2016_02_03/operations/_iot_hub_resource_operations.py @@ -5,25 +5,737 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-03" + accept = "application/json, text/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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2016-02-03" + accept = "application/json, text/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +759,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +784,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,54 +809,44 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -166,16 +858,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + **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 @@ -192,15 +886,19 @@ def begin_create_or_update( :type iot_hub_description: ~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -212,27 +910,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -244,48 +936,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -301,15 +982,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -320,15 +1003,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescription + or ~azure.mgmt.iothub.v2016_02_03.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -342,24 +1029,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -371,20 +1051,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -392,34 +1075,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -432,23 +1110,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -456,8 +1135,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hubs. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -465,35 +1146,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -506,24 +1183,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -542,33 +1220,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -577,15 +1245,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -595,8 +1265,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -604,36 +1276,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -646,26 +1315,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -677,8 +1348,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -686,37 +1359,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -729,26 +1400,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -771,35 +1443,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -808,17 +1470,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -841,35 +1505,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -878,17 +1532,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -911,35 +1567,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -947,14 +1593,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -964,8 +1612,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -973,36 +1623,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1015,26 +1662,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1055,34 +1704,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1091,15 +1730,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1109,8 +1750,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1118,36 +1761,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1160,23 +1800,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1194,36 +1835,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(operation_inputs, 'OperationInputs') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1232,16 +1863,19 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1251,8 +1885,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2016_02_03.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1260,36 +1896,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1302,26 +1935,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1342,34 +1977,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - accept = "application/json, text/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1378,17 +2003,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1410,38 +2039,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1450,17 +2069,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1482,38 +2105,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2016-02-03" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json, text/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1522,4 +2135,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py index 844a218e9f7a..c1ed12f768d0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2017_01_19/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py index 8c8d8b271367..a2e342037f38 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_iot_hub_client.py @@ -6,24 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - +from . import models from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations -from . import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations @@ -32,48 +30,54 @@ class IotHubClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json index 555c8a442721..9b3b5dbac5c6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "iot_hub_resource": "IotHubResourceOperations" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py index dabdaa04fa15..6eb13e4cb392 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2017_01_19/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py index 88adc4d8567b..ce237e220a6e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_iot_hub_client.py @@ -6,70 +6,79 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential - +from .. import models from ._configuration import IotHubClientConfiguration from .operations import IotHubResourceOperations -from .. import models +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials_async import AsyncTokenCredential -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2017_01_19.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2017_01_19.aio.operations.IotHubResourceOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py index 2a33be26b012..2e28f6618b5a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -116,39 +114,28 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -160,8 +147,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -185,15 +175,20 @@ async def begin_create_or_update( :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -205,27 +200,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -237,6 +226,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -250,34 +240,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -293,8 +272,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -311,15 +293,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription or + ~azure.mgmt.iothub.v2017_01_19.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -333,24 +320,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -362,8 +342,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -373,8 +355,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -382,34 +366,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -422,17 +401,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -445,8 +426,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hubs. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -454,35 +437,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -495,17 +474,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -530,33 +511,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -565,8 +536,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -582,8 +556,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -591,36 +567,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -633,17 +606,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -651,7 +626,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -663,8 +639,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -672,37 +650,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -715,17 +691,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -756,35 +734,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -793,8 +761,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -825,35 +796,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -862,8 +823,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -894,35 +858,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -930,13 +884,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -946,8 +903,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -955,36 +914,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -997,17 +953,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1015,7 +973,8 @@ async def get_job( 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. 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. @@ -1036,34 +995,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1072,8 +1021,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1089,8 +1041,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1098,36 +1052,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1140,17 +1091,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1173,36 +1126,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(operation_inputs, 'OperationInputs') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1211,15 +1154,19 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1229,8 +1176,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1238,36 +1187,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1280,17 +1226,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1298,7 +1246,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1319,34 +1268,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1355,8 +1294,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1364,7 +1306,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1386,38 +1330,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1426,8 +1360,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1435,7 +1372,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1457,38 +1396,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1497,4 +1426,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py index f093f2c51ebb..00985acee0f9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/__init__.py @@ -6,80 +6,43 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import OperationInputs - from ._models_py3 import OperationsMonitoringProperties - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties -except (SyntaxError, ImportError): - from ._models import CloudToDeviceProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationsMonitoringProperties # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import OperationInputs +from ._models_py3 import OperationsMonitoringProperties +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py index affd81b47524..8c8854d1a75a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,21 +31,21 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -68,7 +53,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -77,21 +62,21 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -102,7 +87,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -117,7 +102,7 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operations monitoring level. """ @@ -126,7 +111,7 @@ class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models.py deleted file mode 100644 index bf2f0fbc358d..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models.py +++ /dev/null @@ -1,1401 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - :param tags: A set of tags. The tags. - :type tags: dict[str, str] - :param id: The Event Hub-compatible consumer group identifier. - :type id: str - :param name: The Event Hub-compatible consumer group name. - :type name: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: The array of Event Hub-compatible consumer group names. - :type value: list[str] - :ivar next_link: The next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties related to the fallback route based on which the IoT hub routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param source: Required. The source to which the routing rule is to be applied to. e.g. - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled or not. - :type is_enabled: bool - """ - - _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, - } - - _attribute_map = { - '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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2017_01_19.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param subscriptionid: Required. The subscription identifier. - :type subscriptionid: str - :param resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. - :type resourcegroup: str - :param 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2017_01_19.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_01_19.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}, - 'subscriptionid': {'required': True}, - 'resourcegroup': {'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}'}, - 'subscriptionid': {'key': 'subscriptionid', 'type': 'str'}, - 'resourcegroup': {'key': 'resourcegroup', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.subscriptionid = kwargs['subscriptionid'] - self.resourcegroup = kwargs['resourcegroup'] - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2017_01_19.models.IpFilterRule] - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar host_name: The name of the host. - :vartype host_name: str - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to - this dictionary are events and operationsMonitoringEvents. Both of these keys have to be - present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2017_01_19.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2017_01_19.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2017_01_19.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2017_01_19.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2017_01_19.models.CloudToDeviceProperties - :param comments: Comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. - The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, - DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, - TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: - ~azure.mgmt.iothub.v2017_01_19.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2017_01_19.models.Capabilities - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'host_name': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', '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'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.operations_monitoring_properties = kwargs.get('operations_monitoring_properties', None) - self.features = kwargs.get('features', None) - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'current_value': {'key': 'CurrentValue', 'type': 'long'}, - 'max_value': {'key': 'MaxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". - :vartype tier: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuTier - :param capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'capacity': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs['capacity'] - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2017_01_19.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2017_01_19.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2017_01_19.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationsMonitoringProperties(msrest.serialization.Model): - """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2017_01_19.models.OperationMonitoringLevel] - """ - - _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsMonitoringProperties, self).__init__(**kwargs) - self.events = kwargs.get('events', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2017_01_19.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2017_01_19.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2017_01_19.models.RoutingEventHubProperties] - """ - - _attribute_map = { - 'service_bus_queues': {'key': 'serviceBusQueues', 'type': '[RoutingServiceBusQueueEndpointProperties]'}, - 'service_bus_topics': {'key': 'serviceBusTopics', 'type': '[RoutingServiceBusTopicEndpointProperties]'}, - 'event_hubs': {'key': 'eventHubs', 'type': '[RoutingEventHubProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name of the event hub 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2017_01_19.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2017_01_19.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2017_01_19.models.FallbackRouteProperties - """ - - _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name of the service bus queue 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name of the service bus topic 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2017_01_19.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py index bb53ed355109..37c19eabd7ea 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/models/_models_py3.py @@ -18,16 +18,16 @@ class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2017_01_19.models.FeedbackProperties + :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.v2017_01_19.models.FeedbackProperties """ _validation = { @@ -48,6 +48,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2017_01_19.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -87,6 +99,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -97,12 +111,12 @@ def __init__( class EventHubConsumerGroupInfo(msrest.serialization.Model): """The properties of the EventHubConsumerGroupInfo object. - :param tags: A set of tags. The tags. - :type tags: dict[str, str] - :param id: The Event Hub-compatible consumer group identifier. - :type id: str - :param name: The Event Hub-compatible consumer group name. - :type name: str + :ivar tags: A set of tags. The tags. + :vartype tags: 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 """ _attribute_map = { @@ -119,6 +133,14 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags. + :paramtype tags: dict[str, str] + :keyword id: The Event Hub-compatible consumer group identifier. + :paramtype id: str + :keyword name: The Event Hub-compatible consumer group name. + :paramtype name: str + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.tags = tags self.id = id @@ -130,8 +152,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of Event Hub-compatible consumer group names. - :type value: list[str] + :ivar value: The array of Event Hub-compatible consumer group names. + :vartype value: list[str] :ivar next_link: The next link. :vartype next_link: str """ @@ -151,6 +173,10 @@ def __init__( value: Optional[List[str]] = None, **kwargs ): + """ + :keyword value: The array of Event Hub-compatible consumer group names. + :paramtype value: list[str] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -161,13 +187,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -197,6 +223,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -210,11 +245,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -234,6 +269,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -244,19 +286,19 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param source: Required. The source to which the routing rule is to be applied to. e.g. + :ivar source: Required. The source to which the routing rule is to be applied to. e.g. DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2017_01_19.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled or not. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled or not. + :vartype is_enabled: bool """ _validation = { @@ -281,6 +323,21 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword source: Required. The source to which the routing rule is to be applied to. e.g. + DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2017_01_19.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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled or not. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.source = source self.condition = condition @@ -291,17 +348,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -322,6 +379,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -333,10 +403,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -356,6 +426,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -395,6 +471,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -415,10 +493,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -443,6 +521,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -464,22 +548,22 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param subscriptionid: Required. The subscription identifier. - :type subscriptionid: str - :param resourcegroup: Required. The name of the resource group that contains the IoT hub. A + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] + :ivar subscriptionid: Required. The subscription identifier. + :vartype subscriptionid: str + :ivar resourcegroup: Required. The name of the resource group that contains the IoT hub. A resource group name uniquely identifies the resource group within the subscription. - :type resourcegroup: str - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :vartype resourcegroup: 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2017_01_19.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: The properties of an IoT hub. + :vartype properties: ~azure.mgmt.iothub.v2017_01_19.models.IotHubProperties + :ivar sku: Required. Information about the SKU of the IoT hub. + :vartype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo """ _validation = { @@ -517,6 +601,24 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + :keyword subscriptionid: Required. The subscription identifier. + :paramtype subscriptionid: str + :keyword resourcegroup: Required. The name of the resource group that contains the IoT hub. A + resource group name uniquely identifies the resource group within the subscription. + :paramtype resourcegroup: 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: The properties of an IoT hub. + :paramtype properties: ~azure.mgmt.iothub.v2017_01_19.models.IotHubProperties + :keyword sku: Required. Information about the SKU of the IoT hub. + :paramtype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.subscriptionid = subscriptionid self.resourcegroup = resourcegroup @@ -530,8 +632,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -551,6 +653,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -566,8 +672,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -587,6 +693,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -598,49 +708,50 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2017_01_19.models.IpFilterRule] + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2017_01_19.models.IpFilterRule] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar host_name: The name of the host. :vartype host_name: str - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to this dictionary are events and operationsMonitoringEvents. Both of these keys have to be present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2017_01_19.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2017_01_19.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2017_01_19.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2017_01_19.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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2017_01_19.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2017_01_19.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2017_01_19.models.CloudToDeviceProperties - :param comments: Comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. + :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.v2017_01_19.models.CloudToDeviceProperties + :ivar comments: Comments. + :vartype comments: str + :ivar operations_monitoring_properties: The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: + :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2017_01_19.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2017_01_19.models.Capabilities + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2017_01_19.models.Capabilities """ _validation = { @@ -680,6 +791,48 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2017_01_19.models.IpFilterRule] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys + to this dictionary are events and operationsMonitoringEvents. Both of these keys have 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.v2017_01_19.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.v2017_01_19.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.v2017_01_19.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2017_01_19.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.v2017_01_19.models.CloudToDeviceProperties + :keyword comments: Comments. + :paramtype comments: str + :keyword operations_monitoring_properties: The operations monitoring properties for the IoT + hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, + DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, + TwinQueries, JobsOperations, DirectMethods. + :paramtype operations_monitoring_properties: + ~azure.mgmt.iothub.v2017_01_19.models.OperationsMonitoringProperties + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2017_01_19.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -725,6 +878,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -736,8 +891,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -757,6 +912,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -771,10 +930,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2017_01_19.models.IotHubCapacity + :ivar sku: Required. Information about the SKU of the IoT hub. + :vartype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo + :ivar capacity: Required. IoT Hub capacity information. + :vartype capacity: ~azure.mgmt.iothub.v2017_01_19.models.IotHubCapacity """ _validation = { @@ -796,6 +955,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. Information about the SKU of the IoT hub. + :paramtype sku: ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuInfo + :keyword capacity: Required. IoT Hub capacity information. + :paramtype capacity: ~azure.mgmt.iothub.v2017_01_19.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -807,8 +972,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -828,6 +993,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -840,13 +1009,13 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSku + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :vartype name: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuTier - :param capacity: Required. The number of provisioned IoT Hub units. See: + :ivar capacity: Required. The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -868,6 +1037,13 @@ def __init__( capacity: int, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :paramtype name: str or ~azure.mgmt.iothub.v2017_01_19.models.IotHubSku + :keyword capacity: Required. The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :paramtype capacity: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -879,14 +1055,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2017_01_19.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2017_01_19.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -909,6 +1085,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2017_01_19.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -967,6 +1153,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -983,8 +1171,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2017_01_19.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2017_01_19.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1004,6 +1192,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2017_01_19.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1012,16 +1204,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1042,6 +1234,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1053,8 +1257,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1071,6 +1275,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1078,8 +1286,9 @@ def __init__( class OperationsMonitoringProperties(msrest.serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2017_01_19.models.OperationMonitoringLevel] + :ivar events: Dictionary of :code:``. + :vartype events: dict[str, str or + ~azure.mgmt.iothub.v2017_01_19.models.OperationMonitoringLevel] """ _attribute_map = { @@ -1092,6 +1301,11 @@ def __init__( events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, **kwargs ): + """ + :keyword events: Dictionary of :code:``. + :paramtype events: dict[str, str or + ~azure.mgmt.iothub.v2017_01_19.models.OperationMonitoringLevel] + """ super(OperationsMonitoringProperties, self).__init__(**kwargs) self.events = events @@ -1125,6 +1339,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1136,23 +1352,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_01_19.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2017_01_19.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -1180,6 +1395,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2017_01_19.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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -1191,17 +1425,17 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2017_01_19.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2017_01_19.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2017_01_19.models.RoutingEventHubProperties] + :vartype event_hubs: list[~azure.mgmt.iothub.v2017_01_19.models.RoutingEventHubProperties] """ _attribute_map = { @@ -1218,6 +1452,19 @@ def __init__( event_hubs: Optional[List["RoutingEventHubProperties"]] = None, **kwargs ): + """ + :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.v2017_01_19.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.v2017_01_19.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.v2017_01_19.models.RoutingEventHubProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -1229,17 +1476,17 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name of the event hub endpoint. The name can only include + :ivar connection_string: Required. The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar name: Required. The name of the event hub 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -1263,6 +1510,19 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword name: Required. The name of the event hub 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1273,20 +1533,20 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2017_01_19.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2017_01_19.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. - :type routes: list[~azure.mgmt.iothub.v2017_01_19.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2017_01_19.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. - :type fallback_route: ~azure.mgmt.iothub.v2017_01_19.models.FallbackRouteProperties + :vartype fallback_route: ~azure.mgmt.iothub.v2017_01_19.models.FallbackRouteProperties """ _attribute_map = { @@ -1303,6 +1563,22 @@ def __init__( fallback_route: Optional["FallbackRouteProperties"] = None, **kwargs ): + """ + :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.v2017_01_19.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.v2017_01_19.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.v2017_01_19.models.FallbackRouteProperties + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -1314,18 +1590,18 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name of the service bus queue endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar name: Required. The name of the service bus queue 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -1349,6 +1625,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword name: Required. The name of the service bus queue 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need + not be the same as the actual queue name. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1361,18 +1651,18 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name of the service bus topic endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar name: Required. The name of the service bus topic 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -1396,6 +1686,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword name: Required. The name of the service bus topic 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name + need not be the same as the actual topic name. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1408,20 +1712,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2017_01_19.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2017_01_19.models.AccessRights """ _validation = { @@ -1445,6 +1749,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2017_01_19.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -1457,8 +1777,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -1478,6 +1799,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1488,16 +1814,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -1519,6 +1845,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py index 147bfad382cd..9a3c7727f484 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_01_19/operations/_iot_hub_resource_operations.py @@ -5,25 +5,737 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-01-19" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-01-19" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +759,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +784,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,54 +809,44 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -166,16 +858,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + **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 @@ -192,15 +886,19 @@ def begin_create_or_update( :type iot_hub_description: ~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -212,27 +910,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_description=iot_hub_description, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -244,48 +936,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -301,15 +982,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -320,15 +1003,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescription + or ~azure.mgmt.iothub.v2017_01_19.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -342,24 +1029,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -371,20 +1051,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -392,34 +1075,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -432,23 +1110,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -456,8 +1135,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hubs. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -465,35 +1146,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -506,24 +1183,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -542,33 +1220,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -577,15 +1245,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -595,8 +1265,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -604,36 +1276,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -646,26 +1315,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -677,8 +1348,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -686,37 +1359,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -729,26 +1400,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -771,35 +1443,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -808,17 +1470,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -841,35 +1505,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -878,17 +1532,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -911,35 +1567,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -947,14 +1593,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -964,8 +1612,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -973,36 +1623,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1015,26 +1662,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1055,34 +1704,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1091,15 +1730,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1109,8 +1750,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1118,36 +1761,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1160,23 +1800,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1194,36 +1835,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(operation_inputs, 'OperationInputs') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1232,16 +1863,19 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1251,8 +1885,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_01_19.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1260,36 +1896,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1302,26 +1935,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1342,34 +1977,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1378,17 +2003,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1410,38 +2039,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1450,17 +2069,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1482,38 +2105,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-01-19" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1522,4 +2135,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py index a960abda763d..5ce009af8fd1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2017_07_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py index 51b896d37d36..4414b0b4414f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_iot_hub_client.py @@ -6,26 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubResourceOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import CertificatesOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -38,52 +34,56 @@ class IotHubClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json index 829fdb083487..5f98b61d4d1d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py index a0f06dd12849..40d8ab7b9521 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2017_07_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py index 364861ddd0af..bee6ec61f9b1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_iot_hub_client.py @@ -6,80 +6,85 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubResourceOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import CertificatesOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2017_07_01.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2017_07_01.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2017_07_01.aio.operations.IotHubResourceOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2017_07_01.aio.operations.CertificatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py index d6525ec37b30..4b86305ff88d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py index dccd4e4bacc5..aba209624d8d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_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 T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -258,34 +247,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -301,8 +279,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -319,15 +300,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription or + ~azure.mgmt.iothub.v2017_07_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -341,24 +327,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -370,8 +349,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -381,8 +362,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -390,34 +373,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -430,17 +408,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -453,8 +433,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -462,35 +444,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -503,17 +481,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -538,33 +518,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -573,8 +543,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -590,8 +563,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -599,36 +574,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -641,17 +613,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -659,7 +633,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -671,8 +646,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -680,37 +657,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -723,17 +698,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -764,35 +741,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -801,8 +768,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -833,35 +803,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -870,8 +830,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -902,35 +865,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -938,13 +891,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -954,8 +910,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -963,36 +921,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1005,17 +960,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1023,7 +980,8 @@ async def get_job( 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. 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. @@ -1044,34 +1002,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1080,8 +1028,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1097,8 +1048,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1106,36 +1059,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1148,17 +1098,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1181,36 +1133,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1219,15 +1161,19 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1237,8 +1183,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1246,36 +1194,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1288,17 +1233,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1306,7 +1253,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1327,34 +1275,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1363,8 +1301,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1372,7 +1313,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1394,38 +1337,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1434,8 +1367,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1443,7 +1379,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1465,38 +1403,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1505,4 +1433,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py index e18c07af9281..a0cc31207e31 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2017_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2017_07_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/__init__.py index 859bf2ad965f..54511d29bce7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/__init__.py @@ -6,102 +6,54 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import OperationsMonitoringProperties - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties -except (SyntaxError, ImportError): - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OperationsMonitoringProperties # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import OperationsMonitoringProperties +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py index affd81b47524..8c8854d1a75a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,21 +31,21 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -68,7 +53,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -77,21 +62,21 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -102,7 +87,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -117,7 +102,7 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operations monitoring level. """ @@ -126,7 +111,7 @@ class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models.py deleted file mode 100644 index 9a4f10a6f243..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models.py +++ /dev/null @@ -1,1824 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - - -class CertificatePropertiesWithNonce(msrest.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 - """ - - _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'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'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificatePropertiesWithNonce, self).__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 - - -class CertificateVerificationDescription(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - :param tags: A set of tags. The tags. - :type tags: dict[str, str] - :param id: The Event Hub-compatible consumer group identifier. - :type id: str - :param name: The Event Hub-compatible consumer group name. - :type name: str - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: The array of Event Hub-compatible consumer group names. - :type value: list[str] - :ivar next_link: The next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[str]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool - """ - - _validation = { - 'source': {'required': True}, - 'endpoint_names': {'required': True, 'max_items': 1, 'min_items': 1}, - 'is_enabled': {'required': True}, - } - - _attribute_map = { - '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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2017_07_01.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param subscriptionid: Required. The subscription identifier. - :type subscriptionid: str - :param resourcegroup: Required. The name of the resource group that contains the IoT hub. A - resource group name uniquely identifies the resource group within the subscription. - :type resourcegroup: str - :param 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2017_07_01.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_07_01.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}, - 'subscriptionid': {'required': True}, - 'resourcegroup': {'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}'}, - 'subscriptionid': {'key': 'subscriptionid', 'type': 'str'}, - 'resourcegroup': {'key': 'resourcegroup', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'IotHubProperties'}, - 'sku': {'key': 'sku', 'type': 'IotHubSkuInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.subscriptionid = kwargs['subscriptionid'] - self.resourcegroup = kwargs['resourcegroup'] - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2017_07_01.models.IpFilterRule] - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar host_name: The name of the host. - :vartype host_name: str - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to - this dictionary are events and operationsMonitoringEvents. Both of these keys have to be - present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2017_07_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2017_07_01.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2017_07_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2017_07_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2017_07_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. - The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, - DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, - TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: - ~azure.mgmt.iothub.v2017_07_01.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2017_07_01.models.Capabilities - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'host_name': {'readonly': True}, - } - - _attribute_map = { - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRule]'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'provisioning_state': {'key': 'provisioningState', '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'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.operations_monitoring_properties = kwargs.get('operations_monitoring_properties', None) - self.features = kwargs.get('features', None) - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - 'current_value': {'key': 'CurrentValue', 'type': 'long'}, - 'max_value': {'key': 'MaxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". - :vartype tier: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuTier - :param capacity: Required. The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - 'capacity': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs['capacity'] - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2017_07_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2017_07_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2017_07_01.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2017_07_01.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'Name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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.v2017_07_01.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OperationsMonitoringProperties(msrest.serialization.Model): - """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2017_07_01.models.OperationMonitoringLevel] - """ - - _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsMonitoringProperties, self).__init__(**kwargs) - self.events = kwargs.get('events', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2017_07_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2017_07_01.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2017_07_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2017_07_01.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2017_07_01.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2017_07_01.models.FallbackRouteProperties - """ - - _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro' and 'avroDeflate'. Default value is 'avro'. - :type encoding: str - """ - - _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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2017_07_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py index 064d79995980..dd94caccf791 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/models/_models_py3.py @@ -18,9 +18,9 @@ class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -42,8 +47,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2017_07_01.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2017_07_01.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -75,6 +80,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2017_07_01.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -86,8 +95,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription] """ _attribute_map = { @@ -100,6 +109,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -145,6 +158,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -200,6 +215,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -213,9 +230,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -228,6 +245,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -237,9 +259,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2017_07_01.models.CertificatePropertiesWithNonce + :vartype properties: ~azure.mgmt.iothub.v2017_07_01.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -271,6 +293,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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.v2017_07_01.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -282,16 +309,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2017_07_01.models.FeedbackProperties + :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.v2017_07_01.models.FeedbackProperties """ _validation = { @@ -312,6 +339,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2017_07_01.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -351,6 +390,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -361,12 +402,12 @@ def __init__( class EventHubConsumerGroupInfo(msrest.serialization.Model): """The properties of the EventHubConsumerGroupInfo object. - :param tags: A set of tags. The tags. - :type tags: dict[str, str] - :param id: The Event Hub-compatible consumer group identifier. - :type id: str - :param name: The Event Hub-compatible consumer group name. - :type name: str + :ivar tags: A set of tags. The tags. + :vartype tags: 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 """ _attribute_map = { @@ -383,6 +424,14 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. The tags. + :paramtype tags: dict[str, str] + :keyword id: The Event Hub-compatible consumer group identifier. + :paramtype id: str + :keyword name: The Event Hub-compatible consumer group name. + :paramtype name: str + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.tags = tags self.id = id @@ -394,8 +443,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of Event Hub-compatible consumer group names. - :type value: list[str] + :ivar value: The array of Event Hub-compatible consumer group names. + :vartype value: list[str] :ivar next_link: The next link. :vartype next_link: str """ @@ -415,6 +464,10 @@ def __init__( value: Optional[List[str]] = None, **kwargs ): + """ + :keyword value: The array of Event Hub-compatible consumer group names. + :paramtype value: list[str] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -425,13 +478,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -461,6 +514,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -474,11 +536,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -498,6 +560,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -508,19 +577,19 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param source: Required. The source to which the routing rule is to be applied to. For example, + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2017_07_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -545,6 +614,21 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword source: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2017_07_01.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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.source = source self.condition = condition @@ -555,17 +639,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -586,6 +670,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -597,10 +694,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -620,6 +717,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -659,6 +762,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -679,10 +784,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -707,6 +812,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -728,22 +839,22 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param subscriptionid: Required. The subscription identifier. - :type subscriptionid: str - :param resourcegroup: Required. The name of the resource group that contains the IoT hub. A + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] + :ivar subscriptionid: Required. The subscription identifier. + :vartype subscriptionid: str + :ivar resourcegroup: Required. The name of the resource group that contains the IoT hub. A resource group name uniquely identifies the resource group within the subscription. - :type resourcegroup: str - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :vartype resourcegroup: 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2017_07_01.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: The properties of an IoT hub. + :vartype properties: ~azure.mgmt.iothub.v2017_07_01.models.IotHubProperties + :ivar sku: Required. Information about the SKU of the IoT hub. + :vartype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo """ _validation = { @@ -781,6 +892,24 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + :keyword subscriptionid: Required. The subscription identifier. + :paramtype subscriptionid: str + :keyword resourcegroup: Required. The name of the resource group that contains the IoT hub. A + resource group name uniquely identifies the resource group within the subscription. + :paramtype resourcegroup: 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: The properties of an IoT hub. + :paramtype properties: ~azure.mgmt.iothub.v2017_07_01.models.IotHubProperties + :keyword sku: Required. Information about the SKU of the IoT hub. + :paramtype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.subscriptionid = subscriptionid self.resourcegroup = resourcegroup @@ -794,8 +923,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -815,6 +944,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -830,8 +963,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -851,6 +984,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -862,49 +999,50 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2017_07_01.models.IpFilterRule] + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2017_07_01.models.IpFilterRule] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str :ivar host_name: The name of the host. :vartype host_name: str - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to this dictionary are events and operationsMonitoringEvents. Both of these keys have to be present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2017_07_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2017_07_01.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2017_07_01.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2017_07_01.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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2017_07_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2017_07_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2017_07_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. + :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.v2017_07_01.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar operations_monitoring_properties: The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: + :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2017_07_01.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2017_07_01.models.Capabilities + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2017_07_01.models.Capabilities """ _validation = { @@ -944,6 +1082,48 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2017_07_01.models.IpFilterRule] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys + to this dictionary are events and operationsMonitoringEvents. Both of these keys have 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.v2017_07_01.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.v2017_07_01.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.v2017_07_01.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2017_07_01.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.v2017_07_01.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword operations_monitoring_properties: The operations monitoring properties for the IoT + hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, + DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, + TwinQueries, JobsOperations, DirectMethods. + :paramtype operations_monitoring_properties: + ~azure.mgmt.iothub.v2017_07_01.models.OperationsMonitoringProperties + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2017_07_01.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -989,6 +1169,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1000,8 +1182,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1021,6 +1203,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1035,10 +1221,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2017_07_01.models.IotHubCapacity + :ivar sku: Required. Information about the SKU of the IoT hub. + :vartype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo + :ivar capacity: Required. IoT Hub capacity information. + :vartype capacity: ~azure.mgmt.iothub.v2017_07_01.models.IotHubCapacity """ _validation = { @@ -1060,6 +1246,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. Information about the SKU of the IoT hub. + :paramtype sku: ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuInfo + :keyword capacity: Required. IoT Hub capacity information. + :paramtype capacity: ~azure.mgmt.iothub.v2017_07_01.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1071,8 +1263,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1092,6 +1284,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1104,13 +1300,13 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSku + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :vartype name: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuTier - :param capacity: Required. The number of provisioned IoT Hub units. See: + :ivar capacity: Required. The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1132,6 +1328,13 @@ def __init__( capacity: int, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :paramtype name: str or ~azure.mgmt.iothub.v2017_07_01.models.IotHubSku + :keyword capacity: Required. The number of provisioned IoT Hub units. See: + https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. + :paramtype capacity: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1143,14 +1346,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2017_07_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2017_07_01.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1173,6 +1376,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2017_07_01.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1231,6 +1444,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1247,8 +1462,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2017_07_01.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2017_07_01.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1268,6 +1483,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2017_07_01.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1276,16 +1495,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1306,6 +1525,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1319,8 +1550,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2017_07_01.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2017_07_01.models.OperationDisplay """ _validation = { @@ -1338,6 +1569,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2017_07_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1372,6 +1607,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1383,8 +1620,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1401,6 +1638,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1430,6 +1671,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1438,8 +1681,9 @@ def __init__( class OperationsMonitoringProperties(msrest.serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2017_07_01.models.OperationMonitoringLevel] + :ivar events: Dictionary of :code:``. + :vartype events: dict[str, str or + ~azure.mgmt.iothub.v2017_07_01.models.OperationMonitoringLevel] """ _attribute_map = { @@ -1452,6 +1696,11 @@ def __init__( events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, **kwargs ): + """ + :keyword events: Dictionary of :code:``. + :paramtype events: dict[str, str or + ~azure.mgmt.iothub.v2017_07_01.models.OperationMonitoringLevel] + """ super(OperationsMonitoringProperties, self).__init__(**kwargs) self.events = events @@ -1485,6 +1734,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1496,23 +1747,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2017_07_01.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2017_07_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -1540,6 +1790,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2017_07_01.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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -1551,20 +1820,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2017_07_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2017_07_01.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2017_07_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: list[~azure.mgmt.iothub.v2017_07_01.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2017_07_01.models.RoutingStorageContainerProperties] """ @@ -1584,6 +1853,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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.v2017_07_01.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.v2017_07_01.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.v2017_07_01.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.v2017_07_01.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -1596,17 +1882,17 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -1630,6 +1916,19 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1640,20 +1939,20 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2017_07_01.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2017_07_01.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. - :type routes: list[~azure.mgmt.iothub.v2017_07_01.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2017_07_01.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. - :type fallback_route: ~azure.mgmt.iothub.v2017_07_01.models.FallbackRouteProperties + :vartype fallback_route: ~azure.mgmt.iothub.v2017_07_01.models.FallbackRouteProperties """ _attribute_map = { @@ -1670,6 +1969,22 @@ def __init__( fallback_route: Optional["FallbackRouteProperties"] = None, **kwargs ): + """ + :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.v2017_07_01.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.v2017_07_01.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.v2017_07_01.models.FallbackRouteProperties + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -1681,18 +1996,18 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -1716,6 +2031,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need + not be the same as the actual queue name. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1728,18 +2057,18 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -1763,6 +2092,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name + need not be the same as the actual topic name. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1775,32 +2118,32 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the storage account. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :vartype max_chunk_size_in_bytes: int + :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are 'avro' and 'avroDeflate'. Default value is 'avro'. - :type encoding: str + :vartype encoding: str """ _validation = { @@ -1837,6 +2180,34 @@ def __init__( encoding: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the storage account. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. + :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: Required. The name of storage container in the storage account. + :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' and 'avroDeflate'. Default value is 'avro'. + :paramtype encoding: str + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1854,20 +2225,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2017_07_01.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2017_07_01.models.AccessRights """ _validation = { @@ -1891,6 +2262,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2017_07_01.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -1903,8 +2290,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -1924,6 +2312,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1934,16 +2327,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -1965,6 +2358,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py index 164e27cd88c5..18cb73c3bed8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2017_07_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2017_07_01.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py index ad374e0f45fb..91c889db3eb2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_iot_hub_resource_operations.py @@ -5,25 +5,740 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-07-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +762,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +787,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +812,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +863,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +895,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +920,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,48 +946,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -309,15 +992,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -328,15 +1013,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescription + or ~azure.mgmt.iothub.v2017_07_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -350,24 +1039,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -379,20 +1061,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -400,34 +1085,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -440,23 +1120,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -464,8 +1145,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -473,35 +1156,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -514,24 +1193,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -550,33 +1230,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -585,15 +1255,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -603,8 +1275,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -612,36 +1286,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -654,26 +1325,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -685,8 +1358,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -694,37 +1369,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -737,26 +1410,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -779,35 +1453,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -816,17 +1480,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -849,35 +1515,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -886,17 +1542,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -919,35 +1577,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -955,14 +1603,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -972,8 +1622,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -981,36 +1633,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1023,26 +1672,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1063,34 +1714,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1099,15 +1740,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1117,8 +1760,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1126,36 +1771,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1168,23 +1810,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1202,36 +1845,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1240,16 +1873,19 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1259,8 +1895,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2017_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1268,36 +1906,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1310,26 +1945,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1350,34 +1987,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1386,17 +2013,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1418,38 +2049,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1458,17 +2079,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1490,38 +2115,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1530,4 +2145,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py index 8a0e549c5986..6c4cffa23041 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2017_07_01/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2017-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2017-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2018_01_22/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py index 46c8164f647d..f55c34e1de97 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2018_01_22/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py index 7f5c336afba6..68bffdac7958 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_iot_hub_client.py @@ -6,26 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubResourceOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import CertificatesOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -38,52 +34,56 @@ class IotHubClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json index 423759ef29b5..e2500d28a681 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py index be74a731d3c7..a3da587edd4f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2018_01_22/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py index 4d778632863e..ea05376c5fae 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_iot_hub_client.py @@ -6,80 +6,85 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubResourceOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import CertificatesOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2018_01_22.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2018_01_22.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2018_01_22.aio.operations.IotHubResourceOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2018_01_22.aio.operations.CertificatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False self._deserialize = Deserializer(client_models) + self._serialize.client_side_validation = False + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.iot_hub_resource = IotHubResourceOperations(self._client, self._config, self._serialize, self._deserialize) + self.certificates = CertificatesOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.iot_hub_resource = IotHubResourceOperations( - self._client, self._config, self._serialize, self._deserialize) - self.certificates = CertificatesOperations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py index 99a1ed3a7e8c..ee30cb4164b2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py index 57193c221bf7..6326463e758e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, build_export_devices_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_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2018_01_22.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription or + ~azure.mgmt.iothub.v2018_01_22.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -959,35 +922,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -996,8 +949,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1028,35 +984,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1064,13 +1010,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1080,8 +1029,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1089,36 +1040,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1131,17 +1079,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1149,7 +1099,8 @@ async def get_job( 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. 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. @@ -1170,34 +1121,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1206,8 +1147,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1223,8 +1167,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1232,36 +1178,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1274,17 +1217,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1307,36 +1252,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1345,15 +1280,19 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1363,8 +1302,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1372,36 +1313,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1414,17 +1352,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1432,7 +1372,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1453,34 +1394,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1489,8 +1420,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1498,7 +1432,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1520,38 +1456,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') + + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1560,8 +1486,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1569,7 +1498,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1591,38 +1522,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1631,4 +1552,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py index 5ced46710767..a0f3e84a084b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_01_22.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2018_01_22/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/__init__.py index e6897b3d0f01..30257e59af2f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/__init__.py @@ -6,104 +6,55 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import OperationsMonitoringProperties - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource -except (SyntaxError, ImportError): - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OperationsMonitoringProperties # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import OperationsMonitoringProperties +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py index affd81b47524..8c8854d1a75a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,21 +31,21 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -68,7 +53,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -77,21 +62,21 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): S2 = "S2" S3 = "S3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ FREE = "Free" STANDARD = "Standard" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -102,7 +87,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -117,7 +102,7 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operations monitoring level. """ @@ -126,7 +111,7 @@ class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models.py deleted file mode 100644 index 478c725fba93..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models.py +++ /dev/null @@ -1,1858 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - - -class CertificatePropertiesWithNonce(msrest.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 - """ - - _validation = { - 'subject': {'readonly': True}, - 'expiry': {'readonly': True}, - 'thumbprint': {'readonly': True}, - 'is_verified': {'readonly': True}, - 'created': {'readonly': True}, - 'updated': {'readonly': True}, - 'verification_code': {'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'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificatePropertiesWithNonce, self).__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 - - -class CertificateVerificationDescription(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2018_01_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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2018_01_22.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2018_01_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 - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to - this dictionary are events and operationsMonitoringEvents. Both of these keys have to be - present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2018_01_22.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2018_01_22.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2018_01_22.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2018_01_22.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2018_01_22.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. - The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, - DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, - TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: - ~azure.mgmt.iothub.v2018_01_22.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2018_01_22.models.Capabilities - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'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'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.operations_monitoring_properties = kwargs.get('operations_monitoring_properties', None) - self.features = kwargs.get('features', None) - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". - :vartype tier: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2018_01_22.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2018_01_22.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2018_01_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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2018_01_22.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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.v2018_01_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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OperationsMonitoringProperties(msrest.serialization.Model): - """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2018_01_22.models.OperationMonitoringLevel] - """ - - _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsMonitoringProperties, self).__init__(**kwargs) - self.events = kwargs.get('events', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2018_01_22.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2018_01_22.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2018_01_22.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2018_01_22.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2018_01_22.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2018_01_22.models.FallbackRouteProperties - """ - - _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro' and 'avroDeflate'. Default value is 'avro'. - :type encoding: str - """ - - _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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2018_01_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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py index a4f67c3579ba..b3c1a0c63993 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/models/_models_py3.py @@ -18,9 +18,9 @@ class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -42,8 +47,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2018_01_22.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2018_01_22.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -75,6 +80,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2018_01_22.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -86,8 +95,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription] """ _attribute_map = { @@ -100,6 +109,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -145,6 +158,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -200,6 +215,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -213,9 +230,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -228,6 +245,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -237,9 +259,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2018_01_22.models.CertificatePropertiesWithNonce + :vartype properties: ~azure.mgmt.iothub.v2018_01_22.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -271,6 +293,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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.v2018_01_22.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -282,16 +309,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2018_01_22.models.FeedbackProperties + :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.v2018_01_22.models.FeedbackProperties """ _validation = { @@ -312,6 +339,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2018_01_22.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -351,6 +390,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -363,8 +404,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, str] + :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. @@ -396,6 +437,10 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, str] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -409,8 +454,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo] + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -430,6 +475,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -440,13 +489,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -476,6 +525,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -489,11 +547,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -513,6 +571,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -523,22 +588,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2018_01_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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -565,6 +630,24 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2018_01_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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -576,17 +659,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -607,6 +690,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -618,10 +714,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -641,6 +737,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -680,6 +782,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -700,10 +804,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -728,6 +832,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -749,17 +859,17 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: The properties of an IoT hub. - :type properties: ~azure.mgmt.iothub.v2018_01_22.models.IotHubProperties - :param sku: Required. Information about the SKU of the IoT hub. - :type sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: The properties of an IoT hub. + :vartype properties: ~azure.mgmt.iothub.v2018_01_22.models.IotHubProperties + :ivar sku: Required. Information about the SKU of the IoT hub. + :vartype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo """ _validation = { @@ -791,6 +901,19 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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: The properties of an IoT hub. + :paramtype properties: ~azure.mgmt.iothub.v2018_01_22.models.IotHubProperties + :keyword sku: Required. Information about the SKU of the IoT hub. + :paramtype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -802,8 +925,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -823,6 +946,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -838,8 +965,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -859,6 +986,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -870,51 +1001,52 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2018_01_22.models.IpFilterRule] + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2018_01_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 - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to this dictionary are events and operationsMonitoringEvents. Both of these keys have to be present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2018_01_22.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2018_01_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. - :type routing: ~azure.mgmt.iothub.v2018_01_22.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2018_01_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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2018_01_22.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2018_01_22.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2018_01_22.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. + :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.v2018_01_22.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar operations_monitoring_properties: The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: + :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2018_01_22.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2018_01_22.models.Capabilities + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2018_01_22.models.Capabilities """ _validation = { @@ -956,6 +1088,48 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2018_01_22.models.IpFilterRule] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys + to this dictionary are events and operationsMonitoringEvents. Both of these keys have 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.v2018_01_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.v2018_01_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.v2018_01_22.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2018_01_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.v2018_01_22.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword operations_monitoring_properties: The operations monitoring properties for the IoT + hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, + DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, + TwinQueries, JobsOperations, DirectMethods. + :paramtype operations_monitoring_properties: + ~azure.mgmt.iothub.v2018_01_22.models.OperationsMonitoringProperties + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2018_01_22.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -1002,6 +1176,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1013,8 +1189,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1034,6 +1210,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1048,10 +1228,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo - :param capacity: Required. IoT Hub capacity information. - :type capacity: ~azure.mgmt.iothub.v2018_01_22.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo + :ivar capacity: Required. IoT Hub capacity information. + :vartype capacity: ~azure.mgmt.iothub.v2018_01_22.models.IotHubCapacity """ _validation = { @@ -1073,6 +1253,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuInfo + :keyword capacity: Required. IoT Hub capacity information. + :paramtype capacity: ~azure.mgmt.iothub.v2018_01_22.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1084,8 +1270,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1105,6 +1291,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1117,13 +1307,13 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". - :type name: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSku + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :vartype name: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard". :vartype tier: str or ~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1144,6 +1334,13 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3". + :paramtype name: str or ~azure.mgmt.iothub.v2018_01_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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1155,14 +1352,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2018_01_22.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2018_01_22.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1185,6 +1382,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2018_01_22.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1243,6 +1450,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1259,8 +1468,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2018_01_22.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1280,6 +1489,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_01_22.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1288,16 +1501,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1318,6 +1531,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1331,8 +1556,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2018_01_22.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2018_01_22.models.OperationDisplay """ _validation = { @@ -1350,6 +1575,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2018_01_22.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1384,6 +1613,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1395,8 +1626,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1413,6 +1644,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1442,6 +1677,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1450,8 +1687,9 @@ def __init__( class OperationsMonitoringProperties(msrest.serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2018_01_22.models.OperationMonitoringLevel] + :ivar events: Dictionary of :code:``. + :vartype events: dict[str, str or + ~azure.mgmt.iothub.v2018_01_22.models.OperationMonitoringLevel] """ _attribute_map = { @@ -1464,6 +1702,11 @@ def __init__( events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, **kwargs ): + """ + :keyword events: Dictionary of :code:``. + :paramtype events: dict[str, str or + ~azure.mgmt.iothub.v2018_01_22.models.OperationMonitoringLevel] + """ super(OperationsMonitoringProperties, self).__init__(**kwargs) self.events = events @@ -1497,6 +1740,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1508,23 +1753,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_01_22.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2018_01_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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -1552,6 +1796,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2018_01_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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -1563,20 +1826,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2018_01_22.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2018_01_22.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2018_01_22.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: list[~azure.mgmt.iothub.v2018_01_22.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2018_01_22.models.RoutingStorageContainerProperties] """ @@ -1596,6 +1859,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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.v2018_01_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.v2018_01_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.v2018_01_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.v2018_01_22.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -1608,17 +1888,17 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -1642,6 +1922,19 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1652,20 +1945,20 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2018_01_22.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2018_01_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. - :type routes: list[~azure.mgmt.iothub.v2018_01_22.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2018_01_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. - :type fallback_route: ~azure.mgmt.iothub.v2018_01_22.models.FallbackRouteProperties + :vartype fallback_route: ~azure.mgmt.iothub.v2018_01_22.models.FallbackRouteProperties """ _attribute_map = { @@ -1682,6 +1975,22 @@ def __init__( fallback_route: Optional["FallbackRouteProperties"] = None, **kwargs ): + """ + :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.v2018_01_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.v2018_01_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.v2018_01_22.models.FallbackRouteProperties + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -1693,18 +2002,18 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -1728,6 +2037,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need + not be the same as the actual queue name. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1740,18 +2063,18 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -1775,6 +2098,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name + need not be the same as the actual topic name. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1787,32 +2124,32 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the storage account. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :vartype max_chunk_size_in_bytes: int + :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are 'avro' and 'avroDeflate'. Default value is 'avro'. - :type encoding: str + :vartype encoding: str """ _validation = { @@ -1849,6 +2186,34 @@ def __init__( encoding: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the storage account. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. + :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: Required. The name of storage container in the storage account. + :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' and 'avroDeflate'. Default value is 'avro'. + :paramtype encoding: str + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1866,20 +2231,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2018_01_22.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2018_01_22.models.AccessRights """ _validation = { @@ -1903,6 +2268,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2018_01_22.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -1915,8 +2296,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -1936,6 +2318,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1946,16 +2333,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -1977,6 +2364,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -1986,8 +2385,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2000,5 +2399,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py index 35f9c53f2ca1..0ff51fe8a7db 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_01_22.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_01_22.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py index 173495d79397..c563c9fa4cbe 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_iot_hub_resource_operations.py @@ -5,25 +5,784 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-22" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +806,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +831,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +856,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +907,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +939,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +964,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +990,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1034,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1058,19 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2018_01_22.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1082,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1108,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1154,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1175,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescription + or ~azure.mgmt.iothub.v2018_01_22.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1201,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1223,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1247,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1282,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1307,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1318,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1355,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1392,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1417,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1437,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1448,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1487,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1520,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1531,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1572,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1615,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,17 +1642,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -977,35 +1677,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1014,17 +1704,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1047,35 +1739,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1083,14 +1765,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1100,8 +1784,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1109,36 +1795,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1151,26 +1834,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1191,34 +1876,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1227,15 +1902,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1245,8 +1922,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1254,36 +1933,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1296,23 +1972,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1330,36 +2007,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(operation_inputs, 'OperationInputs') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1368,16 +2035,19 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1387,8 +2057,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_01_22.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1396,36 +2068,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1438,26 +2107,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1478,34 +2149,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1514,17 +2175,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1546,38 +2211,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1586,17 +2241,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1618,38 +2277,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1658,4 +2307,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py index 753e76714763..b03fd6ba6885 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_01_22/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-01-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-01-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2018_04_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py index 191838f43422..b769e14330dc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2018_04_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py index 961242fbb475..90c47669ff17 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_iot_hub_client.py @@ -6,27 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -34,61 +29,65 @@ class IotHubClient(object): :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2018_04_01.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2018_04_01.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2018_04_01.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2018_04_01.operations.CertificatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json index 1879addea0cf..77f57a51f86f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py index 9f87a6d39037..33025dfbeb4b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2018_04_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py index 66af50401262..e6b9814e84cf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_iot_hub_client.py @@ -6,85 +6,89 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2018_04_01.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2018_04_01.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2018_04_01.aio.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2018_04_01.aio.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2018_04_01.aio.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2018_04_01.aio.operations.CertificatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py index 6f2338e5a2b9..b49828f49c8b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py index 6d146901419b..cc101dda0373 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2018_04_01.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription or + ~azure.mgmt.iothub.v2018_04_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -959,35 +922,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -996,8 +949,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1028,35 +984,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1064,13 +1010,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1080,8 +1029,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1089,36 +1040,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1131,17 +1079,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1149,7 +1099,8 @@ async def get_job( 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. 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. @@ -1170,34 +1121,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1206,8 +1147,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1223,8 +1167,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1232,36 +1178,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1274,17 +1217,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1300,8 +1245,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1309,36 +1256,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1351,17 +1295,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1384,36 +1330,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1422,8 +1358,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1451,38 +1390,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1491,8 +1420,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1520,38 +1452,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1560,15 +1482,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1578,8 +1504,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1587,36 +1515,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1629,17 +1554,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1647,7 +1574,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1668,34 +1596,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1704,8 +1622,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1713,7 +1634,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1735,38 +1658,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1775,8 +1688,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1784,7 +1700,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1806,38 +1724,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1846,4 +1754,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py index e64469ea5166..dafdb8c83729 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2018_04_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2018_04_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py index 66379c6dbde4..b13bd6e0238b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py index 87505480d984..ab7ebbb14918 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/__init__.py @@ -6,138 +6,72 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import OperationsMonitoringProperties - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import OperationsMonitoringProperties # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import OperationsMonitoringProperties +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py index 1c82fd13a05c..0ee5551a863e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,14 +31,14 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The health status code of the endpoint """ @@ -62,14 +47,14 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -77,7 +62,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -89,7 +74,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -97,14 +82,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -115,7 +100,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -130,7 +115,7 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class OperationMonitoringLevel(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The operations monitoring level. """ @@ -139,14 +124,14 @@ class OperationMonitoringLevel(with_metaclass(_CaseInsensitiveEnumMeta, str, Enu INFORMATION = "Information" ERROR_INFORMATION = "Error, Information" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -156,7 +141,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models.py deleted file mode 100644 index 15b86cdf4710..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models.py +++ /dev/null @@ -1,2300 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: The health status code of the endpoint. Possible values include: - "unknown", "healthy", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthStatus - """ - - _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2018_04_01.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2018_04_01.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 - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to - this dictionary are events and operationsMonitoringEvents. Both of these keys have to be - present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2018_04_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2018_04_01.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2018_04_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2018_04_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2018_04_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. - The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, - DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, - TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: - ~azure.mgmt.iothub.v2018_04_01.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2018_04_01.models.Capabilities - """ - - _validation = { - 'provisioning_state': {'readonly': True}, - 'state': {'readonly': True}, - 'host_name': {'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'}, - 'operations_monitoring_properties': {'key': 'operationsMonitoringProperties', 'type': 'OperationsMonitoringProperties'}, - 'features': {'key': 'features', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.operations_monitoring_properties = kwargs.get('operations_monitoring_properties', None) - self.features = kwargs.get('features', None) - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2018_04_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2018_04_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2018_04_01.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2018_04_01.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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.v2018_04_01.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class OperationsMonitoringProperties(msrest.serialization.Model): - """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2018_04_01.models.OperationMonitoringLevel] - """ - - _attribute_map = { - 'events': {'key': 'events', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsMonitoringProperties, self).__init__(**kwargs) - self.events = kwargs.get('events', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorRange - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition - """ - - _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2018_04_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2018_04_01.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2018_04_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2018_04_01.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2018_04_01.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2018_04_01.models.FallbackRouteProperties - """ - - _attribute_map = { - 'endpoints': {'key': 'endpoints', 'type': 'RoutingEndpoints'}, - 'routes': {'key': 'routes', 'type': '[RouteProperties]'}, - 'fallback_route': {'key': 'fallbackRoute', 'type': 'FallbackRouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need - not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. The name - need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. 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, operationsMonitoringEvents, - fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro' and 'avroDeflate'. Default value is 'avro'. - :type encoding: str - """ - - _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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwinProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired_properties: Twin desired properties. - :type desired_properties: any - :param reported_properties: Twin desired properties. - :type reported_properties: any - """ - - _attribute_map = { - 'desired_properties': {'key': 'desiredProperties', 'type': 'object'}, - 'reported_properties': {'key': 'reportedProperties', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired_properties = kwargs.get('desired_properties', None) - self.reported_properties = kwargs.get('reported_properties', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin - """ - - _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2018_04_01.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2018_04_01.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResultDetails - """ - - _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2018_04_01.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type value: list[~azure.mgmt.iothub.v2018_04_01.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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py index bb46abdae2ea..234c3d982d55 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/models/_models_py3.py @@ -18,9 +18,9 @@ class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -42,8 +47,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2018_04_01.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -75,6 +80,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -86,8 +95,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription] """ _attribute_map = { @@ -100,6 +109,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -121,8 +134,8 @@ class CertificateProperties(msrest.serialization.Model): :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. :vartype updated: ~datetime.datetime - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -150,6 +163,10 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -210,6 +227,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -224,9 +243,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -239,6 +258,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -248,9 +272,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.CertificatePropertiesWithNonce + :vartype properties: ~azure.mgmt.iothub.v2018_04_01.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -282,6 +306,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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.v2018_04_01.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -293,16 +322,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2018_04_01.models.FeedbackProperties + :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.v2018_04_01.models.FeedbackProperties """ _validation = { @@ -323,6 +352,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2018_04_01.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -332,11 +373,11 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: The health status code of the endpoint. Possible values include: + :ivar endpoint_id: Id of the endpoint. + :vartype endpoint_id: str + :ivar health_status: The health status code of the endpoint. Possible values include: "unknown", "healthy", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthStatus + :vartype health_status: str or ~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthStatus """ _attribute_map = { @@ -351,6 +392,13 @@ def __init__( health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, **kwargs ): + """ + :keyword endpoint_id: Id of the endpoint. + :paramtype endpoint_id: str + :keyword health_status: The health status code of the endpoint. Possible values include: + "unknown", "healthy", "unhealthy", "dead". + :paramtype health_status: str or ~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthStatus + """ super(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -361,8 +409,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthData] + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthData] :ivar next_link: Link to more results. :vartype next_link: str """ @@ -382,6 +430,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -420,6 +472,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -432,8 +486,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, str] + :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. @@ -465,6 +519,10 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, str] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -478,8 +536,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo] + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -499,6 +557,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -509,13 +571,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -545,6 +607,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -558,11 +629,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -582,6 +653,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -592,22 +670,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2018_04_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -634,6 +712,24 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2018_04_01.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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -645,17 +741,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -676,6 +772,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -687,10 +796,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -710,6 +819,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -749,6 +864,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -769,10 +886,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -797,6 +914,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -818,17 +941,17 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2018_04_01.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo """ _validation = { @@ -860,6 +983,19 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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.v2018_04_01.models.IotHubProperties + :keyword sku: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -871,8 +1007,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -892,6 +1028,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -907,8 +1047,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -928,6 +1068,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -939,51 +1083,52 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2018_04_01.models.IpFilterRule] + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2018_04_01.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 - :param event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to + :ivar event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys to this dictionary are events and operationsMonitoringEvents. Both of these keys have to be present in the dictionary while making create or update calls for the IoT hub. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2018_04_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :vartype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2018_04_01.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2018_04_01.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2018_04_01.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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2018_04_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2018_04_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2018_04_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param operations_monitoring_properties: The operations monitoring properties for the IoT hub. + :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.v2018_04_01.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar operations_monitoring_properties: The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :type operations_monitoring_properties: + :vartype operations_monitoring_properties: ~azure.mgmt.iothub.v2018_04_01.models.OperationsMonitoringProperties - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2018_04_01.models.Capabilities + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2018_04_01.models.Capabilities """ _validation = { @@ -1025,6 +1170,48 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2018_04_01.models.IpFilterRule] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The possible keys + to this dictionary are events and operationsMonitoringEvents. Both of these keys have 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.v2018_04_01.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.v2018_04_01.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.v2018_04_01.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2018_04_01.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.v2018_04_01.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword operations_monitoring_properties: The operations monitoring properties for the IoT + hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, + DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, + TwinQueries, JobsOperations, DirectMethods. + :paramtype operations_monitoring_properties: + ~azure.mgmt.iothub.v2018_04_01.models.OperationsMonitoringProperties + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2018_04_01.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -1071,6 +1258,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1082,8 +1271,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1103,6 +1292,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1117,10 +1310,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2018_04_01.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2018_04_01.models.IotHubCapacity """ _validation = { @@ -1142,6 +1335,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2018_04_01.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1153,8 +1352,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1174,6 +1373,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1186,15 +1389,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1215,6 +1418,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2018_04_01.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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1226,14 +1437,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2018_04_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2018_04_01.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1256,6 +1467,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2018_04_01.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1314,6 +1535,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1330,8 +1553,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1351,6 +1574,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1359,8 +1586,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties """ _attribute_map = { @@ -1373,6 +1600,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1380,16 +1611,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1410,6 +1641,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1419,10 +1662,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1437,6 +1680,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1449,8 +1698,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2018_04_01.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2018_04_01.models.OperationDisplay """ _validation = { @@ -1468,6 +1717,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2018_04_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1502,6 +1755,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1513,8 +1768,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1531,6 +1786,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1560,6 +1819,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1568,8 +1829,9 @@ def __init__( class OperationsMonitoringProperties(msrest.serialization.Model): """The operations monitoring properties for the IoT hub. The possible keys to the dictionary are Connections, DeviceTelemetry, C2DCommands, DeviceIdentityOperations, FileUploadOperations, Routes, D2CTwinOperations, C2DTwinOperations, TwinQueries, JobsOperations, DirectMethods. - :param events: Dictionary of :code:``. - :type events: dict[str, str or ~azure.mgmt.iothub.v2018_04_01.models.OperationMonitoringLevel] + :ivar events: Dictionary of :code:``. + :vartype events: dict[str, str or + ~azure.mgmt.iothub.v2018_04_01.models.OperationMonitoringLevel] """ _attribute_map = { @@ -1582,6 +1844,11 @@ def __init__( events: Optional[Dict[str, Union[str, "OperationMonitoringLevel"]]] = None, **kwargs ): + """ + :keyword events: Dictionary of :code:``. + :paramtype events: dict[str, str or + ~azure.mgmt.iothub.v2018_04_01.models.OperationMonitoringLevel] + """ super(OperationsMonitoringProperties, self).__init__(**kwargs) self.events = events @@ -1615,6 +1882,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1624,12 +1893,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorRange """ _attribute_map = { @@ -1646,6 +1915,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorRange + """ super(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -1655,10 +1932,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -1673,6 +1950,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -1681,10 +1964,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition """ _attribute_map = { @@ -1699,6 +1982,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2018_04_01.models.RouteErrorPosition + """ super(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -1709,23 +1998,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2018_04_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -1753,6 +2041,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2018_04_01.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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -1764,20 +2071,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2018_04_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2018_04_01.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2018_04_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: list[~azure.mgmt.iothub.v2018_04_01.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2018_04_01.models.RoutingStorageContainerProperties] """ @@ -1797,6 +2104,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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.v2018_04_01.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.v2018_04_01.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.v2018_04_01.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.v2018_04_01.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -1809,17 +2133,17 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -1843,6 +2167,19 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1853,12 +2190,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -1875,6 +2212,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -1884,20 +2229,20 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2018_04_01.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2018_04_01.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. - :type routes: list[~azure.mgmt.iothub.v2018_04_01.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2018_04_01.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. - :type fallback_route: ~azure.mgmt.iothub.v2018_04_01.models.FallbackRouteProperties + :vartype fallback_route: ~azure.mgmt.iothub.v2018_04_01.models.FallbackRouteProperties """ _attribute_map = { @@ -1914,6 +2259,22 @@ def __init__( fallback_route: Optional["FallbackRouteProperties"] = None, **kwargs ): + """ + :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.v2018_04_01.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.v2018_04_01.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.v2018_04_01.models.FallbackRouteProperties + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -1925,18 +2286,18 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual queue name. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -1960,6 +2321,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need + not be the same as the actual queue name. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1972,18 +2347,18 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. The name need not be the same as the actual topic name. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2007,6 +2382,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. The name + need not be the same as the actual topic name. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2019,32 +2408,32 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the storage account. + :vartype connection_string: str + :ivar name: Required. 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, operationsMonitoringEvents, fileNotifications, $default. Endpoint names must be unique across endpoint types. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :vartype max_chunk_size_in_bytes: int + :ivar encoding: Encoding that is used to serialize messages to blobs. Supported values are 'avro' and 'avroDeflate'. Default value is 'avro'. - :type encoding: str + :vartype encoding: str """ _validation = { @@ -2081,6 +2470,34 @@ def __init__( encoding: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the storage account. + :paramtype connection_string: str + :keyword name: Required. 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, operationsMonitoringEvents, + fileNotifications, $default. Endpoint names must be unique across endpoint types. + :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: Required. The name of storage container in the storage account. + :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' and 'avroDeflate'. Default value is 'avro'. + :paramtype encoding: str + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2096,10 +2513,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwinProperties """ _attribute_map = { @@ -2114,6 +2531,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2122,10 +2545,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired_properties: Twin desired properties. - :type desired_properties: any - :param reported_properties: Twin desired properties. - :type reported_properties: any + :ivar desired_properties: Twin desired properties. + :vartype desired_properties: any + :ivar reported_properties: Twin desired properties. + :vartype reported_properties: any """ _attribute_map = { @@ -2140,6 +2563,12 @@ def __init__( reported_properties: Optional[Any] = None, **kwargs ): + """ + :keyword desired_properties: Twin desired properties. + :paramtype desired_properties: any + :keyword reported_properties: Twin desired properties. + :paramtype reported_properties: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired_properties = desired_properties self.reported_properties = reported_properties @@ -2150,20 +2579,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2018_04_01.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2018_04_01.models.AccessRights """ _validation = { @@ -2187,6 +2616,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2018_04_01.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -2199,8 +2644,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -2220,6 +2666,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2230,16 +2681,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -2261,6 +2712,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -2270,8 +2733,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2284,6 +2747,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -2291,13 +2758,13 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin + :vartype routing_source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin """ _attribute_map = { @@ -2314,6 +2781,15 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2018_04_01.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin + """ super(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -2323,8 +2799,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2018_04_01.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2018_04_01.models.MatchedRoute] """ _attribute_map = { @@ -2337,6 +2813,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2018_04_01.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -2346,12 +2826,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage + :ivar route: Required. Route properties. + :vartype route: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin """ _validation = { @@ -2372,6 +2852,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2018_04_01.models.RoutingMessage + :keyword route: Required. Route properties. + :paramtype route: ~azure.mgmt.iothub.v2018_04_01.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2018_04_01.models.RoutingTwin + """ super(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -2381,10 +2869,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2018_04_01.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :vartype result: str or ~azure.mgmt.iothub.v2018_04_01.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResultDetails """ _attribute_map = { @@ -2399,6 +2887,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "true". + :paramtype result: str or ~azure.mgmt.iothub.v2018_04_01.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2018_04_01.models.TestRouteResultDetails + """ super(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -2407,8 +2902,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2018_04_01.models.RouteCompilationError] + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2018_04_01.models.RouteCompilationError] """ _attribute_map = { @@ -2421,6 +2916,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2018_04_01.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -2428,18 +2928,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2018_04_01.models.Name + :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.v2018_04_01.models.Name """ _attribute_map = { @@ -2462,6 +2962,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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.v2018_04_01.models.Name + """ super(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -2476,8 +2990,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2018_04_01.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2018_04_01.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -2497,6 +3011,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2018_04_01.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py index bb33c114ae39..e16b781d11e8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2018_04_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2018_04_01.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py index c017f84076e1..0a8da21cedb0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_iot_hub_resource_operations.py @@ -5,25 +5,907 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +929,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +954,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +979,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1030,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +1062,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +1087,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +1113,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1157,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1181,19 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2018_04_01.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1205,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1231,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1277,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1298,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescription + or ~azure.mgmt.iothub.v2018_04_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1324,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1346,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1370,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1405,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1430,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1441,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1478,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1515,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1540,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1560,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1571,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1610,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1643,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1654,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1695,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1738,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,17 +1765,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -977,35 +1800,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1014,17 +1827,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1047,35 +1862,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1083,14 +1888,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1100,8 +1907,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1109,36 +1918,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1151,26 +1957,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1191,34 +1999,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1227,15 +2025,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1245,8 +2045,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1254,36 +2056,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1296,24 +2095,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1323,8 +2123,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1332,36 +2134,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1374,23 +2173,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1408,36 +2208,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1446,16 +2236,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1476,38 +2268,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1516,16 +2298,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1546,38 +2330,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1586,16 +2360,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1605,8 +2382,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2018_04_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1614,36 +2393,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1656,26 +2432,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1696,34 +2474,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1732,17 +2500,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1764,38 +2536,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1804,17 +2566,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1836,38 +2602,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1876,4 +2632,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py index 56cbb8f8603b..52cd6c72b4e2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2018-04-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2018_04_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py index 563d41bf8ee8..6ba5aff172f3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2018_04_01/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2018-04-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2018-04-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + 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 index 8883d8041fab..a9adde0a702d 100644 --- 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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 index fbc603fb1870..cd5c63745cf2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2019_03_22/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py index afb5e82a33be..951b3ca1b38b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_iot_hub_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -35,7 +29,8 @@ class IotHubClient(object): :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 + :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 @@ -44,56 +39,58 @@ class IotHubClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None 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 index 55db6dc09a6e..fc5e51cb66cb 100644 --- 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 @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", 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/v2019_03_22/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" 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 index a84cf700a930..28356865df6a 100644 --- 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 @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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 index 37b393c08b0f..3bae35d63381 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2019_03_22/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py index f93a57bde18e..a782c8bcf8e1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_iot_hub_client.py @@ -6,34 +6,32 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .. import models - - -class IotHubClient(object): +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 + :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 + :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 @@ -42,54 +40,58 @@ class IotHubClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() 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/v2019_03_22/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py index 67eca47974e4..2fb6cf7150c3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # 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 index c2cb8ac10b48..d3da730ab3cd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,45 +58,36 @@ async def _manual_failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, @@ -115,15 +110,18 @@ async def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -135,24 +133,18 @@ async def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -164,4 +156,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # 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 index efb90a4b000c..76472d2e0237 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription or + ~azure.mgmt.iothub.v2019_03_22.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -959,35 +922,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -996,8 +949,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1028,35 +984,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1064,13 +1010,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1080,8 +1029,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1089,36 +1040,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1131,17 +1079,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1149,7 +1099,8 @@ async def get_job( 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. 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. @@ -1170,34 +1121,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1206,8 +1147,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1223,8 +1167,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1232,36 +1178,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1274,17 +1217,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1300,8 +1245,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1309,36 +1256,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1351,17 +1295,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1384,36 +1330,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1422,8 +1358,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1451,38 +1390,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1491,8 +1420,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1520,38 +1452,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1560,15 +1482,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1578,8 +1504,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1587,36 +1515,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1629,17 +1554,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1647,7 +1574,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1668,34 +1596,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1704,8 +1622,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1713,7 +1634,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1735,38 +1658,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1775,8 +1688,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1784,7 +1700,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1806,38 +1724,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1846,4 +1754,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py index aa1890635d53..f28df237f22e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_03_22.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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_03_22/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py index c880e562b35a..01f77bcf4b4a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # 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 index 521f9ee14412..db0d9c0ada4a 100644 --- 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 @@ -6,140 +6,73 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FailoverInput - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubLocationDescription - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FailoverInput # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubLocationDescription # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py index 000a2df33e9b..19ff62f5aabe 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,14 +31,14 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -70,14 +55,14 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -86,7 +71,7 @@ class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -94,7 +79,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -106,7 +91,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -114,14 +99,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -132,7 +117,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -147,14 +132,14 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -164,7 +149,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -173,7 +158,7 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveE AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models.py deleted file mode 100644 index 0359132db5a2..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models.py +++ /dev/null @@ -1,2344 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type 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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type 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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type 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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param 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. Possible values include: "unknown", "healthy", "unhealthy", - "dead". - :type 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, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type 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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FailoverInput(msrest.serialization.Model): - """Use to provide failover region when requesting manual Failover for a hub. - - All required parameters must be populated in order to send to Azure. - - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str - """ - - _validation = { - 'failover_region': {'required': True}, - } - - _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverInput, self).__init__(**kwargs) - self.failover_region = kwargs['failover_region'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type 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, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type 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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubLocationDescription(msrest.serialization.Model): - """Public representation of one of the locations where a resource is provisioned. - - :param location: The name of the Azure region. - :type location: str - :param 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. Possible values - include: "primary", "secondary". - :type 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, - **kwargs - ): - super(IotHubLocationDescription, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.role = kwargs.get('role', None) - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type 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 - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2019_03_22.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2019_03_22.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_03_22.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_03_22.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2019_03_22.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type 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, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.features = kwargs.get('features', None) - self.locations = None - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type 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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type 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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type 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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2019_03_22.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2019_03_22.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type 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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type 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, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type 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, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorPosition - """ - - _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2019_03_22.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2019_03_22.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2019_03_22.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type 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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2019_03_22.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2019_03_22.models.RouteProperties] - :param 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. - :type 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, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". - :type 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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwinProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any - """ - - _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired = kwargs.get('desired', None) - self.reported = kwargs.get('reported', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type 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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type 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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :param twin: Routing Twin Reference. - :type 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, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2019_03_22.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties - :param twin: Routing Twin Reference. - :type 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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2019_03_22.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResultDetails - """ - - _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2019_03_22.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type 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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type 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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py index 202cfa479536..3b9699b9de18 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/models/_models_py3.py @@ -18,9 +18,9 @@ class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -42,8 +47,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.CertificateProperties + :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. @@ -75,6 +80,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -86,8 +95,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription] """ _attribute_map = { @@ -100,6 +109,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -121,8 +134,8 @@ class CertificateProperties(msrest.serialization.Model): :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. :vartype updated: ~datetime.datetime - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -150,6 +163,10 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -210,6 +227,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -224,9 +243,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -239,6 +258,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -248,9 +272,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.CertificatePropertiesWithNonce + :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. @@ -282,6 +306,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -293,16 +322,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2019_03_22.models.FeedbackProperties + :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 = { @@ -323,6 +352,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -332,9 +373,9 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: Health statuses have following meanings. The 'healthy' status shows that + :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 @@ -344,7 +385,7 @@ class EndpointHealthData(msrest.serialization.Model): the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthStatus + :vartype health_status: str or ~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthStatus """ _attribute_map = { @@ -359,6 +400,21 @@ def __init__( health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, **kwargs ): + """ + :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. Possible values include: "unknown", + "healthy", "unhealthy", "dead". + :paramtype health_status: str or ~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthStatus + """ super(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -369,8 +425,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthData] + :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 """ @@ -390,6 +446,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -428,6 +488,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -440,8 +502,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, str] + :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. @@ -473,6 +535,10 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, str] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -486,8 +552,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo] + :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 """ @@ -507,6 +573,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -517,13 +587,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -553,6 +623,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -566,11 +645,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -590,6 +669,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -600,8 +686,8 @@ class FailoverInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str + :ivar failover_region: Required. Region the hub will be failed over to. + :vartype failover_region: str """ _validation = { @@ -618,6 +704,10 @@ def __init__( failover_region: str, **kwargs ): + """ + :keyword failover_region: Required. Region the hub will be failed over to. + :paramtype failover_region: str + """ super(FailoverInput, self).__init__(**kwargs) self.failover_region = failover_region @@ -627,22 +717,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -669,6 +759,24 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -680,17 +788,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -711,6 +819,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -722,10 +843,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -745,6 +866,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -784,6 +911,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -804,10 +933,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -832,6 +961,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -853,17 +988,17 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2019_03_22.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo """ _validation = { @@ -895,6 +1030,19 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -906,8 +1054,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + :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 """ @@ -927,6 +1075,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -935,13 +1087,13 @@ def __init__( class IotHubLocationDescription(msrest.serialization.Model): """Public representation of one of the locations where a resource is provisioned. - :param location: The name of the Azure region. - :type location: str - :param role: The role of the region, can be either primary or secondary. The primary region is + :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. Possible values include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubReplicaRoleType + :vartype role: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubReplicaRoleType """ _attribute_map = { @@ -956,6 +1108,15 @@ def __init__( role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, **kwargs ): + """ + :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. Possible + values include: "primary", "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubReplicaRoleType + """ super(IotHubLocationDescription, self).__init__(**kwargs) self.location = location self.role = role @@ -971,8 +1132,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -992,6 +1153,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -1003,45 +1168,46 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2019_03_22.models.IpFilterRule] + :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 - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2019_03_22.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :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. - :type routing: ~azure.mgmt.iothub.v2019_03_22.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2019_03_22.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2019_03_22.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2019_03_22.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2019_03_22.models.Capabilities + :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. Possible values include: + "None", "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] """ @@ -1085,6 +1251,42 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2019_03_22.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -1131,6 +1333,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1142,8 +1346,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfo] + :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 """ @@ -1163,6 +1367,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1177,10 +1385,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2019_03_22.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2019_03_22.models.IotHubCapacity """ _validation = { @@ -1202,6 +1410,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2019_03_22.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1213,8 +1427,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescription] + :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 """ @@ -1234,6 +1448,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1246,15 +1464,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1275,6 +1493,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1286,14 +1512,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2019_03_22.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2019_03_22.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1316,6 +1542,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2019_03_22.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1374,6 +1610,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1390,8 +1628,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.JobResponse] + :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 """ @@ -1411,6 +1649,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1419,8 +1661,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties """ _attribute_map = { @@ -1433,6 +1675,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1440,16 +1686,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1470,6 +1716,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1479,10 +1737,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1497,6 +1755,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1509,8 +1773,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2019_03_22.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2019_03_22.models.OperationDisplay """ _validation = { @@ -1528,6 +1792,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2019_03_22.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1566,6 +1834,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1578,8 +1848,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1596,6 +1866,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1625,6 +1899,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1659,6 +1935,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1668,12 +1946,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "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 = { @@ -1690,6 +1968,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "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(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -1699,10 +1985,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -1717,6 +2003,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -1725,10 +2017,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2019_03_22.models.RouteErrorPosition + :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 = { @@ -1743,6 +2035,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :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(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -1753,23 +2051,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -1797,6 +2094,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -1808,20 +2124,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2019_03_22.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2019_03_22.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2019_03_22.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :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. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2019_03_22.models.RoutingStorageContainerProperties] """ @@ -1841,6 +2157,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -1853,17 +2186,17 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -1887,6 +2220,19 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1897,12 +2243,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -1919,6 +2265,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -1928,20 +2282,20 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2019_03_22.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :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. - :type routes: list[~azure.mgmt.iothub.v2019_03_22.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :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. - :type fallback_route: ~azure.mgmt.iothub.v2019_03_22.models.FallbackRouteProperties + :vartype fallback_route: ~azure.mgmt.iothub.v2019_03_22.models.FallbackRouteProperties """ _attribute_map = { @@ -1958,6 +2312,22 @@ def __init__( fallback_route: Optional["FallbackRouteProperties"] = None, **kwargs ): + """ + :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(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -1969,18 +2339,18 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -2004,6 +2374,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2016,18 +2400,18 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2051,6 +2435,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2063,33 +2461,33 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the storage account. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :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'. Possible values include: "Avro", "AvroDeflate", "JSON". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingStorageContainerPropertiesEncoding """ @@ -2127,6 +2525,36 @@ def __init__( encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the storage account. + :paramtype connection_string: str + :keyword name: Required. 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. + :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: Required. The name of storage container in the storage account. + :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'. Possible values include: "Avro", + "AvroDeflate", "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2019_03_22.models.RoutingStorageContainerPropertiesEncoding + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2142,10 +2570,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwinProperties """ _attribute_map = { @@ -2160,6 +2588,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2168,10 +2602,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any + :ivar desired: Twin desired properties. + :vartype desired: any + :ivar reported: Twin desired properties. + :vartype reported: any """ _attribute_map = { @@ -2186,6 +2620,12 @@ def __init__( reported: Optional[Any] = None, **kwargs ): + """ + :keyword desired: Twin desired properties. + :paramtype desired: any + :keyword reported: Twin desired properties. + :paramtype reported: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired = desired self.reported = reported @@ -2196,20 +2636,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2019_03_22.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2019_03_22.models.AccessRights """ _validation = { @@ -2233,6 +2673,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2019_03_22.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -2245,8 +2701,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] + :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 """ @@ -2266,6 +2723,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2276,16 +2738,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -2307,6 +2769,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -2316,8 +2790,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2330,6 +2804,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -2337,13 +2815,13 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2019_03_22.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwin + :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 = { @@ -2360,6 +2838,15 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "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(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -2369,8 +2856,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2019_03_22.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2019_03_22.models.MatchedRoute] """ _attribute_map = { @@ -2383,6 +2870,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2019_03_22.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -2392,12 +2883,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2019_03_22.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_03_22.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage + :ivar route: Required. Route properties. + :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 = { @@ -2418,6 +2909,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2019_03_22.models.RoutingMessage + :keyword route: Required. Route properties. + :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(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -2427,10 +2926,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2019_03_22.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2019_03_22.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "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 = { @@ -2445,6 +2944,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "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(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -2453,8 +2959,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2019_03_22.models.RouteCompilationError] + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2019_03_22.models.RouteCompilationError] """ _attribute_map = { @@ -2467,6 +2973,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2019_03_22.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -2474,18 +2985,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2019_03_22.models.Name + :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 = { @@ -2508,6 +3019,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -2522,8 +3047,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -2543,6 +3068,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2019_03_22.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py index 8d9b4615329e..4dcff655b801 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_03_22.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_03_22.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # 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 index 518aec6fce65..5b443b3b4450 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_operations.py @@ -5,24 +5,71 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_manual_failover_request_initial( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubOperations(object): """IotHubOperations operations. @@ -48,64 +95,53 @@ def __init__(self, client, config, serializer, deserializer): def _manual_failover_initial( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> None + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace def begin_manual_failover( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **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 @@ -121,15 +157,18 @@ def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2019_03_22.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -141,24 +180,18 @@ def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -170,4 +203,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # 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 index 754a6e33e4b1..586341a29d20 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_iot_hub_resource_operations.py @@ -5,25 +5,907 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +929,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +954,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +979,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1030,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +1062,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +1087,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +1113,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1157,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1181,19 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2019_03_22.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1205,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1231,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1277,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1298,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescription + or ~azure.mgmt.iothub.v2019_03_22.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1324,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1346,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1370,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1405,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1430,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1441,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1478,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1515,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1540,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1560,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1571,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1610,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1643,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1654,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1695,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1738,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,17 +1765,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -977,35 +1800,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1014,17 +1827,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1047,35 +1862,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1083,14 +1888,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1100,8 +1907,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1109,36 +1918,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1151,26 +1957,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1191,34 +1999,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1227,15 +2025,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1245,8 +2045,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1254,36 +2056,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1296,24 +2095,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1323,8 +2123,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1332,36 +2134,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1374,23 +2173,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1408,36 +2208,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1446,16 +2236,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1476,38 +2268,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1516,16 +2298,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1546,38 +2330,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1586,16 +2360,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1605,8 +2382,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_03_22.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1614,36 +2393,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1656,26 +2432,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1696,34 +2474,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1732,17 +2500,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1764,38 +2536,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1804,17 +2566,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1836,38 +2602,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1876,4 +2632,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py index 9d502342d248..1e4a39cc4c0a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2019-03-22" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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_03_22/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py index 9e5df89897da..38666fafa756 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_03_22/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2019-03-22" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-03-22" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + 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 index 8883d8041fab..a9adde0a702d 100644 --- 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 @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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 index 6a35364fe0fd..4d73b23ea30a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2019_07_01_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py index 2c1d9c91c1fb..9cdd0e184440 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_iot_hub_client.py @@ -6,36 +6,32 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from . import models - -class IotHubClient(object): +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 + :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 + :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 @@ -44,56 +40,58 @@ class IotHubClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None 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 index 5cf978bb9225..6ca10e975b29 100644 --- 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 @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", 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 new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" 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 index a84cf700a930..28356865df6a 100644 --- 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 @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +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 index f2211de659ad..03687e3c970b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2019_07_01_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py index e14c3d1d3665..554abd2a2516 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_iot_hub_client.py @@ -6,90 +6,93 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .. import models - - -class IotHubClient(object): +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 + :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 + :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 + :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. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() 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 new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py index ec1a719dae39..4f0c10b2d5fe 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -186,7 +177,8 @@ async def create_or_update( :param certificate_name: The name of the certificate. :type certificate_name: str :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription + :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. :type if_match: str @@ -200,41 +192,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +228,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +263,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +289,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +322,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +349,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +377,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription @@ -419,40 +389,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +421,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # 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 index 00b17cbe6034..057b2134e253 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,45 +58,36 @@ async def _manual_failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, @@ -112,15 +107,18 @@ async def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -132,24 +130,18 @@ async def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -161,4 +153,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # 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 index 4e2aa39c4e7d..ef121d2789ad 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription + or ~azure.mgmt.iothub.v2019_07_01_preview.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -959,35 +922,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -996,8 +949,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1028,35 +984,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1064,13 +1010,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1080,8 +1029,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1089,36 +1040,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1131,17 +1079,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1149,7 +1099,8 @@ async def get_job( 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. 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. @@ -1170,34 +1121,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1206,8 +1147,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1223,8 +1167,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1232,36 +1178,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1274,17 +1217,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1300,8 +1245,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1309,36 +1256,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1351,17 +1295,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1384,36 +1330,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1422,8 +1358,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1451,38 +1390,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1491,8 +1420,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1520,38 +1452,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1560,15 +1482,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1578,8 +1504,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1587,36 +1515,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1629,17 +1554,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1647,7 +1574,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1668,34 +1596,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1704,8 +1622,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1713,7 +1634,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1724,7 +1647,8 @@ async def export_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. - :type export_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest + :type export_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse @@ -1735,38 +1659,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1775,8 +1689,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1784,7 +1701,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1795,7 +1714,8 @@ async def import_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. - :type import_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest + :type import_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse @@ -1806,38 +1726,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1846,4 +1756,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # 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 index 743295d26784..8e1fd34f8682 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py index f85aaa1dec40..083b5a669602 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # 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 index 58f68bc2924e..837cba04f503 100644 --- 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 @@ -6,144 +6,75 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import EnrichmentProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FailoverInput - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubLocationDescription - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubPropertiesDeviceStreams - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import EnrichmentProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FailoverInput # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubLocationDescription # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubPropertiesDeviceStreams # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubPropertiesDeviceStreams +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py index f76bc658dd59..618c9a456b12 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,14 +31,14 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -70,21 +55,21 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specific Role assigned to this location """ PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -92,7 +77,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -104,7 +89,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -112,14 +97,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -130,7 +115,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -145,14 +130,14 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -163,7 +148,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" DIGITAL_TWIN_CHANGE_EVENTS = "DigitalTwinChangeEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -172,7 +157,7 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveE AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models.py deleted file mode 100644 index f55305672417..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models.py +++ /dev/null @@ -1,2413 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type 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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type 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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type 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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param 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. Possible values include: "unknown", "healthy", "unhealthy", - "dead". - :type 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, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type 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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EnrichmentProperties(msrest.serialization.Model): - """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. - :type 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, - **kwargs - ): - super(EnrichmentProperties, self).__init__(**kwargs) - self.key = kwargs['key'] - self.value = kwargs['value'] - self.endpoint_names = kwargs['endpoint_names'] - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FailoverInput(msrest.serialization.Model): - """Use to provide failover region when requesting manual Failover for a hub. - - All required parameters must be populated in order to send to Azure. - - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str - """ - - _validation = { - 'failover_region': {'required': True}, - } - - _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverInput, self).__init__(**kwargs) - self.failover_region = kwargs['failover_region'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". - :type source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type 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, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type 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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubLocationDescription(msrest.serialization.Model): - """Public representation of one of the locations where a resource is provisioned. - - :param location: Azure Geo Regions. - :type location: str - :param role: Specific Role assigned to this location. Possible values include: "primary", - "secondary". - :type 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, - **kwargs - ): - super(IotHubLocationDescription, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.role = kwargs.get('role', None) - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or - ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type 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 - :param 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. - :type event_hub_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_07_01_preview.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_07_01_preview.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2019_07_01_preview.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param device_streams: The device streams properties of iothub. - :type device_streams: - ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubPropertiesDeviceStreams - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type 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, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.device_streams = kwargs.get('device_streams', None) - self.features = kwargs.get('features', None) - self.locations = None - - -class IotHubPropertiesDeviceStreams(msrest.serialization.Model): - """The device streams properties of iothub. - - :param streaming_endpoints: List of Device Streams Endpoints. - :type streaming_endpoints: list[str] - """ - - _attribute_map = { - 'streaming_endpoints': {'key': 'streamingEndpoints', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubPropertiesDeviceStreams, self).__init__(**kwargs) - self.streaming_endpoints = kwargs.get('streaming_endpoints', None) - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type 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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type 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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type 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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type 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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type 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, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type 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, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorPosition - :param end: End where the route error happened. - :type 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, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". - :type source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type 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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2019_07_01_preview.models.FallbackRouteProperties - :param 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. - :type 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, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - self.enrichments = kwargs.get('enrichments', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". - :type 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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type 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, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any - """ - - _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired = kwargs.get('desired', None) - self.reported = kwargs.get('reported', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type 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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type 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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DigitalTwinChangeEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :param twin: Routing Twin Reference. - :type 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, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2019_07_01_preview.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties - :param twin: Routing Twin Reference. - :type 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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.TestResultStatus - :param details: Detailed result of testing route. - :type 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, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: - list[~azure.mgmt.iothub.v2019_07_01_preview.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type 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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type 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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py index 9a354236e9c8..c37f85003c33 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/models/_models_py3.py @@ -18,9 +18,9 @@ class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -42,8 +47,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateProperties + :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. @@ -75,6 +80,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -86,8 +95,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription] """ _attribute_map = { @@ -100,6 +109,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -121,8 +134,8 @@ class CertificateProperties(msrest.serialization.Model): :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. :vartype updated: ~datetime.datetime - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -150,6 +163,10 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -210,6 +227,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -224,9 +243,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -239,6 +258,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -248,9 +272,10 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificatePropertiesWithNonce + :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. @@ -282,6 +307,12 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -293,16 +324,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2019_07_01_preview.models.FeedbackProperties + :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 = { @@ -323,6 +354,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -332,9 +375,9 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: Health statuses have following meanings. The 'healthy' status shows that + :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 @@ -344,7 +387,8 @@ class EndpointHealthData(msrest.serialization.Model): the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthStatus + :vartype health_status: str or + ~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthStatus """ _attribute_map = { @@ -359,6 +403,22 @@ def __init__( health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, **kwargs ): + """ + :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. Possible values include: "unknown", + "healthy", "unhealthy", "dead". + :paramtype health_status: str or + ~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthStatus + """ super(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -369,8 +429,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthData] + :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 """ @@ -390,6 +450,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -400,13 +464,13 @@ class EnrichmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to + :ivar key: Required. The key or name for the enrichment property. + :vartype key: str + :ivar value: Required. The value for the enrichment property. + :vartype value: str + :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to the message. - :type endpoint_names: list[str] + :vartype endpoint_names: list[str] """ _validation = { @@ -429,6 +493,15 @@ def __init__( endpoint_names: List[str], **kwargs ): + """ + :keyword key: Required. The key or name for the enrichment property. + :paramtype key: str + :keyword value: Required. The value for the enrichment property. + :paramtype value: str + :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to + the message. + :paramtype endpoint_names: list[str] + """ super(EnrichmentProperties, self).__init__(**kwargs) self.key = key self.value = value @@ -468,6 +541,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -480,8 +555,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, str] + :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. @@ -513,6 +588,10 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, str] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -526,8 +605,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo] + :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 """ @@ -547,6 +626,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -557,13 +640,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -593,6 +676,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -606,11 +698,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -630,6 +722,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -640,8 +739,8 @@ class FailoverInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str + :ivar failover_region: Required. Region the hub will be failed over to. + :vartype failover_region: str """ _validation = { @@ -658,6 +757,10 @@ def __init__( failover_region: str, **kwargs ): + """ + :keyword failover_region: Required. Region the hub will be failed over to. + :paramtype failover_region: str + """ super(FailoverInput, self).__init__(**kwargs) self.failover_region = failover_region @@ -667,22 +770,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". - :type source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -709,6 +812,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -720,17 +842,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -751,6 +873,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -762,10 +897,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -785,6 +920,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -824,6 +965,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -844,10 +987,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -872,6 +1015,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -893,17 +1042,17 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo """ _validation = { @@ -935,6 +1084,19 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -946,8 +1108,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :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 """ @@ -967,6 +1129,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -975,11 +1141,11 @@ def __init__( class IotHubLocationDescription(msrest.serialization.Model): """Public representation of one of the locations where a resource is provisioned. - :param location: Azure Geo Regions. - :type location: str - :param role: Specific Role assigned to this location. Possible values include: "primary", + :ivar location: Azure Geo Regions. + :vartype location: str + :ivar role: Specific Role assigned to this location. Possible values include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubReplicaRoleType + :vartype role: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubReplicaRoleType """ _attribute_map = { @@ -994,6 +1160,13 @@ def __init__( role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, **kwargs ): + """ + :keyword location: Azure Geo Regions. + :paramtype location: str + :keyword role: Specific Role assigned to this location. Possible values include: "primary", + "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubReplicaRoleType + """ super(IotHubLocationDescription, self).__init__(**kwargs) self.location = location self.role = role @@ -1010,8 +1183,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -1031,6 +1204,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -1042,49 +1219,49 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterRule] + :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 - :param 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. - :type event_hub_endpoints: dict[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] - :param routing: The routing related properties of the IoT hub. See: + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2019_07_01_preview.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2019_07_01_preview.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2019_07_01_preview.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param device_streams: The device streams properties of iothub. - :type device_streams: + :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 - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.Capabilities + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "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] @@ -1131,6 +1308,46 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -1152,8 +1369,8 @@ def __init__( class IotHubPropertiesDeviceStreams(msrest.serialization.Model): """The device streams properties of iothub. - :param streaming_endpoints: List of Device Streams Endpoints. - :type streaming_endpoints: list[str] + :ivar streaming_endpoints: List of Device Streams Endpoints. + :vartype streaming_endpoints: list[str] """ _attribute_map = { @@ -1166,6 +1383,10 @@ def __init__( streaming_endpoints: Optional[List[str]] = None, **kwargs ): + """ + :keyword streaming_endpoints: List of Device Streams Endpoints. + :paramtype streaming_endpoints: list[str] + """ super(IotHubPropertiesDeviceStreams, self).__init__(**kwargs) self.streaming_endpoints = streaming_endpoints @@ -1199,6 +1420,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1210,8 +1433,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfo] + :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 """ @@ -1231,6 +1454,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1245,10 +1472,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubCapacity """ _validation = { @@ -1270,6 +1497,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1281,8 +1514,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescription] + :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 """ @@ -1302,6 +1535,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1314,15 +1551,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1343,6 +1580,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1354,14 +1599,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1384,6 +1629,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1442,6 +1697,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1458,8 +1715,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse] + :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 """ @@ -1479,6 +1736,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1487,8 +1748,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties """ _attribute_map = { @@ -1501,6 +1762,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1508,16 +1773,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1538,6 +1803,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1547,10 +1824,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1565,6 +1842,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1577,8 +1860,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationDisplay """ _validation = { @@ -1596,6 +1879,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2019_07_01_preview.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1634,6 +1921,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1646,8 +1935,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1664,6 +1953,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1693,6 +1986,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1727,6 +2022,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1736,12 +2033,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "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 = { @@ -1758,6 +2055,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "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(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -1767,10 +2072,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -1785,6 +2090,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -1793,10 +2104,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteErrorPosition + :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 = { @@ -1811,6 +2122,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :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(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -1821,23 +2138,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". - :type source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -1865,6 +2181,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -1876,20 +2211,21 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :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. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingStorageContainerProperties] """ @@ -1909,6 +2245,24 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -1921,17 +2275,17 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -1955,6 +2309,19 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1965,12 +2332,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -1987,6 +2354,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -1996,23 +2371,23 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :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. - :type routes: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :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. - :type fallback_route: ~azure.mgmt.iothub.v2019_07_01_preview.models.FallbackRouteProperties - :param enrichments: The list of user-provided enrichments that the IoT hub applies to messages + :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. - :type enrichments: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EnrichmentProperties] + :vartype enrichments: list[~azure.mgmt.iothub.v2019_07_01_preview.models.EnrichmentProperties] """ _attribute_map = { @@ -2031,6 +2406,27 @@ def __init__( enrichments: Optional[List["EnrichmentProperties"]] = None, **kwargs ): + """ + :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(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -2043,18 +2439,18 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -2078,6 +2474,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2090,18 +2500,18 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2125,6 +2535,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2137,33 +2561,33 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the storage account. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :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'. Possible values include: "Avro", "AvroDeflate", "JSON". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingStorageContainerPropertiesEncoding """ @@ -2201,6 +2625,36 @@ def __init__( encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the storage account. + :paramtype connection_string: str + :keyword name: Required. 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. + :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: Required. The name of storage container in the storage account. + :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'. Possible values include: "Avro", + "AvroDeflate", "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingStorageContainerPropertiesEncoding + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2216,10 +2670,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwinProperties """ _attribute_map = { @@ -2234,6 +2688,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2242,10 +2702,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any + :ivar desired: Twin desired properties. + :vartype desired: any + :ivar reported: Twin desired properties. + :vartype reported: any """ _attribute_map = { @@ -2260,6 +2720,12 @@ def __init__( reported: Optional[Any] = None, **kwargs ): + """ + :keyword desired: Twin desired properties. + :paramtype desired: any + :keyword reported: Twin desired properties. + :paramtype reported: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired = desired self.reported = reported @@ -2270,20 +2736,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.AccessRights """ _validation = { @@ -2307,6 +2773,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -2319,8 +2801,8 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: + :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 @@ -2341,6 +2823,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2351,16 +2838,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -2382,6 +2869,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -2391,8 +2890,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2405,6 +2904,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -2412,14 +2915,14 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwin + :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 = { @@ -2436,6 +2939,16 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "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(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -2445,8 +2958,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2019_07_01_preview.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2019_07_01_preview.models.MatchedRoute] """ _attribute_map = { @@ -2459,6 +2972,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2019_07_01_preview.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -2468,12 +2985,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2019_07_01_preview.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage + :ivar route: Required. Route properties. + :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 = { @@ -2494,6 +3011,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2019_07_01_preview.models.RoutingMessage + :keyword route: Required. Route properties. + :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(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -2503,10 +3028,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2019_07_01_preview.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2019_07_01_preview.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "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 = { @@ -2521,6 +3046,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "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(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -2529,8 +3061,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2019_07_01_preview.models.RouteCompilationError] """ @@ -2544,6 +3076,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2019_07_01_preview.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -2551,18 +3088,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2019_07_01_preview.models.Name + :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 = { @@ -2585,6 +3122,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -2599,8 +3150,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -2620,6 +3171,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2019_07_01_preview.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py index 37d3949f3537..b82824c8f721 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -193,7 +429,8 @@ def create_or_update( :param certificate_name: The name of the certificate. :type certificate_name: str :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateBodyDescription + :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. :type if_match: str @@ -207,41 +444,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +480,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +515,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +541,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +574,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +601,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +629,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.CertificateDescription @@ -429,40 +641,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +673,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # 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 index 667b2645228a..79e771d2eeed 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_operations.py @@ -5,24 +5,71 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_manual_failover_request_initial( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubOperations(object): """IotHubOperations operations. @@ -48,64 +95,53 @@ def __init__(self, client, config, serializer, deserializer): def _manual_failover_initial( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> None + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace def begin_manual_failover( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> LROPoller[None]: """Manual Failover Fail over. Perform manual fail over of given hub. @@ -118,15 +154,18 @@ def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2019_07_01_preview.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -138,24 +177,18 @@ def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -167,4 +200,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # 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 index e556b24941aa..c5727624509f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_iot_hub_resource_operations.py @@ -5,25 +5,907 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +929,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +954,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +979,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1030,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +1062,20 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +1088,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +1114,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1158,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1182,20 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2019_07_01_preview.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1207,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1233,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1279,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1300,20 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescription + or ~azure.mgmt.iothub.v2019_07_01_preview.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1327,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1349,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1373,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1408,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1433,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1444,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1481,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1518,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1543,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1563,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1574,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1613,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1646,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1657,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1698,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1741,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,17 +1768,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -977,35 +1803,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1014,17 +1830,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1047,35 +1865,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1083,14 +1891,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1100,8 +1910,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1109,36 +1921,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1151,26 +1960,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1191,34 +2002,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1227,15 +2028,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1245,8 +2048,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1254,36 +2059,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1296,24 +2098,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1323,8 +2126,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1332,36 +2137,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1374,23 +2176,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1408,36 +2211,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1446,16 +2239,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1476,38 +2271,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1516,16 +2301,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1546,38 +2333,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1586,16 +2363,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1605,8 +2385,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1614,36 +2396,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1656,26 +2435,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1696,34 +2477,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1732,17 +2503,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1753,7 +2528,8 @@ def export_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. - :type export_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest + :type export_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ExportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse @@ -1764,38 +2540,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1804,17 +2570,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1825,7 +2595,8 @@ def import_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. - :type import_devices_parameters: ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest + :type import_devices_parameters: + ~azure.mgmt.iothub.v2019_07_01_preview.models.ImportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_07_01_preview.models.JobResponse @@ -1836,38 +2607,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1876,4 +2637,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # 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 index e04f0241ccec..56922073a5b9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2019-07-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_07_01_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py index 5a7eb697e6da..858af7aef515 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_07_01_preview/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2019-07-01-preview" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-07-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py index 74adeddc9e68..db44b6c2402a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2019_11_04/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py index 277fbb5ae9ee..badc2a2e1a2a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_iot_hub_client.py @@ -6,28 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -35,7 +29,8 @@ class IotHubClient(object): :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2019_11_04.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2019_11_04.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2019_11_04.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2019_11_04.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations @@ -44,56 +39,58 @@ class IotHubClient(object): :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json index 538a9c833663..82012676da9a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py index 3e86bf418b8e..e98f39e76d91 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2019_11_04/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py index 7c30c0557b47..49300465af52 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_iot_hub_client.py @@ -6,34 +6,32 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2019_11_04.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2019_11_04.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2019_11_04.aio.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2019_11_04.aio.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2019_11_04.aio.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2019_11_04.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations @@ -42,54 +40,58 @@ class IotHubClient(object): :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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.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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py index 8a941f871504..9a317c7b66c5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py index aab3a24ea223..28b9b1639fb5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,45 +58,36 @@ async def _manual_failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, @@ -115,15 +110,18 @@ async def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -135,24 +133,18 @@ async def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -164,4 +156,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py index a60aa6c1a20a..868faa55009c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2019_11_04.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription or + ~azure.mgmt.iothub.v2019_11_04.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -959,35 +922,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -996,8 +949,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1028,35 +984,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1064,13 +1010,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1080,8 +1029,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1089,36 +1040,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1131,17 +1079,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1149,7 +1099,8 @@ async def get_job( 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. 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. @@ -1170,34 +1121,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1206,8 +1147,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1223,8 +1167,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1232,36 +1178,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1274,17 +1217,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1300,8 +1245,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1309,36 +1256,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1351,17 +1295,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1384,36 +1330,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1422,8 +1358,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1451,38 +1390,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1491,8 +1420,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1520,38 +1452,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1560,15 +1482,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1578,8 +1504,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1587,36 +1515,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1629,17 +1554,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1647,7 +1574,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1668,34 +1596,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1704,8 +1622,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1713,7 +1634,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1735,38 +1658,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1775,8 +1688,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1784,7 +1700,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1806,38 +1724,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1846,4 +1754,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py index 606437d237f0..37fce809b96d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2019_11_04.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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_11_04/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py index 225317d7ee58..47037cc33390 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py index 8b0ef578493a..e49548abc8de 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/__init__.py @@ -6,142 +6,74 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import EnrichmentProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FailoverInput - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubLocationDescription - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import EnrichmentProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FailoverInput # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubLocationDescription # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py index 000a2df33e9b..19ff62f5aabe 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,14 +31,14 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -70,14 +55,14 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -86,7 +71,7 @@ class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -94,7 +79,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -106,7 +91,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -114,14 +99,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -132,7 +117,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -147,14 +132,14 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -164,7 +149,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -173,7 +158,7 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveE AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models.py deleted file mode 100644 index af609c11b7ff..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models.py +++ /dev/null @@ -1,2385 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param 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. Possible values include: "unknown", "healthy", "unhealthy", - "dead". - :type health_status: str or ~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthStatus - """ - - _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EnrichmentProperties(msrest.serialization.Model): - """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. - :type 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, - **kwargs - ): - super(EnrichmentProperties, self).__init__(**kwargs) - self.key = kwargs['key'] - self.value = kwargs['value'] - self.endpoint_names = kwargs['endpoint_names'] - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - - -class FailoverInput(msrest.serialization.Model): - """Use to provide failover region when requesting manual Failover for a hub. - - All required parameters must be populated in order to send to Azure. - - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str - """ - - _validation = { - 'failover_region': {'required': True}, - } - - _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverInput, self).__init__(**kwargs) - self.failover_region = kwargs['failover_region'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2019_11_04.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubLocationDescription(msrest.serialization.Model): - """Public representation of one of the locations where a resource is provisioned. - - :param location: The name of the Azure region. - :type location: str - :param 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. Possible values - include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubReplicaRoleType - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubLocationDescription, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.role = kwargs.get('role', None) - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2019_11_04.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 - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2019_11_04.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2019_11_04.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_11_04.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2019_11_04.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2019_11_04.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2019_11_04.models.Capabilities - :ivar locations: Primary and secondary location for iot hub. - :vartype locations: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.features = kwargs.get('features', None) - self.locations = None - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2019_11_04.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2019_11_04.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2019_11_04.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2019_11_04.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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_11_04.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorRange - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition - """ - - _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2019_11_04.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2019_11_04.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2019_11_04.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2019_11_04.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2019_11_04.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2019_11_04.models.FallbackRouteProperties - :param 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. - :type enrichments: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - self.enrichments = kwargs.get('enrichments', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". - :type encoding: str or - ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.connection_string = kwargs['connection_string'] - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwinProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any - """ - - _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired = kwargs.get('desired', None) - self.reported = kwargs.get('reported', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type 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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin - """ - - _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2019_11_04.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2019_11_04.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResultDetails - """ - - _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2019_11_04.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type value: list[~azure.mgmt.iothub.v2019_11_04.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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py index 9dee07a997a6..b243979335c6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/models/_models_py3.py @@ -18,9 +18,9 @@ class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -42,8 +47,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2019_11_04.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -75,6 +80,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -86,8 +95,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription] """ _attribute_map = { @@ -100,6 +109,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -121,8 +134,8 @@ class CertificateProperties(msrest.serialization.Model): :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. :vartype updated: ~datetime.datetime - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -150,6 +163,10 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -210,6 +227,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -224,9 +243,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -239,6 +258,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -248,9 +272,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.CertificatePropertiesWithNonce + :vartype properties: ~azure.mgmt.iothub.v2019_11_04.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -282,6 +306,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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_11_04.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -293,16 +322,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2019_11_04.models.FeedbackProperties + :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_11_04.models.FeedbackProperties """ _validation = { @@ -323,6 +352,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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_11_04.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -332,9 +373,9 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: Health statuses have following meanings. The 'healthy' status shows that + :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 @@ -344,7 +385,7 @@ class EndpointHealthData(msrest.serialization.Model): the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthStatus + :vartype health_status: str or ~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthStatus """ _attribute_map = { @@ -359,6 +400,21 @@ def __init__( health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, **kwargs ): + """ + :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. Possible values include: "unknown", + "healthy", "unhealthy", "dead". + :paramtype health_status: str or ~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthStatus + """ super(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -369,8 +425,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthData] + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthData] :ivar next_link: Link to more results. :vartype next_link: str """ @@ -390,6 +446,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -400,13 +460,13 @@ class EnrichmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to + :ivar key: Required. The key or name for the enrichment property. + :vartype key: str + :ivar value: Required. The value for the enrichment property. + :vartype value: str + :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to the message. - :type endpoint_names: list[str] + :vartype endpoint_names: list[str] """ _validation = { @@ -429,6 +489,15 @@ def __init__( endpoint_names: List[str], **kwargs ): + """ + :keyword key: Required. The key or name for the enrichment property. + :paramtype key: str + :keyword value: Required. The value for the enrichment property. + :paramtype value: str + :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to + the message. + :paramtype endpoint_names: list[str] + """ super(EnrichmentProperties, self).__init__(**kwargs) self.key = key self.value = value @@ -468,6 +537,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -480,8 +551,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, str] + :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. @@ -513,6 +584,10 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, str] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -526,8 +601,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo] + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -547,6 +622,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -557,13 +636,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -593,6 +672,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -606,11 +694,11 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool + :vartype exclude_keys: bool """ _validation = { @@ -630,6 +718,13 @@ def __init__( exclude_keys: bool, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :paramtype exclude_keys: bool + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -640,8 +735,8 @@ class FailoverInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str + :ivar failover_region: Required. Region the hub will be failed over to. + :vartype failover_region: str """ _validation = { @@ -658,6 +753,10 @@ def __init__( failover_region: str, **kwargs ): + """ + :keyword failover_region: Required. Region the hub will be failed over to. + :paramtype failover_region: str + """ super(FailoverInput, self).__init__(**kwargs) self.failover_region = failover_region @@ -667,22 +766,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2019_11_04.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -709,6 +808,24 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2019_11_04.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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -720,17 +837,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -751,6 +868,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -762,10 +892,10 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str """ _validation = { @@ -785,6 +915,12 @@ def __init__( output_blob_container_uri: str, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :paramtype output_blob_container_uri: str + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -824,6 +960,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -844,10 +982,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -872,6 +1010,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -893,17 +1037,17 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2019_11_04.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo """ _validation = { @@ -935,6 +1079,19 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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_11_04.models.IotHubProperties + :keyword sku: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -946,8 +1103,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -967,6 +1124,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -975,13 +1136,13 @@ def __init__( class IotHubLocationDescription(msrest.serialization.Model): """Public representation of one of the locations where a resource is provisioned. - :param location: The name of the Azure region. - :type location: str - :param role: The role of the region, can be either primary or secondary. The primary region is + :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. Possible values include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubReplicaRoleType + :vartype role: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubReplicaRoleType """ _attribute_map = { @@ -996,6 +1157,15 @@ def __init__( role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, **kwargs ): + """ + :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. Possible + values include: "primary", "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubReplicaRoleType + """ super(IotHubLocationDescription, self).__init__(**kwargs) self.location = location self.role = role @@ -1011,8 +1181,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -1032,6 +1202,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -1043,45 +1217,46 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2019_11_04.models.IpFilterRule] + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2019_11_04.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 - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2019_11_04.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :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_11_04.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2019_11_04.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2019_11_04.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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2019_11_04.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2019_11_04.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2019_11_04.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2019_11_04.models.Capabilities + :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_11_04.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2019_11_04.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubLocationDescription] """ @@ -1125,6 +1300,42 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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_11_04.models.SharedAccessSignatureAuthorizationRule] + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2019_11_04.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_11_04.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_11_04.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_11_04.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2019_11_04.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_11_04.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2019_11_04.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.ip_filter_rules = ip_filter_rules @@ -1171,6 +1382,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1182,8 +1395,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1203,6 +1416,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1217,10 +1434,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2019_11_04.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2019_11_04.models.IotHubCapacity """ _validation = { @@ -1242,6 +1459,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2019_11_04.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1253,8 +1476,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1274,6 +1497,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1286,15 +1513,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1315,6 +1542,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2019_11_04.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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1326,14 +1561,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2019_11_04.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2019_11_04.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1356,6 +1591,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2019_11_04.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1414,6 +1659,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1430,8 +1677,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1451,6 +1698,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1459,8 +1710,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties """ _attribute_map = { @@ -1473,6 +1724,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1480,16 +1735,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1510,6 +1765,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1519,10 +1786,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1537,6 +1804,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1549,8 +1822,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2019_11_04.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2019_11_04.models.OperationDisplay """ _validation = { @@ -1568,6 +1841,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2019_11_04.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1606,6 +1883,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1618,8 +1897,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1636,6 +1915,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1665,6 +1948,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1699,6 +1984,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1708,12 +1995,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorRange """ _attribute_map = { @@ -1730,6 +2017,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorRange + """ super(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -1739,10 +2034,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -1757,6 +2052,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -1765,10 +2066,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition """ _attribute_map = { @@ -1783,6 +2084,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2019_11_04.models.RouteErrorPosition + """ super(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -1793,23 +2100,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2019_11_04.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -1837,6 +2143,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2019_11_04.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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -1848,20 +2173,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2019_11_04.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2019_11_04.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2019_11_04.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: list[~azure.mgmt.iothub.v2019_11_04.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2019_11_04.models.RoutingStorageContainerProperties] """ @@ -1881,6 +2206,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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_11_04.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_11_04.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_11_04.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_11_04.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -1893,17 +2235,17 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the event hub endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the event hub endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -1927,6 +2269,19 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the event hub endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -1937,12 +2292,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -1959,6 +2314,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -1968,23 +2331,23 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2019_11_04.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2019_11_04.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. - :type routes: list[~azure.mgmt.iothub.v2019_11_04.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2019_11_04.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. - :type fallback_route: ~azure.mgmt.iothub.v2019_11_04.models.FallbackRouteProperties - :param enrichments: The list of user-provided enrichments that the IoT hub applies to messages + :vartype fallback_route: ~azure.mgmt.iothub.v2019_11_04.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. - :type enrichments: list[~azure.mgmt.iothub.v2019_11_04.models.EnrichmentProperties] + :vartype enrichments: list[~azure.mgmt.iothub.v2019_11_04.models.EnrichmentProperties] """ _attribute_map = { @@ -2003,6 +2366,26 @@ def __init__( enrichments: Optional[List["EnrichmentProperties"]] = None, **kwargs ): + """ + :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_11_04.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_11_04.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_11_04.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.v2019_11_04.models.EnrichmentProperties] + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -2015,18 +2398,18 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus queue endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus queue endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -2050,6 +2433,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus queue endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2062,18 +2459,18 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the service bus topic endpoint. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the service bus topic endpoint. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2097,6 +2494,20 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the service bus topic endpoint. + :paramtype connection_string: str + :keyword name: Required. 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. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2109,33 +2520,33 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param connection_string: Required. The connection string of the storage account. - :type connection_string: str - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar connection_string: Required. The connection string of the storage account. + :vartype connection_string: str + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :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'. Possible values include: "Avro", "AvroDeflate", "JSON". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingStorageContainerPropertiesEncoding """ @@ -2173,6 +2584,36 @@ def __init__( encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): + """ + :keyword connection_string: Required. The connection string of the storage account. + :paramtype connection_string: str + :keyword name: Required. 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. + :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: Required. The name of storage container in the storage account. + :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'. Possible values include: "Avro", + "AvroDeflate", "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2019_11_04.models.RoutingStorageContainerPropertiesEncoding + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.connection_string = connection_string self.name = name @@ -2188,10 +2629,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwinProperties """ _attribute_map = { @@ -2206,6 +2647,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2214,10 +2661,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any + :ivar desired: Twin desired properties. + :vartype desired: any + :ivar reported: Twin desired properties. + :vartype reported: any """ _attribute_map = { @@ -2232,6 +2679,12 @@ def __init__( reported: Optional[Any] = None, **kwargs ): + """ + :keyword desired: Twin desired properties. + :paramtype desired: any + :keyword reported: Twin desired properties. + :paramtype reported: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired = desired self.reported = reported @@ -2242,20 +2695,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2019_11_04.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2019_11_04.models.AccessRights """ _validation = { @@ -2279,6 +2732,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2019_11_04.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -2291,8 +2760,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -2312,6 +2782,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2322,16 +2797,16 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str + :vartype container_name: str """ _validation = { @@ -2353,6 +2828,18 @@ def __init__( sas_ttl_as_iso8601: Optional[datetime.timedelta] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -2362,8 +2849,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2376,6 +2863,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -2383,13 +2874,13 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin + :vartype routing_source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin """ _attribute_map = { @@ -2406,6 +2897,15 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2019_11_04.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin + """ super(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -2415,8 +2915,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2019_11_04.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2019_11_04.models.MatchedRoute] """ _attribute_map = { @@ -2429,6 +2929,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2019_11_04.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -2438,12 +2942,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage + :ivar route: Required. Route properties. + :vartype route: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin """ _validation = { @@ -2464,6 +2968,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2019_11_04.models.RoutingMessage + :keyword route: Required. Route properties. + :paramtype route: ~azure.mgmt.iothub.v2019_11_04.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2019_11_04.models.RoutingTwin + """ super(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -2473,10 +2985,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2019_11_04.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :vartype result: str or ~azure.mgmt.iothub.v2019_11_04.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResultDetails """ _attribute_map = { @@ -2491,6 +3003,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "true". + :paramtype result: str or ~azure.mgmt.iothub.v2019_11_04.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2019_11_04.models.TestRouteResultDetails + """ super(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -2499,8 +3018,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2019_11_04.models.RouteCompilationError] + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2019_11_04.models.RouteCompilationError] """ _attribute_map = { @@ -2513,6 +3032,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2019_11_04.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -2520,18 +3044,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2019_11_04.models.Name + :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_11_04.models.Name """ _attribute_map = { @@ -2554,6 +3078,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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_11_04.models.Name + """ super(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -2568,8 +3106,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2019_11_04.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2019_11_04.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -2589,6 +3127,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2019_11_04.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py index eab4242d29dd..2871159c0bb3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2019_11_04.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2019_11_04.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py index b140ad5eba5a..61395d0c12e6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_operations.py @@ -5,24 +5,71 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_manual_failover_request_initial( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubOperations(object): """IotHubOperations operations. @@ -48,64 +95,53 @@ def __init__(self, client, config, serializer, deserializer): def _manual_failover_initial( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> None + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace def begin_manual_failover( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **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 @@ -121,15 +157,18 @@ def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2019_11_04.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -141,24 +180,18 @@ def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -170,4 +203,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py index f5556c8f14d2..8891bb2c035c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_iot_hub_resource_operations.py @@ -5,25 +5,907 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +929,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +954,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +979,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1030,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +1062,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +1087,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +1113,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1157,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1181,19 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2019_11_04.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1205,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1231,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1277,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1298,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescription + or ~azure.mgmt.iothub.v2019_11_04.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1324,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1346,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1370,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1405,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1430,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1441,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1478,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1515,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1540,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1560,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1571,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1610,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1643,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1654,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1695,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1738,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,17 +1765,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -977,35 +1800,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1014,17 +1827,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1047,35 +1862,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1083,14 +1888,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1100,8 +1907,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1109,36 +1918,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1151,26 +1957,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1191,34 +1999,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1227,15 +2025,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1245,8 +2045,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1254,36 +2056,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1296,24 +2095,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1323,8 +2123,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1332,36 +2134,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1374,23 +2173,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1408,36 +2208,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1446,16 +2236,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1476,38 +2268,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1516,16 +2298,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1546,38 +2330,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1586,16 +2360,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1605,8 +2382,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2019_11_04.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1614,36 +2393,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1656,26 +2432,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1696,34 +2474,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1732,17 +2500,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1764,38 +2536,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1804,17 +2566,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1836,38 +2602,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1876,4 +2632,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py index 4c3e7b8e5e61..c2d3f2296a2a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2019-11-04" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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_11_04/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py index bc1af5678f51..3492dcfa293d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2019_11_04/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2019-11-04" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py index c9b00d796e7e..ef82a2d7b619 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2020_03_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py index 9e90abda68f1..729a6be2075b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_iot_hub_client.py @@ -6,30 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -37,73 +29,76 @@ class IotHubClient(object): :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2020_03_01.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2020_03_01.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2020_03_01.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2020_03_01.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2020_03_01.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2020_03_01.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2020_03_01.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2020_03_01.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2020_03_01.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) - 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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json index 2f9d36ad7464..7263b5339a8a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py index ee32bef16a66..7a90522e2bd9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2020_03_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py index a39b4f027ee4..e7d55bb480c2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_iot_hub_client.py @@ -6,100 +6,100 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +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 -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2020_03_01.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2020_03_01.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2020_03_01.aio.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2020_03_01.aio.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2020_03_01.aio.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2020_03_01.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2020_03_01.aio.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2020_03_01.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2020_03_01.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2020_03_01.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2020_03_01.aio.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) + - 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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py index 4dbb41d6941c..d486ba04638a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py index bf818219456b..24c42a56e959 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,45 +58,36 @@ async def _manual_failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, @@ -115,15 +110,18 @@ async def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -135,24 +133,18 @@ async def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -164,4 +156,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py index 6eba81156669..ae18200a4a3e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2020_03_01.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription or + ~azure.mgmt.iothub.v2020_03_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -959,35 +922,25 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -996,8 +949,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1028,35 +984,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1064,13 +1010,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1080,8 +1029,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1089,36 +1040,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1131,17 +1079,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1149,7 +1099,8 @@ async def get_job( 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. 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. @@ -1170,34 +1121,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1206,8 +1147,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1223,8 +1167,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1232,36 +1178,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1274,17 +1217,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1300,8 +1245,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1309,36 +1256,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1351,17 +1295,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1384,36 +1330,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1422,8 +1358,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1451,38 +1390,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1491,8 +1420,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1520,38 +1452,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1560,15 +1482,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1578,8 +1504,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1587,36 +1515,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1629,17 +1554,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1647,7 +1574,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1668,34 +1596,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1704,8 +1622,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1713,7 +1634,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1735,38 +1658,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1775,8 +1688,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1784,7 +1700,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1806,38 +1724,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1846,4 +1754,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py index 3803c9762b4d..7e6d9a095008 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2020_03_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py index ebc1580cad7a..6301e9371f09 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_endpoint_connections_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -66,33 +71,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -101,8 +96,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -130,34 +128,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -166,8 +154,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, @@ -181,40 +171,29 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -226,8 +205,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -247,18 +229,24 @@ async def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -271,28 +259,21 @@ async def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -304,6 +285,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -318,35 +300,24 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -359,8 +330,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -380,15 +354,19 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -403,25 +381,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -433,4 +403,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py index 7749488f0d1b..87ecc58767bc 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_private_link_resources_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -99,8 +94,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -164,4 +152,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py index 748bdf90123e..b98fdb828dd9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py index 9577cb305ff9..154f2039f5a6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/__init__.py @@ -6,156 +6,81 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import EnrichmentProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FailoverInput - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import GroupIdInformation - from ._models_py3 import GroupIdInformationProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubLocationDescription - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionProperties - from ._models_py3 import PrivateLinkResources - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import EnrichmentProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FailoverInput # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import GroupIdInformation # type: ignore - from ._models import GroupIdInformationProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubLocationDescription # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionProperties # type: ignore - from ._models import PrivateLinkResources # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResources +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py index cbe99eb5827b..44f1adadad66 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,21 +31,21 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies authentication type being used for connecting to the storage account. """ KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -77,14 +62,14 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -93,7 +78,7 @@ class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -101,7 +86,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -113,7 +98,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -121,14 +106,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -139,7 +124,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -154,7 +139,7 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of a private endpoint connection """ @@ -163,21 +148,21 @@ class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether requests from Public Network are allowed """ ENABLED = "Enabled" DISABLED = "Disabled" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -187,7 +172,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEVICE_LIFECYCLE_EVENTS = "DeviceLifecycleEvents" DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -196,7 +181,7 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveE AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models.py deleted file mode 100644 index 5d9f13920872..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models.py +++ /dev/null @@ -1,2713 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param 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. Possible values include: "unknown", "healthy", "unhealthy", - "dead". - :type health_status: str or ~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthStatus - """ - - _attribute_map = { - 'endpoint_id': {'key': 'endpointId', 'type': 'str'}, - 'health_status': {'key': 'healthStatus', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EnrichmentProperties(msrest.serialization.Model): - """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. - :type 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, - **kwargs - ): - super(EnrichmentProperties, self).__init__(**kwargs) - self.key = kwargs['key'] - self.value = kwargs['value'] - self.endpoint_names = kwargs['endpoint_names'] - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type exclude_keys: bool - :param 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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - self.export_blob_name = kwargs.get('export_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - - -class FailoverInput(msrest.serialization.Model): - """Use to provide failover region when requesting manual Failover for a hub. - - All required parameters must be populated in order to send to Azure. - - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str - """ - - _validation = { - 'failover_region': {'required': True}, - } - - _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverInput, self).__init__(**kwargs) - self.failover_region = kwargs['failover_region'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class GroupIdInformation(msrest.serialization.Model): - """The group information for creating a private endpoint on an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(GroupIdInformation, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class GroupIdInformationProperties(msrest.serialization.Model): - """The properties for a group information object. - - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type 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, - **kwargs - ): - super(GroupIdInformationProperties, self).__init__(**kwargs) - self.group_id = kwargs.get('group_id', None) - self.required_members = kwargs.get('required_members', None) - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob - container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - self.input_blob_name = kwargs.get('input_blob_name', None) - self.output_blob_name = kwargs.get('output_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2020_03_01.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubLocationDescription(msrest.serialization.Model): - """Public representation of one of the locations where a resource is provisioned. - - :param location: The name of the Azure region. - :type location: str - :param 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. Possible values - include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubReplicaRoleType - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubLocationDescription, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.role = kwargs.get('role', None) - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] - :param public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.iothub.v2020_03_01.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2020_03_01.models.IpFilterRule] - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: - list[~azure.mgmt.iothub.v2020_03_01.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 - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2020_03_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2020_03_01.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2020_03_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2020_03_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2020_03_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2020_03_01.models.Capabilities - :ivar locations: Primary and secondary location for iot hub. - :vartype locations: list[~azure.mgmt.iothub.v2020_03_01.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]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - '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]'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.public_network_access = kwargs.get('public_network_access', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.min_tls_version = kwargs.get('min_tls_version', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.features = kwargs.get('features', None) - self.locations = None - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2020_03_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2020_03_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2020_03_01.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2020_03_01.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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.v2020_03_01.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpoint(msrest.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 - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(msrest.serialization.Model): - """The private endpoint connection of an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class PrivateEndpointConnectionProperties(msrest.serialization.Model): - """The properties of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint - connection. - :type private_link_service_connection_state: - ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs['private_link_service_connection_state'] - - -class PrivateLinkResources(msrest.serialization.Model): - """The available private link resources for an IotHub. - - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResources, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint - connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type 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, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs['description'] - self.actions_required = kwargs.get('actions_required', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorRange - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition - """ - - _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2020_03_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2020_03_01.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2020_03_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2020_03_01.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2020_03_01.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2020_03_01.models.FallbackRouteProperties - :param 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. - :type enrichments: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - self.enrichments = kwargs.get('enrichments', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". - :type encoding: str or - ~azure.mgmt.iothub.v2020_03_01.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'}, - '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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwinProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any - """ - - _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired = kwargs.get('desired', None) - self.reported = kwargs.get('reported', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - self.authentication_type = kwargs.get('authentication_type', None) - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin - """ - - _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2020_03_01.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2020_03_01.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResultDetails - """ - - _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2020_03_01.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type value: list[~azure.mgmt.iothub.v2020_03_01.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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py index 0d47050e4f9a..f8e30068d236 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/models/_models_py3.py @@ -18,9 +18,9 @@ class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -33,6 +33,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -42,8 +47,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -75,6 +80,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -86,8 +95,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription] """ _attribute_map = { @@ -100,6 +109,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -121,8 +134,8 @@ class CertificateProperties(msrest.serialization.Model): :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. :vartype updated: ~datetime.datetime - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -150,6 +163,10 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -210,6 +227,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -224,9 +243,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -239,6 +258,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -248,9 +272,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.CertificatePropertiesWithNonce + :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -282,6 +306,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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.v2020_03_01.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -293,16 +322,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2020_03_01.models.FeedbackProperties + :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.v2020_03_01.models.FeedbackProperties """ _validation = { @@ -323,6 +352,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2020_03_01.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -332,9 +373,9 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: Health statuses have following meanings. The 'healthy' status shows that + :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 @@ -344,7 +385,7 @@ class EndpointHealthData(msrest.serialization.Model): the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or rejected from this endpoint. Possible values include: "unknown", "healthy", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthStatus + :vartype health_status: str or ~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthStatus """ _attribute_map = { @@ -359,6 +400,21 @@ def __init__( health_status: Optional[Union[str, "EndpointHealthStatus"]] = None, **kwargs ): + """ + :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. Possible values include: "unknown", + "healthy", "unhealthy", "dead". + :paramtype health_status: str or ~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthStatus + """ super(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -369,8 +425,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthData] + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthData] :ivar next_link: Link to more results. :vartype next_link: str """ @@ -390,6 +446,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -400,13 +460,13 @@ class EnrichmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to + :ivar key: Required. The key or name for the enrichment property. + :vartype key: str + :ivar value: Required. The value for the enrichment property. + :vartype value: str + :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to the message. - :type endpoint_names: list[str] + :vartype endpoint_names: list[str] """ _validation = { @@ -429,6 +489,15 @@ def __init__( endpoint_names: List[str], **kwargs ): + """ + :keyword key: Required. The key or name for the enrichment property. + :paramtype key: str + :keyword value: Required. The value for the enrichment property. + :paramtype value: str + :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to + the message. + :paramtype endpoint_names: list[str] + """ super(EnrichmentProperties, self).__init__(**kwargs) self.key = key self.value = value @@ -468,6 +537,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -480,8 +551,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, str] + :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. @@ -513,6 +584,10 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, str] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -526,8 +601,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo] + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -547,6 +622,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -557,13 +636,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -593,6 +672,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -606,17 +694,17 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool - :param export_blob_name: The name of the blob that will be created in the provided output blob + :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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype export_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ _validation = { @@ -640,6 +728,20 @@ def __init__( authentication_type: Optional[Union[str, "AuthenticationType"]] = None, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -652,8 +754,8 @@ class FailoverInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str + :ivar failover_region: Required. Region the hub will be failed over to. + :vartype failover_region: str """ _validation = { @@ -670,6 +772,10 @@ def __init__( failover_region: str, **kwargs ): + """ + :keyword failover_region: Required. Region the hub will be failed over to. + :paramtype failover_region: str + """ super(FailoverInput, self).__init__(**kwargs) self.failover_region = failover_region @@ -679,22 +785,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2020_03_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -721,6 +827,24 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2020_03_01.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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -732,17 +856,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -763,6 +887,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -782,8 +919,8 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformationProperties + :ivar properties: Required. The properties for a group information object. + :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformationProperties """ _validation = { @@ -806,6 +943,10 @@ def __init__( properties: "GroupIdInformationProperties", **kwargs ): + """ + :keyword properties: Required. The properties for a group information object. + :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformationProperties + """ super(GroupIdInformation, self).__init__(**kwargs) self.id = None self.name = None @@ -816,12 +957,12 @@ def __init__( class GroupIdInformationProperties(msrest.serialization.Model): """The properties for a group information object. - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type required_zone_names: list[str] + :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 = { @@ -838,6 +979,14 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :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(GroupIdInformationProperties, self).__init__(**kwargs) self.group_id = group_id self.required_members = required_members @@ -849,18 +998,18 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str + :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ _validation = { @@ -886,6 +1035,20 @@ def __init__( authentication_type: Optional[Union[str, "AuthenticationType"]] = None, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -928,6 +1091,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -948,10 +1113,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -976,6 +1141,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -997,17 +1168,17 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo """ _validation = { @@ -1039,6 +1210,19 @@ def __init__( properties: Optional["IotHubProperties"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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.v2020_03_01.models.IotHubProperties + :keyword sku: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -1050,8 +1234,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1071,6 +1255,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1079,13 +1267,13 @@ def __init__( class IotHubLocationDescription(msrest.serialization.Model): """Public representation of one of the locations where a resource is provisioned. - :param location: The name of the Azure region. - :type location: str - :param role: The role of the region, can be either primary or secondary. The primary region is + :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. Possible values include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubReplicaRoleType + :vartype role: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubReplicaRoleType """ _attribute_map = { @@ -1100,6 +1288,15 @@ def __init__( role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, **kwargs ): + """ + :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. Possible + values include: "primary", "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubReplicaRoleType + """ super(IotHubLocationDescription, self).__init__(**kwargs) self.location = location self.role = role @@ -1115,8 +1312,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -1136,6 +1333,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -1147,20 +1348,21 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :ivar public_network_access: Whether requests from Public Network are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.iothub.v2020_03_01.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2020_03_01.models.IpFilterRule] - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: + :vartype public_network_access: str or + ~azure.mgmt.iothub.v2020_03_01.models.PublicNetworkAccess + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2020_03_01.models.IpFilterRule] + :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.v2020_03_01.models.PrivateEndpointConnection] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1168,33 +1370,34 @@ class IotHubProperties(msrest.serialization.Model): :vartype state: str :ivar host_name: The name of the host. :vartype host_name: str - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2020_03_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :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.v2020_03_01.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2020_03_01.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2020_03_01.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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2020_03_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2020_03_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2020_03_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2020_03_01.models.Capabilities + :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.v2020_03_01.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2020_03_01.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubLocationDescription] """ @@ -1244,6 +1447,52 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] + :keyword public_network_access: Whether requests from Public Network are allowed. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothub.v2020_03_01.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2020_03_01.models.IpFilterRule] + :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.v2020_03_01.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.v2020_03_01.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.v2020_03_01.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.v2020_03_01.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2020_03_01.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.v2020_03_01.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2020_03_01.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.public_network_access = public_network_access @@ -1293,6 +1542,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1304,8 +1555,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1325,6 +1576,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1339,10 +1594,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2020_03_01.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2020_03_01.models.IotHubCapacity """ _validation = { @@ -1364,6 +1619,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2020_03_01.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1375,8 +1636,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1396,6 +1657,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1408,15 +1673,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1437,6 +1702,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2020_03_01.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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1448,14 +1721,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2020_03_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2020_03_01.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1478,6 +1751,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2020_03_01.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1536,6 +1819,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1552,8 +1837,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1573,6 +1858,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1581,8 +1870,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties """ _attribute_map = { @@ -1595,6 +1884,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1602,16 +1895,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1632,6 +1925,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1641,10 +1946,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1659,6 +1964,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1671,8 +1982,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2020_03_01.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2020_03_01.models.OperationDisplay """ _validation = { @@ -1690,6 +2001,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2020_03_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -1728,6 +2043,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -1740,8 +2057,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -1758,6 +2075,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -1787,6 +2108,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -1813,6 +2136,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = None @@ -1830,8 +2155,8 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnectionProperties + :ivar properties: Required. The properties of a private endpoint connection. + :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnectionProperties """ _validation = { @@ -1854,6 +2179,11 @@ def __init__( properties: "PrivateEndpointConnectionProperties", **kwargs ): + """ + :keyword properties: Required. The properties of a private endpoint connection. + :paramtype properties: + ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnectionProperties + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.id = None self.name = None @@ -1866,11 +2196,11 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint + :ivar private_endpoint: The private endpoint property of a private endpoint connection. + :vartype private_endpoint: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: Required. The current state of a private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionState """ @@ -1890,6 +2220,14 @@ def __init__( private_endpoint: Optional["PrivateEndpoint"] = None, **kwargs ): + """ + :keyword private_endpoint: The private endpoint property of a private endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: Required. The current state of a private + endpoint connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionState + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -1898,8 +2236,8 @@ def __init__( class PrivateLinkResources(msrest.serialization.Model): """The available private link resources for an IotHub. - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformation] + :ivar value: The list of available private link resources for an IotHub. + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformation] """ _attribute_map = { @@ -1912,6 +2250,10 @@ def __init__( value: Optional[List["GroupIdInformation"]] = None, **kwargs ): + """ + :keyword value: The list of available private link resources for an IotHub. + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.GroupIdInformation] + """ super(PrivateLinkResources, self).__init__(**kwargs) self.value = value @@ -1921,14 +2263,15 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. The status of a private endpoint connection. Possible values include: + :ivar status: Required. The status of a private endpoint connection. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint + :vartype status: str or + ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionStatus + :ivar description: Required. The description for the current state of a private endpoint connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type actions_required: str + :vartype description: str + :ivar actions_required: Actions required for a private endpoint connection. + :vartype actions_required: str """ _validation = { @@ -1950,6 +2293,17 @@ def __init__( actions_required: Optional[str] = None, **kwargs ): + """ + :keyword status: Required. The status of a private endpoint connection. Possible values + include: "Pending", "Approved", "Rejected", "Disconnected". + :paramtype status: str or + ~azure.mgmt.iothub.v2020_03_01.models.PrivateLinkServiceConnectionStatus + :keyword description: Required. The description for the current state of a private endpoint + connection. + :paramtype description: str + :keyword actions_required: Actions required for a private endpoint connection. + :paramtype actions_required: str + """ super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -1985,6 +2339,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -1994,12 +2350,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorRange """ _attribute_map = { @@ -2016,6 +2372,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorRange + """ super(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -2025,10 +2389,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -2043,6 +2407,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -2051,10 +2421,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition """ _attribute_map = { @@ -2069,6 +2439,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2020_03_01.models.RouteErrorPosition + """ super(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -2079,23 +2455,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2020_03_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -2123,6 +2498,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2020_03_01.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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -2134,20 +2528,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2020_03_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2020_03_01.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2020_03_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: list[~azure.mgmt.iothub.v2020_03_01.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2020_03_01.models.RoutingStorageContainerProperties] """ @@ -2167,6 +2561,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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.v2020_03_01.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.v2020_03_01.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.v2020_03_01.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.v2020_03_01.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -2179,26 +2590,26 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. The name that identifies this endpoint. The name can only include + :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. Possible + values include: "keyBased", "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -2229,6 +2640,28 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :keyword name: Required. 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. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2243,12 +2676,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -2265,6 +2698,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -2274,23 +2715,23 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2020_03_01.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2020_03_01.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. - :type routes: list[~azure.mgmt.iothub.v2020_03_01.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2020_03_01.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. - :type fallback_route: ~azure.mgmt.iothub.v2020_03_01.models.FallbackRouteProperties - :param enrichments: The list of user-provided enrichments that the IoT hub applies to messages + :vartype fallback_route: ~azure.mgmt.iothub.v2020_03_01.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. - :type enrichments: list[~azure.mgmt.iothub.v2020_03_01.models.EnrichmentProperties] + :vartype enrichments: list[~azure.mgmt.iothub.v2020_03_01.models.EnrichmentProperties] """ _attribute_map = { @@ -2309,6 +2750,26 @@ def __init__( enrichments: Optional[List["EnrichmentProperties"]] = None, **kwargs ): + """ + :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.v2020_03_01.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.v2020_03_01.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.v2020_03_01.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.v2020_03_01.models.EnrichmentProperties] + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -2321,28 +2782,28 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -2373,6 +2834,30 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :keyword name: Required. 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. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2389,28 +2874,28 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2441,6 +2926,30 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :keyword name: Required. 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. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2457,40 +2966,40 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :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'. Possible values include: "Avro", "AvroDeflate", "JSON". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingStorageContainerPropertiesEncoding """ @@ -2533,6 +3042,43 @@ def __init__( encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :keyword name: Required. 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. + :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: Required. The name of storage container in the storage account. + :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'. Possible values include: "Avro", + "AvroDeflate", "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2020_03_01.models.RoutingStorageContainerPropertiesEncoding + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2551,10 +3097,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwinProperties """ _attribute_map = { @@ -2569,6 +3115,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2577,10 +3129,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any + :ivar desired: Twin desired properties. + :vartype desired: any + :ivar reported: Twin desired properties. + :vartype reported: any """ _attribute_map = { @@ -2595,6 +3147,12 @@ def __init__( reported: Optional[Any] = None, **kwargs ): + """ + :keyword desired: Twin desired properties. + :paramtype desired: any + :keyword reported: Twin desired properties. + :paramtype reported: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired = desired self.reported = reported @@ -2605,20 +3163,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2020_03_01.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2020_03_01.models.AccessRights """ _validation = { @@ -2642,6 +3200,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2020_03_01.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -2654,8 +3228,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -2675,6 +3250,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2685,19 +3265,19 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype container_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + :vartype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType """ _validation = { @@ -2721,6 +3301,21 @@ def __init__( authentication_type: Optional[Union[str, "AuthenticationType"]] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2020_03_01.models.AuthenticationType + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -2731,8 +3326,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -2745,6 +3340,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -2752,13 +3351,13 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin + :vartype routing_source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin """ _attribute_map = { @@ -2775,6 +3374,15 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2020_03_01.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin + """ super(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -2784,8 +3392,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2020_03_01.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2020_03_01.models.MatchedRoute] """ _attribute_map = { @@ -2798,6 +3406,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2020_03_01.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -2807,12 +3419,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage + :ivar route: Required. Route properties. + :vartype route: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin """ _validation = { @@ -2833,6 +3445,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2020_03_01.models.RoutingMessage + :keyword route: Required. Route properties. + :paramtype route: ~azure.mgmt.iothub.v2020_03_01.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2020_03_01.models.RoutingTwin + """ super(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -2842,10 +3462,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2020_03_01.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :vartype result: str or ~azure.mgmt.iothub.v2020_03_01.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResultDetails """ _attribute_map = { @@ -2860,6 +3480,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "true". + :paramtype result: str or ~azure.mgmt.iothub.v2020_03_01.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2020_03_01.models.TestRouteResultDetails + """ super(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -2868,8 +3495,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2020_03_01.models.RouteCompilationError] + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2020_03_01.models.RouteCompilationError] """ _attribute_map = { @@ -2882,6 +3509,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2020_03_01.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -2889,18 +3521,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2020_03_01.models.Name + :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.v2020_03_01.models.Name """ _attribute_map = { @@ -2923,6 +3555,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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.v2020_03_01.models.Name + """ super(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -2937,8 +3583,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2020_03_01.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2020_03_01.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -2958,6 +3604,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2020_03_01.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py index 314a9d61de07..a7ea4e625cfd 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateBodyDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2020_03_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2020_03_01.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py index 5074a8f939da..3558c1d9573b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_operations.py @@ -5,24 +5,71 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_manual_failover_request_initial( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubOperations(object): """IotHubOperations operations. @@ -48,64 +95,53 @@ def __init__(self, client, config, serializer, deserializer): def _manual_failover_initial( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> None + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace def begin_manual_failover( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **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 @@ -121,15 +157,18 @@ def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2020_03_01.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -141,24 +180,18 @@ def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -170,4 +203,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py index c1ed507d469c..b197c51cfc67 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_iot_hub_resource_operations.py @@ -5,25 +5,907 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +929,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +954,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +979,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1030,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +1062,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +1087,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +1113,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1157,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1181,19 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2020_03_01.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1205,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1231,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1277,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1298,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescription + or ~azure.mgmt.iothub.v2020_03_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1324,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1346,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1370,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1405,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1430,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1441,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1478,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1515,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1540,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1560,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1571,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1610,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1643,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1654,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1695,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1738,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,17 +1765,19 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -977,35 +1800,25 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1014,17 +1827,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1047,35 +1862,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1083,14 +1888,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1100,8 +1907,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1109,36 +1918,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1151,26 +1957,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1191,34 +1999,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1227,15 +2025,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1245,8 +2045,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1254,36 +2056,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1296,24 +2095,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1323,8 +2123,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1332,36 +2134,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1374,23 +2173,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1408,36 +2208,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1446,16 +2236,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1476,38 +2268,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1516,16 +2298,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1546,38 +2330,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1586,16 +2360,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1605,8 +2382,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2020_03_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1614,36 +2393,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1656,26 +2432,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1696,34 +2474,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1732,17 +2500,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1764,38 +2536,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1804,17 +2566,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1836,38 +2602,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1876,4 +2632,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py index e56dd3fcb3d8..505155cfd60b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2020_03_01/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py index 73f726bdbb94..ade8c39c7b02 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_endpoint_connections_operations.py @@ -5,24 +5,182 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -46,13 +204,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> List["_models.PrivateEndpointConnection"]: """List private endpoint connections. List private endpoint connection properties. @@ -71,33 +229,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -106,16 +254,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + 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. @@ -136,34 +286,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -172,56 +312,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -233,17 +363,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. @@ -255,18 +387,24 @@ def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +417,21 @@ def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -312,50 +443,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -368,16 +488,18 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + 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. @@ -390,15 +512,19 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2020_03_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -413,25 +539,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -443,4 +561,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py index dbbc36575771..d4327dfb078a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_private_link_resources_operations.py @@ -5,22 +5,96 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2020-03-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +118,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResources" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResources": """List private link resources. List private link resources for the given IotHub. @@ -69,33 +143,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -104,16 +168,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupIdInformation" + 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. @@ -134,34 +200,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -170,4 +226,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py index 6787f3c8acc1..5511313d433e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2020_03_01/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2020-03-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2020-03-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py index dd94e0ecba2a..4c19507767b9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2021_03_03_preview/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py index 7eff43e2772a..228c19ee302c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_iot_hub_client.py @@ -6,104 +6,100 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2021_03_03_preview.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2021_03_03_preview.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2021_03_03_preview.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2021_03_03_preview.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2021_03_03_preview.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2021_03_03_preview.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2021_03_03_preview.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2021_03_03_preview.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2021_03_03_preview.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_03_preview.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2021_03_03_preview.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) - 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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json index 24c6a0568ce2..89c74400d8bf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py index 0b69f2acf43a..8c2881ceb63e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2021_03_03_preview/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py index 669fc65c8c7b..0a2596c56ef8 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_iot_hub_client.py @@ -6,100 +6,101 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +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 -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2021_03_03_preview.aio.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2021_03_03_preview.aio.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations - :vartype certificates: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.CertificatesOperations + :vartype certificates: + azure.mgmt.iothub.v2021_03_03_preview.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2021_03_03_preview.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_03_preview.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2021_03_03_preview.aio.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) + - 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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py index b396fb3535ea..ae289fc0cd12 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -186,7 +177,8 @@ async def create_or_update( :param certificate_name: The name of the certificate. :type certificate_name: str :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :type certificate_description: + ~azure.mgmt.iothub.v2021_03_03_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. :type if_match: str @@ -200,41 +192,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +228,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +263,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +289,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +322,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +349,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +377,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription @@ -419,40 +389,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +421,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py index 6de4792dabf1..fab7afcbc92c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,45 +58,36 @@ async def _manual_failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, @@ -115,15 +110,18 @@ async def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -135,24 +133,18 @@ async def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -164,4 +156,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py index 416a5dddfb21..9aa4244ff357 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -190,15 +179,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -211,27 +205,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -243,6 +231,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -257,32 +246,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -296,8 +275,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -317,15 +299,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_03_preview.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -337,27 +324,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -369,6 +350,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -382,34 +364,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -425,8 +396,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -443,15 +417,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription + or ~azure.mgmt.iothub.v2021_03_03_preview.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -465,24 +444,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -494,8 +466,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -505,8 +479,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -514,34 +490,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -554,17 +525,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -577,8 +550,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -586,35 +561,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -627,17 +598,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -662,33 +635,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -697,8 +660,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -714,8 +680,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -723,36 +691,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -765,17 +730,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -783,7 +750,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -795,8 +763,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -804,37 +774,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -847,17 +815,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -888,35 +858,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -925,8 +885,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -949,7 +912,8 @@ async def create_event_hub_consumer_group( :param name: The name of the consumer group to add. :type name: str :param consumer_group_body: The consumer group to add. - :type consumer_group_body: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: EventHubConsumerGroupInfo, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo @@ -960,40 +924,30 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1002,8 +956,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1034,35 +991,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1070,13 +1017,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1086,8 +1036,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1095,36 +1047,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1137,17 +1086,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1155,7 +1106,8 @@ async def get_job( 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. 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. @@ -1176,34 +1128,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1212,8 +1154,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1229,8 +1174,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1238,36 +1185,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1280,17 +1224,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1306,8 +1252,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1315,36 +1263,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1357,17 +1302,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1390,36 +1337,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1428,8 +1365,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1457,38 +1397,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1497,8 +1427,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1526,38 +1459,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1566,15 +1489,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1584,8 +1511,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1593,36 +1522,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1635,17 +1561,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1653,7 +1581,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1674,34 +1603,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1710,8 +1629,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1719,7 +1641,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1730,7 +1654,8 @@ async def export_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. - :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest + :type export_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse @@ -1741,38 +1666,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1781,8 +1696,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1790,7 +1708,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1801,7 +1721,8 @@ async def import_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. - :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest + :type import_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse @@ -1812,38 +1733,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1852,4 +1763,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py index 397b3f45c3af..7fe0153d081c 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py index 848003d6c0d5..360476c9c1e9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_endpoint_connections_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -66,33 +71,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -101,8 +96,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -130,34 +128,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -166,8 +154,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, @@ -181,40 +171,29 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -226,8 +205,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -247,18 +229,24 @@ async def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -271,28 +259,21 @@ async def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -304,6 +285,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -318,35 +300,24 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -359,8 +330,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -380,15 +354,19 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -403,25 +381,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -433,4 +403,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py index a138a40dea52..4ec5d7fa9f28 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_private_link_resources_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -99,8 +94,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -164,4 +152,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py index 8f18daa04c36..f7e828fb0140 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py index a74f297bc163..61dab75c6643 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/__init__.py @@ -6,176 +6,91 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ArmIdentity - from ._models_py3 import ArmUserIdentity - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EncryptionPropertiesDescription - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import EnrichmentProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupBodyDescription - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupName - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FailoverInput - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import GroupIdInformation - from ._models_py3 import GroupIdInformationProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubLocationDescription - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubPropertiesDeviceStreams - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import KeyVaultKeyProperties - from ._models_py3 import ManagedIdentity - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import NetworkRuleSetIpRule - from ._models_py3 import NetworkRuleSetProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionProperties - from ._models_py3 import PrivateLinkResources - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import ArmIdentity # type: ignore - from ._models import ArmUserIdentity # type: ignore - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EncryptionPropertiesDescription # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import EnrichmentProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupBodyDescription # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupName # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FailoverInput # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import GroupIdInformation # type: ignore - from ._models import GroupIdInformationProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubLocationDescription # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubPropertiesDeviceStreams # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import KeyVaultKeyProperties # type: ignore - from ._models import ManagedIdentity # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import NetworkRuleSetIpRule # type: ignore - from ._models import NetworkRuleSetProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionProperties # type: ignore - from ._models import PrivateLinkResources # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import ArmIdentity +from ._models_py3 import ArmUserIdentity +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EncryptionPropertiesDescription +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupBodyDescription +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupName +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubPropertiesDeviceStreams +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import KeyVaultKeyProperties +from ._models_py3 import ManagedIdentity +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import NetworkRuleSetIpRule +from ._models_py3 import NetworkRuleSetProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResources +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py index c2f6b6a50e3e..a8c0e3a0f3e6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,28 +31,28 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies authentication type being used for connecting to the storage account. """ KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class DefaultAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Default Action for Network Rule Set """ DENY = "Deny" ALLOW = "Allow" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -85,14 +70,14 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -101,7 +86,7 @@ class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -109,7 +94,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -121,7 +106,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -129,14 +114,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -147,7 +132,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -162,13 +147,13 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class NetworkRuleIPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """IP Filter Action """ ALLOW = "Allow" -class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of a private endpoint connection """ @@ -177,14 +162,14 @@ class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether requests from Public Network are allowed """ ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -195,14 +180,14 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -214,7 +199,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DIGITAL_TWIN_CHANGE_EVENTS = "DigitalTwinChangeEvents" DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -223,7 +208,7 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveE AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models.py deleted file mode 100644 index 59d5b0732b8f..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models.py +++ /dev/null @@ -1,3059 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class ArmIdentity(msrest.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 - :param 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. Possible values include: "SystemAssigned", - "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.ResourceIdentityType - :param user_assigned_identities: Dictionary of :code:``. - :type user_assigned_identities: dict[str, - ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmUserIdentity] - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'user_assigned_identities': {'key': 'userAssignedIdentities', 'type': '{ArmUserIdentity}'}, - } - - def __init__( - self, - **kwargs - ): - super(ArmIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class ArmUserIdentity(msrest.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 - ): - super(ArmUserIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EncryptionPropertiesDescription(msrest.serialization.Model): - """The encryption properties for the IoT hub. - - :param key_source: The source of the key. - :type key_source: str - :param key_vault_properties: The properties of the KeyVault key. - :type key_vault_properties: - list[~azure.mgmt.iothub.v2021_03_03_preview.models.KeyVaultKeyProperties] - """ - - _attribute_map = { - 'key_source': {'key': 'keySource', 'type': 'str'}, - 'key_vault_properties': {'key': 'keyVaultProperties', 'type': '[KeyVaultKeyProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(EncryptionPropertiesDescription, self).__init__(**kwargs) - self.key_source = kwargs.get('key_source', None) - self.key_vault_properties = kwargs.get('key_vault_properties', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param 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. Possible values include: "unknown", "healthy", "degraded", - "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthStatus - :param last_known_error: Last error obtained when a message failed to be delivered to iot hub. - :type last_known_error: str - :param last_known_error_time: Time at which the last known error occurred. - :type last_known_error_time: ~datetime.datetime - :param last_successful_send_attempt_time: Last time iot hub successfully sent a message to the - endpoint. - :type last_successful_send_attempt_time: ~datetime.datetime - :param last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. - :type 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, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - self.last_known_error = kwargs.get('last_known_error', None) - self.last_known_error_time = kwargs.get('last_known_error_time', None) - self.last_successful_send_attempt_time = kwargs.get('last_successful_send_attempt_time', None) - self.last_send_attempt_time = kwargs.get('last_send_attempt_time', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EnrichmentProperties(msrest.serialization.Model): - """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. - :type 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, - **kwargs - ): - super(EnrichmentProperties, self).__init__(**kwargs) - self.key = kwargs['key'] - self.value = kwargs['value'] - self.endpoint_names = kwargs['endpoint_names'] - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): - """The EventHub consumer group. - - :param properties: The EventHub consumer group name. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupName - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'EventHubConsumerGroupName'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupName(msrest.serialization.Model): - """The EventHub consumer group name. - - :param name: EventHub consumer group name. - :type name: str - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupName, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type exclude_keys: bool - :param 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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for export devices. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - self.export_blob_name = kwargs.get('export_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - - -class FailoverInput(msrest.serialization.Model): - """Use to provide failover region when requesting manual Failover for a hub. - - All required parameters must be populated in order to send to Azure. - - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str - """ - - _validation = { - 'failover_region': {'required': True}, - } - - _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverInput, self).__init__(**kwargs) - self.failover_region = kwargs['failover_region'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", - "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class GroupIdInformation(msrest.serialization.Model): - """The group information for creating a private endpoint on an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformationProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - '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, - **kwargs - ): - super(GroupIdInformation, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class GroupIdInformationProperties(msrest.serialization.Model): - """The properties for a group information object. - - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type 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, - **kwargs - ): - super(GroupIdInformationProperties, self).__init__(**kwargs) - self.group_id = kwargs.get('group_id', None) - self.required_members = kwargs.get('required_members', None) - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob - container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for import devices. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - """ - - _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'}, - } - - def __init__( - self, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - self.input_blob_name = kwargs.get('input_blob_name', None) - self.output_blob_name = kwargs.get('output_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2021_03_03_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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo - :param identity: The managed identities for the IotHub. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmIdentity - """ - - _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'}, - 'identity': {'key': 'identity', 'type': 'ArmIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - self.identity = kwargs.get('identity', None) - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubLocationDescription(msrest.serialization.Model): - """Public representation of one of the locations where a resource is provisioned. - - :param location: The name of the Azure region. - :type location: str - :param 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. Possible values - include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubReplicaRoleType - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubLocationDescription, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.role = kwargs.get('role', None) - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] - :param public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". - :type public_network_access: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterRule] - :param network_rule_sets: Network Rule Set Properties of IotHub. - :type network_rule_sets: ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetProperties - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: - list[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :ivar provisioning_state: The provisioning state. - :vartype provisioning_state: str - :ivar state: The hub state. - :vartype state: str - :ivar host_name: The name of the host. - :vartype host_name: str - :param 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. - :type event_hub_endpoints: dict[str, - ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2021_03_03_preview.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2021_03_03_preview.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2021_03_03_preview.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param device_streams: The device streams properties of iothub. - :type device_streams: - ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubPropertiesDeviceStreams - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.Capabilities - :param encryption: The encryption properties for the IoT hub. - :type encryption: ~azure.mgmt.iothub.v2021_03_03_preview.models.EncryptionPropertiesDescription - :ivar locations: Primary and secondary location for iot hub. - :vartype locations: - list[~azure.mgmt.iothub.v2021_03_03_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]'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'network_rule_sets': {'key': 'networkRuleSets', 'type': 'NetworkRuleSetProperties'}, - 'min_tls_version': {'key': 'minTlsVersion', 'type': 'str'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'state': {'key': 'state', 'type': 'str'}, - 'host_name': {'key': 'hostName', 'type': 'str'}, - 'event_hub_endpoints': {'key': 'eventHubEndpoints', 'type': '{EventHubProperties}'}, - 'routing': {'key': 'routing', 'type': 'RoutingProperties'}, - 'storage_endpoints': {'key': 'storageEndpoints', 'type': '{StorageEndpointProperties}'}, - 'messaging_endpoints': {'key': 'messagingEndpoints', 'type': '{MessagingEndpointProperties}'}, - 'enable_file_upload_notifications': {'key': 'enableFileUploadNotifications', 'type': 'bool'}, - 'cloud_to_device': {'key': 'cloudToDevice', 'type': 'CloudToDeviceProperties'}, - 'comments': {'key': 'comments', 'type': 'str'}, - 'device_streams': {'key': 'deviceStreams', 'type': 'IotHubPropertiesDeviceStreams'}, - 'features': {'key': 'features', 'type': 'str'}, - 'encryption': {'key': 'encryption', 'type': 'EncryptionPropertiesDescription'}, - 'locations': {'key': 'locations', 'type': '[IotHubLocationDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.public_network_access = kwargs.get('public_network_access', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.network_rule_sets = kwargs.get('network_rule_sets', None) - self.min_tls_version = kwargs.get('min_tls_version', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.device_streams = kwargs.get('device_streams', None) - self.features = kwargs.get('features', None) - self.encryption = kwargs.get('encryption', None) - self.locations = None - - -class IotHubPropertiesDeviceStreams(msrest.serialization.Model): - """The device streams properties of iothub. - - :param streaming_endpoints: List of Device Streams Endpoints. - :type streaming_endpoints: list[str] - """ - - _attribute_map = { - 'streaming_endpoints': {'key': 'streamingEndpoints', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubPropertiesDeviceStreams, self).__init__(**kwargs) - self.streaming_endpoints = kwargs.get('streaming_endpoints', None) - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2021_03_03_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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class KeyVaultKeyProperties(msrest.serialization.Model): - """The properties of the KeyVault key. - - :param key_identifier: The identifier of the key. - :type key_identifier: str - :param identity: Managed identity properties of KeyVault Key. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - """ - - _attribute_map = { - 'key_identifier': {'key': 'keyIdentifier', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(KeyVaultKeyProperties, self).__init__(**kwargs) - self.key_identifier = kwargs.get('key_identifier', None) - self.identity = kwargs.get('identity', None) - - -class ManagedIdentity(msrest.serialization.Model): - """The properties of the Managed identity. - - :param user_assigned_identity: The user assigned identity. - :type user_assigned_identity: str - """ - - _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedIdentity, self).__init__(**kwargs) - self.user_assigned_identity = kwargs.get('user_assigned_identity', None) - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class NetworkRuleSetIpRule(msrest.serialization.Model): - """IP Rule to be applied as part of Network Rule Set. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. Name of the IP filter rule. - :type filter_name: str - :param action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleIPAction - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(NetworkRuleSetIpRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs.get('action', "Allow") - self.ip_mask = kwargs['ip_mask'] - - -class NetworkRuleSetProperties(msrest.serialization.Model): - """Network Rule Set Properties of IotHub. - - All required parameters must be populated in order to send to Azure. - - :param default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". - :type default_action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.DefaultAction - :param apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. - :type apply_to_built_in_event_hub_endpoint: bool - :param ip_rules: Required. List of IP Rules. - :type ip_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetIpRule] - """ - - _validation = { - 'apply_to_built_in_event_hub_endpoint': {'required': True}, - 'ip_rules': {'required': True}, - } - - _attribute_map = { - 'default_action': {'key': 'defaultAction', 'type': 'str'}, - 'apply_to_built_in_event_hub_endpoint': {'key': 'applyToBuiltInEventHubEndpoint', 'type': 'bool'}, - 'ip_rules': {'key': 'ipRules', 'type': '[NetworkRuleSetIpRule]'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkRuleSetProperties, self).__init__(**kwargs) - self.default_action = kwargs.get('default_action', "Deny") - self.apply_to_built_in_event_hub_endpoint = kwargs['apply_to_built_in_event_hub_endpoint'] - self.ip_rules = kwargs['ip_rules'] - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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.v2021_03_03_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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpoint(msrest.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 - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(msrest.serialization.Model): - """The private endpoint connection of an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: - ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnectionProperties - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, - '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, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class PrivateEndpointConnectionProperties(msrest.serialization.Model): - """The properties of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint - connection. - :type private_link_service_connection_state: - ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionState - """ - - _validation = { - 'private_link_service_connection_state': {'required': True}, - } - - _attribute_map = { - 'private_endpoint': {'key': 'privateEndpoint', 'type': 'PrivateEndpoint'}, - 'private_link_service_connection_state': {'key': 'privateLinkServiceConnectionState', 'type': 'PrivateLinkServiceConnectionState'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs['private_link_service_connection_state'] - - -class PrivateLinkResources(msrest.serialization.Model): - """The available private link resources for an IotHub. - - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResources, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint - connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type 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, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs['description'] - self.actions_required = kwargs.get('actions_required', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorRange - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition - """ - - _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", - "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing event hub endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2021_03_03_preview.models.FallbackRouteProperties - :param 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. - :type enrichments: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - self.enrichments = kwargs.get('enrichments', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing service bus queue endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing service bus topic endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". - :type authentication_type: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing storage endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". - :type encoding: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingStorageContainerPropertiesEncoding - """ - - _validation = { - 'name': {'required': True, 'pattern': r'^[A-Za-z0-9-._]{1,64}$'}, - 'container_name': {'required': True}, - 'batch_frequency_in_seconds': {'maximum': 720, 'minimum': 60}, - 'max_chunk_size_in_bytes': {'maximum': 524288000, 'minimum': 10485760}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'endpoint_uri': {'key': 'endpointUri', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - 'name': {'key': 'name', 'type': 'str'}, - 'subscription_id': {'key': 'subscriptionId', 'type': 'str'}, - 'resource_group': {'key': 'resourceGroup', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'file_name_format': {'key': 'fileNameFormat', 'type': 'str'}, - 'batch_frequency_in_seconds': {'key': 'batchFrequencyInSeconds', 'type': 'int'}, - 'max_chunk_size_in_bytes': {'key': 'maxChunkSizeInBytes', 'type': 'int'}, - 'encoding': {'key': 'encoding', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwinProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any - """ - - _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired = kwargs.get('desired', None) - self.reported = kwargs.get('reported', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: - list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or - ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for file upload. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - """ - - _validation = { - 'connection_string': {'required': True}, - 'container_name': {'required': True}, - } - - _attribute_map = { - 'sas_ttl_as_iso8601': {'key': 'sasTtlAsIso8601', 'type': 'duration'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'container_name': {'key': 'containerName', 'type': 'str'}, - 'authentication_type': {'key': 'authenticationType', 'type': 'str'}, - 'identity': {'key': 'identity', 'type': 'ManagedIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin - """ - - _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2021_03_03_preview.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResultDetails - """ - - _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: - list[~azure.mgmt.iothub.v2021_03_03_preview.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type value: list[~azure.mgmt.iothub.v2021_03_03_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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py index 3208fb57c4b9..15e24f718b19 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/models/_models_py3.py @@ -24,13 +24,13 @@ class ArmIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: Tenant Id. :vartype tenant_id: str - :param type: The type of identity used for the resource. The type 'SystemAssigned,UserAssigned' + :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. Possible values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.ResourceIdentityType - :param user_assigned_identities: Dictionary of :code:``. - :type user_assigned_identities: dict[str, + :vartype type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.ResourceIdentityType + :ivar user_assigned_identities: Dictionary of :code:``. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmUserIdentity] """ @@ -53,6 +53,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "ArmUserIdentity"]] = None, **kwargs ): + """ + :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. Possible + values include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.ResourceIdentityType + :keyword user_assigned_identities: Dictionary of :code:``. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmUserIdentity] + """ super(ArmIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -85,6 +95,8 @@ def __init__( self, **kwargs ): + """ + """ super(ArmUserIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -93,9 +105,9 @@ def __init__( class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -108,6 +120,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -117,8 +134,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -150,6 +167,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -161,8 +182,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription] """ _attribute_map = { @@ -175,6 +196,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -196,8 +221,8 @@ class CertificateProperties(msrest.serialization.Model): :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. :vartype updated: ~datetime.datetime - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -225,6 +250,10 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -285,6 +314,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -299,9 +330,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -314,6 +345,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -323,9 +359,10 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificatePropertiesWithNonce + :vartype properties: + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -357,6 +394,12 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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.v2021_03_03_preview.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -368,16 +411,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2021_03_03_preview.models.FeedbackProperties + :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.v2021_03_03_preview.models.FeedbackProperties """ _validation = { @@ -398,6 +441,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2021_03_03_preview.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -407,10 +462,10 @@ def __init__( class EncryptionPropertiesDescription(msrest.serialization.Model): """The encryption properties for the IoT hub. - :param key_source: The source of the key. - :type key_source: str - :param key_vault_properties: The properties of the KeyVault key. - :type key_vault_properties: + :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.v2021_03_03_preview.models.KeyVaultKeyProperties] """ @@ -426,6 +481,13 @@ def __init__( key_vault_properties: Optional[List["KeyVaultKeyProperties"]] = None, **kwargs ): + """ + :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.v2021_03_03_preview.models.KeyVaultKeyProperties] + """ super(EncryptionPropertiesDescription, self).__init__(**kwargs) self.key_source = key_source self.key_vault_properties = key_vault_properties @@ -434,9 +496,9 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: Health statuses have following meanings. The 'healthy' status shows that + :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 @@ -446,16 +508,17 @@ class EndpointHealthData(msrest.serialization.Model): the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or rejected from this endpoint. Possible values include: "unknown", "healthy", "degraded", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthStatus - :param last_known_error: Last error obtained when a message failed to be delivered to iot hub. - :type last_known_error: str - :param last_known_error_time: Time at which the last known error occurred. - :type last_known_error_time: ~datetime.datetime - :param last_successful_send_attempt_time: Last time iot hub successfully sent a message to the + :vartype health_status: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthStatus + :ivar last_known_error: Last error obtained when a message failed to be delivered to iot hub. + :vartype last_known_error: str + :ivar last_known_error_time: Time at which the last known error occurred. + :vartype last_known_error_time: ~datetime.datetime + :ivar last_successful_send_attempt_time: Last time iot hub successfully sent a message to the endpoint. - :type last_successful_send_attempt_time: ~datetime.datetime - :param last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. - :type last_send_attempt_time: ~datetime.datetime + :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 = { @@ -478,6 +541,32 @@ def __init__( last_send_attempt_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :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. Possible values include: "unknown", + "healthy", "degraded", "unhealthy", "dead". + :paramtype health_status: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthStatus + :keyword last_known_error: Last error obtained when a message failed to be delivered to iot + hub. + :paramtype last_known_error: str + :keyword last_known_error_time: Time at which the last known error occurred. + :paramtype last_known_error_time: ~datetime.datetime + :keyword last_successful_send_attempt_time: Last time iot hub successfully sent a message to + the endpoint. + :paramtype last_successful_send_attempt_time: ~datetime.datetime + :keyword last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. + :paramtype last_send_attempt_time: ~datetime.datetime + """ super(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -492,8 +581,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthData] + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthData] :ivar next_link: Link to more results. :vartype next_link: str """ @@ -513,6 +602,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -523,13 +616,13 @@ class EnrichmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to + :ivar key: Required. The key or name for the enrichment property. + :vartype key: str + :ivar value: Required. The value for the enrichment property. + :vartype value: str + :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to the message. - :type endpoint_names: list[str] + :vartype endpoint_names: list[str] """ _validation = { @@ -552,6 +645,15 @@ def __init__( endpoint_names: List[str], **kwargs ): + """ + :keyword key: Required. The key or name for the enrichment property. + :paramtype key: str + :keyword value: Required. The value for the enrichment property. + :paramtype value: str + :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to + the message. + :paramtype endpoint_names: list[str] + """ super(EnrichmentProperties, self).__init__(**kwargs) self.key = key self.value = value @@ -591,6 +693,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -601,8 +705,8 @@ def __init__( class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): """The EventHub consumer group. - :param properties: The EventHub consumer group name. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupName + :ivar properties: The EventHub consumer group name. + :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupName """ _attribute_map = { @@ -615,6 +719,10 @@ def __init__( properties: Optional["EventHubConsumerGroupName"] = None, **kwargs ): + """ + :keyword properties: The EventHub consumer group name. + :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupName + """ super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) self.properties = properties @@ -624,8 +732,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, str] + :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. @@ -657,6 +765,10 @@ def __init__( properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, str] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -668,8 +780,8 @@ def __init__( class EventHubConsumerGroupName(msrest.serialization.Model): """The EventHub consumer group name. - :param name: EventHub consumer group name. - :type name: str + :ivar name: EventHub consumer group name. + :vartype name: str """ _attribute_map = { @@ -682,6 +794,10 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword name: EventHub consumer group name. + :paramtype name: str + """ super(EventHubConsumerGroupName, self).__init__(**kwargs) self.name = name @@ -691,8 +807,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo] + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -712,6 +828,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -722,13 +842,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -758,6 +878,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -771,20 +900,20 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool - :param export_blob_name: The name of the blob that will be created in the provided output blob + :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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype export_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for export devices. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :ivar identity: Managed identity properties of storage endpoint for export devices. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity """ _validation = { @@ -810,6 +939,23 @@ def __init__( identity: Optional["ManagedIdentity"] = None, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for export devices. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + """ super(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -823,8 +969,8 @@ class FailoverInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str + :ivar failover_region: Required. Region the hub will be failed over to. + :vartype failover_region: str """ _validation = { @@ -841,6 +987,10 @@ def __init__( failover_region: str, **kwargs ): + """ + :keyword failover_region: Required. Region the hub will be failed over to. + :paramtype failover_region: str + """ super(FailoverInput, self).__init__(**kwargs) self.failover_region = failover_region @@ -850,23 +1000,23 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2021_03_03_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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -893,6 +1043,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2021_03_03_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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -904,17 +1073,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -935,6 +1104,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -954,8 +1136,8 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformationProperties + :ivar properties: Required. The properties for a group information object. + :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformationProperties """ _validation = { @@ -978,6 +1160,11 @@ def __init__( properties: "GroupIdInformationProperties", **kwargs ): + """ + :keyword properties: Required. The properties for a group information object. + :paramtype properties: + ~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformationProperties + """ super(GroupIdInformation, self).__init__(**kwargs) self.id = None self.name = None @@ -988,12 +1175,12 @@ def __init__( class GroupIdInformationProperties(msrest.serialization.Model): """The properties for a group information object. - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type required_zone_names: list[str] + :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 = { @@ -1010,6 +1197,14 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :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(GroupIdInformationProperties, self).__init__(**kwargs) self.group_id = group_id self.required_members = required_members @@ -1021,21 +1216,21 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str + :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for import devices. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :ivar identity: Managed identity properties of storage endpoint for import devices. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity """ _validation = { @@ -1063,6 +1258,23 @@ def __init__( identity: Optional["ManagedIdentity"] = None, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for import devices. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + """ super(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -1106,6 +1318,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -1126,10 +1340,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1154,6 +1368,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1175,19 +1395,19 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo - :param identity: The managed identities for the IotHub. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmIdentity + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo + :ivar identity: The managed identities for the IotHub. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmIdentity """ _validation = { @@ -1221,6 +1441,21 @@ def __init__( identity: Optional["ArmIdentity"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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.v2021_03_03_preview.models.IotHubProperties + :keyword sku: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo + :keyword identity: The managed identities for the IotHub. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ArmIdentity + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -1233,8 +1468,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1254,6 +1489,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1262,13 +1501,13 @@ def __init__( class IotHubLocationDescription(msrest.serialization.Model): """Public representation of one of the locations where a resource is provisioned. - :param location: The name of the Azure region. - :type location: str - :param role: The role of the region, can be either primary or secondary. The primary region is + :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. Possible values include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubReplicaRoleType + :vartype role: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubReplicaRoleType """ _attribute_map = { @@ -1283,6 +1522,15 @@ def __init__( role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, **kwargs ): + """ + :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. Possible + values include: "primary", "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubReplicaRoleType + """ super(IotHubLocationDescription, self).__init__(**kwargs) self.location = location self.role = role @@ -1299,8 +1547,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -1320,6 +1568,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -1331,23 +1583,24 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :ivar public_network_access: Whether requests from Public Network are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or + :vartype public_network_access: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterRule] - :param network_rule_sets: Network Rule Set Properties of IotHub. - :type network_rule_sets: ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetProperties - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterRule] + :ivar network_rule_sets: Network Rule Set Properties of IotHub. + :vartype network_rule_sets: + ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetProperties + :ivar min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set to + "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :vartype min_tls_version: str + :ivar private_endpoint_connections: Private endpoint connections created on this IotHub. + :vartype private_endpoint_connections: list[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1355,39 +1608,40 @@ class IotHubProperties(msrest.serialization.Model): :vartype state: str :ivar host_name: The name of the host. :vartype host_name: str - :param 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. - :type event_hub_endpoints: dict[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.v2021_03_03_preview.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2021_03_03_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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2021_03_03_preview.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2021_03_03_preview.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2021_03_03_preview.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param device_streams: The device streams properties of iothub. - :type device_streams: + :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.v2021_03_03_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.v2021_03_03_preview.models.IotHubPropertiesDeviceStreams - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.Capabilities - :param encryption: The encryption properties for the IoT hub. - :type encryption: ~azure.mgmt.iothub.v2021_03_03_preview.models.EncryptionPropertiesDescription + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.Capabilities + :ivar encryption: The encryption properties for the IoT hub. + :vartype encryption: + ~azure.mgmt.iothub.v2021_03_03_preview.models.EncryptionPropertiesDescription :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubLocationDescription] @@ -1444,6 +1698,62 @@ def __init__( encryption: Optional["EncryptionPropertiesDescription"] = None, **kwargs ): + """ + :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.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] + :keyword public_network_access: Whether requests from Public Network are allowed. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterRule] + :keyword network_rule_sets: Network Rule Set Properties of IotHub. + :paramtype network_rule_sets: + ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetProperties + :keyword min_tls_version: Specifies the minimum TLS version to support for this hub. Can be set + to "1.2" to have clients that use a TLS version below 1.2 to be rejected. + :paramtype min_tls_version: str + :keyword private_endpoint_connections: Private endpoint connections created on this IotHub. + :paramtype private_endpoint_connections: + list[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :keyword event_hub_endpoints: The Event Hub-compatible endpoint properties. The only possible + keys to this dictionary is events. This key has to be present in the dictionary while making + create or update calls for the IoT hub. + :paramtype event_hub_endpoints: dict[str, + ~azure.mgmt.iothub.v2021_03_03_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.v2021_03_03_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.v2021_03_03_preview.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2021_03_03_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.v2021_03_03_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.v2021_03_03_preview.models.IotHubPropertiesDeviceStreams + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.Capabilities + :keyword encryption: The encryption properties for the IoT hub. + :paramtype encryption: + ~azure.mgmt.iothub.v2021_03_03_preview.models.EncryptionPropertiesDescription + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.public_network_access = public_network_access @@ -1470,8 +1780,8 @@ def __init__( class IotHubPropertiesDeviceStreams(msrest.serialization.Model): """The device streams properties of iothub. - :param streaming_endpoints: List of Device Streams Endpoints. - :type streaming_endpoints: list[str] + :ivar streaming_endpoints: List of Device Streams Endpoints. + :vartype streaming_endpoints: list[str] """ _attribute_map = { @@ -1484,6 +1794,10 @@ def __init__( streaming_endpoints: Optional[List[str]] = None, **kwargs ): + """ + :keyword streaming_endpoints: List of Device Streams Endpoints. + :paramtype streaming_endpoints: list[str] + """ super(IotHubPropertiesDeviceStreams, self).__init__(**kwargs) self.streaming_endpoints = streaming_endpoints @@ -1517,6 +1831,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1528,8 +1844,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1549,6 +1865,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1563,10 +1883,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubCapacity """ _validation = { @@ -1588,6 +1908,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1599,8 +1925,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1620,6 +1946,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1632,15 +1962,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1661,6 +1991,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2021_03_03_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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1672,14 +2010,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1702,6 +2040,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1760,6 +2108,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1776,8 +2126,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1797,6 +2147,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1805,10 +2159,10 @@ def __init__( class KeyVaultKeyProperties(msrest.serialization.Model): """The properties of the KeyVault key. - :param key_identifier: The identifier of the key. - :type key_identifier: str - :param identity: Managed identity properties of KeyVault Key. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :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.v2021_03_03_preview.models.ManagedIdentity """ _attribute_map = { @@ -1823,6 +2177,12 @@ def __init__( identity: Optional["ManagedIdentity"] = None, **kwargs ): + """ + :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.v2021_03_03_preview.models.ManagedIdentity + """ super(KeyVaultKeyProperties, self).__init__(**kwargs) self.key_identifier = key_identifier self.identity = identity @@ -1831,8 +2191,8 @@ def __init__( class ManagedIdentity(msrest.serialization.Model): """The properties of the Managed identity. - :param user_assigned_identity: The user assigned identity. - :type user_assigned_identity: str + :ivar user_assigned_identity: The user assigned identity. + :vartype user_assigned_identity: str """ _attribute_map = { @@ -1845,6 +2205,10 @@ def __init__( user_assigned_identity: Optional[str] = None, **kwargs ): + """ + :keyword user_assigned_identity: The user assigned identity. + :paramtype user_assigned_identity: str + """ super(ManagedIdentity, self).__init__(**kwargs) self.user_assigned_identity = user_assigned_identity @@ -1852,8 +2216,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties """ _attribute_map = { @@ -1866,6 +2230,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1873,16 +2241,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1903,6 +2271,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1912,10 +2292,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1930,6 +2310,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1940,13 +2326,13 @@ class NetworkRuleSetIpRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. Name of the IP filter rule. - :type filter_name: str - :param action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleIPAction - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :ivar filter_name: Required. Name of the IP filter rule. + :vartype filter_name: str + :ivar action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :vartype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleIPAction + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1968,6 +2354,15 @@ def __init__( action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", **kwargs ): + """ + :keyword filter_name: Required. Name of the IP filter rule. + :paramtype filter_name: str + :keyword action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :paramtype action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleIPAction + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(NetworkRuleSetIpRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1979,14 +2374,14 @@ class NetworkRuleSetProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param default_action: Default Action for Network Rule Set. Possible values include: "Deny", + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Deny", "Allow". Default value: "Deny". - :type default_action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.DefaultAction - :param apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also + :vartype default_action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.DefaultAction + :ivar apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also applied to BuiltIn EventHub EndPoint of IotHub. - :type apply_to_built_in_event_hub_endpoint: bool - :param ip_rules: Required. List of IP Rules. - :type ip_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetIpRule] + :vartype apply_to_built_in_event_hub_endpoint: bool + :ivar ip_rules: Required. List of IP Rules. + :vartype ip_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetIpRule] """ _validation = { @@ -2008,6 +2403,16 @@ def __init__( default_action: Optional[Union[str, "DefaultAction"]] = "Deny", **kwargs ): + """ + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Deny", + "Allow". Default value: "Deny". + :paramtype default_action: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.DefaultAction + :keyword apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also + applied to BuiltIn EventHub EndPoint of IotHub. + :paramtype apply_to_built_in_event_hub_endpoint: bool + :keyword ip_rules: Required. List of IP Rules. + :paramtype ip_rules: list[~azure.mgmt.iothub.v2021_03_03_preview.models.NetworkRuleSetIpRule] + """ super(NetworkRuleSetProperties, self).__init__(**kwargs) self.default_action = default_action self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint @@ -2021,8 +2426,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationDisplay """ _validation = { @@ -2040,6 +2445,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2021_03_03_preview.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -2078,6 +2487,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -2090,8 +2501,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -2108,6 +2519,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -2137,6 +2552,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2163,6 +2580,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = None @@ -2180,8 +2599,8 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: + :ivar properties: Required. The properties of a private endpoint connection. + :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnectionProperties """ @@ -2205,6 +2624,11 @@ def __init__( properties: "PrivateEndpointConnectionProperties", **kwargs ): + """ + :keyword properties: Required. The properties of a private endpoint connection. + :paramtype properties: + ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnectionProperties + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.id = None self.name = None @@ -2217,11 +2641,11 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint + :ivar private_endpoint: The private endpoint property of a private endpoint connection. + :vartype private_endpoint: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpoint + :ivar private_link_service_connection_state: Required. The current state of a private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionState """ @@ -2241,6 +2665,14 @@ def __init__( private_endpoint: Optional["PrivateEndpoint"] = None, **kwargs ): + """ + :keyword private_endpoint: The private endpoint property of a private endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpoint + :keyword private_link_service_connection_state: Required. The current state of a private + endpoint connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionState + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -2249,8 +2681,8 @@ def __init__( class PrivateLinkResources(msrest.serialization.Model): """The available private link resources for an IotHub. - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformation] + :ivar value: The list of available private link resources for an IotHub. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformation] """ _attribute_map = { @@ -2263,6 +2695,10 @@ def __init__( value: Optional[List["GroupIdInformation"]] = None, **kwargs ): + """ + :keyword value: The list of available private link resources for an IotHub. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.GroupIdInformation] + """ super(PrivateLinkResources, self).__init__(**kwargs) self.value = value @@ -2272,15 +2708,15 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. The status of a private endpoint connection. Possible values include: + :ivar status: Required. The status of a private endpoint connection. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or + :vartype status: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint + :ivar description: Required. The description for the current state of a private endpoint connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type actions_required: str + :vartype description: str + :ivar actions_required: Actions required for a private endpoint connection. + :vartype actions_required: str """ _validation = { @@ -2302,6 +2738,17 @@ def __init__( actions_required: Optional[str] = None, **kwargs ): + """ + :keyword status: Required. The status of a private endpoint connection. Possible values + include: "Pending", "Approved", "Rejected", "Disconnected". + :paramtype status: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateLinkServiceConnectionStatus + :keyword description: Required. The description for the current state of a private endpoint + connection. + :paramtype description: str + :keyword actions_required: Actions required for a private endpoint connection. + :paramtype actions_required: str + """ super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -2337,6 +2784,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -2346,12 +2795,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorRange """ _attribute_map = { @@ -2368,6 +2817,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorRange + """ super(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -2377,10 +2834,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -2395,6 +2852,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -2403,10 +2866,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition """ _attribute_map = { @@ -2421,6 +2884,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteErrorPosition + """ super(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -2431,24 +2900,23 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2021_03_03_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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -2476,6 +2944,26 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", + "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2021_03_03_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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -2487,20 +2975,21 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: + list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingStorageContainerProperties] """ @@ -2520,6 +3009,24 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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.v2021_03_03_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.v2021_03_03_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.v2021_03_03_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.v2021_03_03_preview.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -2532,29 +3039,29 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or + :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. Possible + values include: "keyBased", "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing event hub endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar identity: Managed identity properties of routing event hub endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -2587,6 +3094,31 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing event hub endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2602,12 +3134,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -2624,6 +3156,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -2633,23 +3173,23 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2021_03_03_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. - :type routes: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2021_03_03_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. - :type fallback_route: ~azure.mgmt.iothub.v2021_03_03_preview.models.FallbackRouteProperties - :param enrichments: The list of user-provided enrichments that the IoT hub applies to messages + :vartype fallback_route: ~azure.mgmt.iothub.v2021_03_03_preview.models.FallbackRouteProperties + :ivar enrichments: The list of user-provided enrichments that the IoT hub applies to messages to be delivered to built-in and custom endpoints. See: https://aka.ms/telemetryoneventgrid. - :type enrichments: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EnrichmentProperties] + :vartype enrichments: list[~azure.mgmt.iothub.v2021_03_03_preview.models.EnrichmentProperties] """ _attribute_map = { @@ -2668,6 +3208,28 @@ def __init__( enrichments: Optional[List["EnrichmentProperties"]] = None, **kwargs ): + """ + :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.v2021_03_03_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.v2021_03_03_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.v2021_03_03_preview.models.FallbackRouteProperties + :keyword enrichments: The list of user-provided enrichments that the IoT hub applies to + messages to be delivered to built-in and custom endpoints. See: + https://aka.ms/telemetryoneventgrid. + :paramtype enrichments: + list[~azure.mgmt.iothub.v2021_03_03_preview.models.EnrichmentProperties] + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -2680,31 +3242,31 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing service bus queue endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar identity: Managed identity properties of routing service bus queue endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -2737,6 +3299,33 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus queue endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2754,31 +3343,31 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing service bus topic endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar identity: Managed identity properties of routing service bus topic endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2811,6 +3400,33 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus topic endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2828,43 +3444,43 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of routing storage endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :ivar identity: Managed identity properties of routing storage endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :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'. Possible values include: "Avro", "AvroDeflate", "JSON". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingStorageContainerPropertiesEncoding """ @@ -2909,6 +3525,46 @@ def __init__( encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType + :keyword identity: Managed identity properties of routing storage endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :keyword name: Required. 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. + :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: Required. The name of storage container in the storage account. + :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'. Possible values include: "Avro", + "AvroDeflate", "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingStorageContainerPropertiesEncoding + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2928,10 +3584,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwinProperties """ _attribute_map = { @@ -2946,6 +3602,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2954,10 +3616,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any + :ivar desired: Twin desired properties. + :vartype desired: any + :ivar reported: Twin desired properties. + :vartype reported: any """ _attribute_map = { @@ -2972,6 +3634,12 @@ def __init__( reported: Optional[Any] = None, **kwargs ): + """ + :keyword desired: Twin desired properties. + :paramtype desired: any + :keyword reported: Twin desired properties. + :paramtype reported: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired = desired self.reported = reported @@ -2982,20 +3650,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AccessRights """ _validation = { @@ -3019,6 +3687,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -3031,8 +3715,8 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: + :ivar value: The list of shared access policies. + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str @@ -3053,6 +3737,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -3063,22 +3752,22 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype container_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for file upload. - :type identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + :ivar identity: Managed identity properties of storage endpoint for file upload. + :vartype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity """ _validation = { @@ -3104,6 +3793,24 @@ def __init__( identity: Optional["ManagedIdentity"] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or + ~azure.mgmt.iothub.v2021_03_03_preview.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for file upload. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_03_preview.models.ManagedIdentity + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -3115,8 +3822,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -3129,6 +3836,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -3136,14 +3847,14 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin + :vartype routing_source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin """ _attribute_map = { @@ -3160,6 +3871,16 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DigitalTwinChangeEvents", "DeviceConnectionStateEvents". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin + """ super(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -3169,8 +3890,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2021_03_03_preview.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2021_03_03_preview.models.MatchedRoute] """ _attribute_map = { @@ -3183,6 +3904,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2021_03_03_preview.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -3192,12 +3917,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage + :ivar route: Required. Route properties. + :vartype route: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin """ _validation = { @@ -3218,6 +3943,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingMessage + :keyword route: Required. Route properties. + :paramtype route: ~azure.mgmt.iothub.v2021_03_03_preview.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2021_03_03_preview.models.RoutingTwin + """ super(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -3227,10 +3960,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :vartype result: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResultDetails """ _attribute_map = { @@ -3245,6 +3978,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "true". + :paramtype result: str or ~azure.mgmt.iothub.v2021_03_03_preview.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2021_03_03_preview.models.TestRouteResultDetails + """ super(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -3253,8 +3993,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2021_03_03_preview.models.RouteCompilationError] """ @@ -3268,6 +4008,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2021_03_03_preview.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -3275,18 +4020,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2021_03_03_preview.models.Name + :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.v2021_03_03_preview.models.Name """ _attribute_map = { @@ -3309,6 +4054,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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.v2021_03_03_preview.models.Name + """ super(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -3323,8 +4082,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -3344,6 +4103,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2021_03_03_preview.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py index fdec24959167..3c50b0af35aa 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -193,7 +429,8 @@ def create_or_update( :param certificate_name: The name of the certificate. :type certificate_name: str :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription + :type certificate_description: + ~azure.mgmt.iothub.v2021_03_03_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. :type if_match: str @@ -207,41 +444,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +480,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +515,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +541,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +574,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +601,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +629,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.CertificateDescription @@ -429,40 +641,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +673,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py index 25a6ba351247..9027f3dc07d6 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_operations.py @@ -5,24 +5,71 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_manual_failover_request_initial( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubOperations(object): """IotHubOperations operations. @@ -48,64 +95,53 @@ def __init__(self, client, config, serializer, deserializer): def _manual_failover_initial( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> None + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace def begin_manual_failover( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **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 @@ -121,15 +157,18 @@ def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2021_03_03_preview.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -141,24 +180,18 @@ def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -170,4 +203,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py index 3f26f763b334..73b364e5d2f0 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_iot_hub_resource_operations.py @@ -5,25 +5,916 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +938,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +963,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +988,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1039,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -197,15 +1069,20 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -218,27 +1095,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -250,47 +1121,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -304,16 +1165,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -326,15 +1189,20 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_03_preview.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -346,27 +1214,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -378,48 +1240,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -435,15 +1286,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -454,15 +1307,20 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescription + or ~azure.mgmt.iothub.v2021_03_03_preview.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -476,24 +1334,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -505,20 +1356,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -526,34 +1380,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -566,23 +1415,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -590,8 +1440,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -599,35 +1451,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -640,24 +1488,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -676,33 +1525,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -711,15 +1550,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -729,8 +1570,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -738,36 +1581,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -780,26 +1620,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -811,8 +1653,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -820,37 +1664,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -863,26 +1705,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -905,35 +1748,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -942,18 +1775,20 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - consumer_group_body, # type: "_models.EventHubConsumerGroupBodyDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + **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. @@ -967,7 +1802,8 @@ def create_event_hub_consumer_group( :param name: The name of the consumer group to add. :type name: str :param consumer_group_body: The consumer group to add. - :type consumer_group_body: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupBodyDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: EventHubConsumerGroupInfo, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.EventHubConsumerGroupInfo @@ -978,40 +1814,30 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1020,17 +1846,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1053,35 +1881,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1089,14 +1907,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1106,8 +1926,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1115,36 +1937,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1157,26 +1976,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1197,34 +2018,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1233,15 +2044,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1251,8 +2064,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1260,36 +2075,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1302,24 +2114,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1329,8 +2142,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1338,36 +2153,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1380,23 +2192,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1414,36 +2227,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1452,16 +2255,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1482,38 +2287,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1522,16 +2317,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1552,38 +2349,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1592,16 +2379,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1611,8 +2401,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1620,36 +2412,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1662,26 +2451,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1702,34 +2493,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1738,17 +2519,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1759,7 +2544,8 @@ def export_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param export_devices_parameters: The parameters that specify the export devices operation. - :type export_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest + :type export_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ExportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse @@ -1770,38 +2556,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1810,17 +2586,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1831,7 +2611,8 @@ def import_devices( :param resource_name: The name of the IoT hub. :type resource_name: str :param import_devices_parameters: The parameters that specify the import devices operation. - :type import_devices_parameters: ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest + :type import_devices_parameters: + ~azure.mgmt.iothub.v2021_03_03_preview.models.ImportDevicesRequest :keyword callable cls: A custom type or function that will be passed the direct response :return: JobResponse, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_03_preview.models.JobResponse @@ -1842,38 +2623,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1882,4 +2653,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py index 81a564b3d1ef..3b53a4a8082f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,16 +72,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_03_preview.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -62,30 +90,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +123,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py index 1dc5cda2d50b..985b8c5e89fb 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_endpoint_connections_operations.py @@ -5,24 +5,182 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -46,13 +204,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> List["_models.PrivateEndpointConnection"]: """List private endpoint connections. List private endpoint connection properties. @@ -71,33 +229,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -106,16 +254,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + 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. @@ -136,34 +286,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -172,56 +312,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -233,17 +363,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. @@ -255,18 +387,24 @@ def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +417,21 @@ def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -312,50 +443,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -368,16 +488,18 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + 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. @@ -390,15 +512,19 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_03_preview.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -413,25 +539,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -443,4 +561,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py index c9505ea2c3fe..b1dfa28d9017 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_private_link_resources_operations.py @@ -5,22 +5,96 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-03-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +118,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResources" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResources": """List private link resources. List private link resources for the given IotHub. @@ -69,33 +143,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -104,16 +168,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupIdInformation" + 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. @@ -134,34 +200,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -170,4 +226,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py index dfaa4e5fb346..632c02b4bc72 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_03_preview/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2021-03-03-preview" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-03-preview" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py index dfcdb45a5fd2..eb8e4bf8ef86 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2021_03_31/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py index f238b0202dea..07f2dfe8d808 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_iot_hub_client.py @@ -6,30 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -37,73 +29,76 @@ class IotHubClient(object): :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2021_03_31.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2021_03_31.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2021_03_31.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2021_03_31.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2021_03_31.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2021_03_31.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2021_03_31.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_31.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2021_03_31.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) - 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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json index 8caa4bfcc7a5..6f4f713265df 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py index 8e0435535d03..90a1a20ea65b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2021_03_31/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py index d852bb7dbc37..26297068135e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_iot_hub_client.py @@ -6,100 +6,100 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +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 -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2021_03_31.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2021_03_31.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2021_03_31.aio.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2021_03_31.aio.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2021_03_31.aio.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2021_03_31.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2021_03_31.aio.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2021_03_31.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2021_03_31.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_03_31.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2021_03_31.aio.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) + - 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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py index 6be8dc807724..2990117af7a5 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py index 6b6e8e4e6609..40b24473ac2d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,45 +58,36 @@ async def _manual_failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, @@ -115,15 +110,18 @@ async def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -135,24 +133,18 @@ async def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -164,4 +156,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py index ce53fec51266..ed5c7b17ad3b 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_31.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription or + ~azure.mgmt.iothub.v2021_03_31.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -951,7 +914,8 @@ async def create_event_hub_consumer_group( :param name: The name of the consumer group to add. :type name: str :param consumer_group_body: The consumer group to add. - :type consumer_group_body: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: EventHubConsumerGroupInfo, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo @@ -962,40 +926,30 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1004,8 +958,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1036,35 +993,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1072,13 +1019,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1088,8 +1038,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1097,36 +1049,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1139,17 +1088,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1157,7 +1108,8 @@ async def get_job( 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. 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. @@ -1178,34 +1130,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1214,8 +1156,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1231,8 +1176,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1240,36 +1187,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1282,17 +1226,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1308,8 +1254,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1317,36 +1265,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1359,17 +1304,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1392,36 +1339,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1430,8 +1367,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1459,38 +1399,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1499,8 +1429,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1528,38 +1461,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1568,15 +1491,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1586,8 +1513,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1595,36 +1524,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1637,17 +1563,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1655,7 +1583,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1676,34 +1605,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1712,8 +1631,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1721,7 +1643,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1743,38 +1667,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1783,8 +1697,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1792,7 +1709,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1814,38 +1733,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1854,4 +1763,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py index baeb94261ee2..f4569de4cc99 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_03_31.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py index 2b3111df0d15..1ee1881b03f4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_endpoint_connections_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -66,33 +71,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -101,8 +96,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -130,34 +128,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -166,8 +154,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, @@ -181,40 +171,29 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -226,8 +205,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -247,18 +229,24 @@ async def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -271,28 +259,21 @@ async def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -304,6 +285,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -318,35 +300,24 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -359,8 +330,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -380,15 +354,19 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -403,25 +381,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -433,4 +403,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py index e29aa7bb7727..3f630cd628b3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_private_link_resources_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -99,8 +94,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -164,4 +152,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py index 67582636977a..43c59958ef8d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py index 1491e763a154..138c7dde883f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/__init__.py @@ -6,170 +6,88 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ArmIdentity - from ._models_py3 import ArmUserIdentity - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import EnrichmentProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupBodyDescription - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupName - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FailoverInput - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import GroupIdInformation - from ._models_py3 import GroupIdInformationProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubLocationDescription - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import ManagedIdentity - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import NetworkRuleSetIpRule - from ._models_py3 import NetworkRuleSetProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionProperties - from ._models_py3 import PrivateLinkResources - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import ArmIdentity # type: ignore - from ._models import ArmUserIdentity # type: ignore - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import EnrichmentProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupBodyDescription # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupName # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FailoverInput # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import GroupIdInformation # type: ignore - from ._models import GroupIdInformationProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubLocationDescription # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import ManagedIdentity # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import NetworkRuleSetIpRule # type: ignore - from ._models import NetworkRuleSetProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionProperties # type: ignore - from ._models import PrivateLinkResources # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import ArmIdentity +from ._models_py3 import ArmUserIdentity +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupBodyDescription +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupName +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import ManagedIdentity +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import NetworkRuleSetIpRule +from ._models_py3 import NetworkRuleSetProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResources +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py index 77789fe60025..9f70b1792da9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,28 +31,28 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies authentication type being used for connecting to the storage account. """ KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class DefaultAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Default Action for Network Rule Set """ DENY = "Deny" ALLOW = "Allow" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -85,14 +70,14 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -101,7 +86,7 @@ class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -109,7 +94,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -121,7 +106,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -129,14 +114,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -147,7 +132,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -162,13 +147,13 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class NetworkRuleIPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """IP Filter Action """ ALLOW = "Allow" -class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of a private endpoint connection """ @@ -177,14 +162,14 @@ class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether requests from Public Network are allowed """ ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -195,14 +180,14 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -213,7 +198,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -222,7 +207,7 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveE AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models.py deleted file mode 100644 index 2c62b6b5bc47..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models.py +++ /dev/null @@ -1,2997 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class ArmIdentity(msrest.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 - :param 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. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.iothub.v2021_03_31.models.ResourceIdentityType - :param user_assigned_identities: Dictionary of :code:``. - :type user_assigned_identities: dict[str, - ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(ArmIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class ArmUserIdentity(msrest.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 - ): - super(ArmUserIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = None - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param 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. Possible values include: "unknown", "healthy", "degraded", - "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthStatus - :param last_known_error: Last error obtained when a message failed to be delivered to iot hub. - :type last_known_error: str - :param last_known_error_time: Time at which the last known error occurred. - :type last_known_error_time: ~datetime.datetime - :param last_successful_send_attempt_time: Last time iot hub successfully sent a message to the - endpoint. - :type last_successful_send_attempt_time: ~datetime.datetime - :param last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. - :type 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, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - self.last_known_error = kwargs.get('last_known_error', None) - self.last_known_error_time = kwargs.get('last_known_error_time', None) - self.last_successful_send_attempt_time = kwargs.get('last_successful_send_attempt_time', None) - self.last_send_attempt_time = kwargs.get('last_send_attempt_time', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EnrichmentProperties(msrest.serialization.Model): - """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. - :type 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, - **kwargs - ): - super(EnrichmentProperties, self).__init__(**kwargs) - self.key = kwargs['key'] - self.value = kwargs['value'] - self.endpoint_names = kwargs['endpoint_names'] - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): - """The EventHub consumer group. - - All required parameters must be populated in order to send to Azure. - - :param properties: Required. The EventHub consumer group name. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupName - """ - - _validation = { - 'properties': {'required': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'EventHubConsumerGroupName'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) - self.properties = kwargs['properties'] - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupName(msrest.serialization.Model): - """The EventHub consumer group name. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. EventHub consumer group name. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupName, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type exclude_keys: bool - :param 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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for export devices. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be exported. - :type include_configurations: bool - :param 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. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - self.export_blob_name = kwargs.get('export_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.include_configurations = kwargs.get('include_configurations', None) - self.configurations_blob_name = kwargs.get('configurations_blob_name', None) - - -class FailoverInput(msrest.serialization.Model): - """Use to provide failover region when requesting manual Failover for a hub. - - All required parameters must be populated in order to send to Azure. - - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str - """ - - _validation = { - 'failover_region': {'required': True}, - } - - _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverInput, self).__init__(**kwargs) - self.failover_region = kwargs['failover_region'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class GroupIdInformation(msrest.serialization.Model): - """The group information for creating a private endpoint on an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(GroupIdInformation, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class GroupIdInformationProperties(msrest.serialization.Model): - """The properties for a group information object. - - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type 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, - **kwargs - ): - super(GroupIdInformationProperties, self).__init__(**kwargs) - self.group_id = kwargs.get('group_id', None) - self.required_members = kwargs.get('required_members', None) - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob - container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for import devices. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be imported. - :type include_configurations: bool - :param configurations_blob_name: The blob name to be used when importing configurations from - the provided input blob container. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - self.input_blob_name = kwargs.get('input_blob_name', None) - self.output_blob_name = kwargs.get('output_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.include_configurations = kwargs.get('include_configurations', None) - self.configurations_blob_name = kwargs.get('configurations_blob_name', None) - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2021_03_31.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo - :param identity: The managed identities for the IotHub. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ArmIdentity - """ - - _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'}, - 'identity': {'key': 'identity', 'type': 'ArmIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - self.identity = kwargs.get('identity', None) - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubLocationDescription(msrest.serialization.Model): - """Public representation of one of the locations where a resource is provisioned. - - :param location: The name of the Azure region. - :type location: str - :param 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. Possible values - include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubReplicaRoleType - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubLocationDescription, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.role = kwargs.get('role', None) - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] - :param public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.iothub.v2021_03_31.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_31.models.IpFilterRule] - :param network_rule_sets: Network Rule Set Properties of IotHub. - :type network_rule_sets: ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleSetProperties - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: - list[~azure.mgmt.iothub.v2021_03_31.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 - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2021_03_31.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2021_03_31.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2021_03_31.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2021_03_31.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2021_03_31.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2021_03_31.models.Capabilities - :ivar locations: Primary and secondary location for iot hub. - :vartype locations: list[~azure.mgmt.iothub.v2021_03_31.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]'}, - '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]'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.public_network_access = kwargs.get('public_network_access', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.network_rule_sets = kwargs.get('network_rule_sets', None) - self.min_tls_version = kwargs.get('min_tls_version', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.features = kwargs.get('features', None) - self.locations = None - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2021_03_31.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2021_03_31.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2021_03_31.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ManagedIdentity(msrest.serialization.Model): - """The properties of the Managed identity. - - :param user_assigned_identity: The user assigned identity. - :type user_assigned_identity: str - """ - - _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedIdentity, self).__init__(**kwargs) - self.user_assigned_identity = kwargs.get('user_assigned_identity', None) - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class NetworkRuleSetIpRule(msrest.serialization.Model): - """IP Rule to be applied as part of Network Rule Set. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. Name of the IP filter rule. - :type filter_name: str - :param action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleIPAction - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(NetworkRuleSetIpRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs.get('action', "Allow") - self.ip_mask = kwargs['ip_mask'] - - -class NetworkRuleSetProperties(msrest.serialization.Model): - """Network Rule Set Properties of IotHub. - - All required parameters must be populated in order to send to Azure. - - :param default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". - :type default_action: str or ~azure.mgmt.iothub.v2021_03_31.models.DefaultAction - :param apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. - :type apply_to_built_in_event_hub_endpoint: bool - :param ip_rules: Required. List of IP Rules. - :type ip_rules: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(NetworkRuleSetProperties, self).__init__(**kwargs) - self.default_action = kwargs.get('default_action', "Deny") - self.apply_to_built_in_event_hub_endpoint = kwargs['apply_to_built_in_event_hub_endpoint'] - self.ip_rules = kwargs['ip_rules'] - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2021_03_31.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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.v2021_03_31.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpoint(msrest.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 - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(msrest.serialization.Model): - """The private endpoint connection of an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class PrivateEndpointConnectionProperties(msrest.serialization.Model): - """The properties of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint - connection. - :type private_link_service_connection_state: - ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs['private_link_service_connection_state'] - - -class PrivateLinkResources(msrest.serialization.Model): - """The available private link resources for an IotHub. - - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResources, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint - connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type 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, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs['description'] - self.actions_required = kwargs.get('actions_required', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorRange - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition - """ - - _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2021_03_31.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2021_03_31.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2021_03_31.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing event hub endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2021_03_31.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2021_03_31.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2021_03_31.models.FallbackRouteProperties - :param 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. - :type enrichments: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - self.enrichments = kwargs.get('enrichments', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing service bus queue endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing service bus topic endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing storage endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". - :type encoding: str or - ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwinProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any - """ - - _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired = kwargs.get('desired', None) - self.reported = kwargs.get('reported', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for file upload. - :type identity: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DeviceConnectionStateEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin - """ - - _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2021_03_31.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2021_03_31.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResultDetails - """ - - _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2021_03_31.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type value: list[~azure.mgmt.iothub.v2021_03_31.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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py index f39ce7fab9f6..8552a0ed37ae 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/models/_models_py3.py @@ -24,13 +24,13 @@ class ArmIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: Tenant Id. :vartype tenant_id: str - :param 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. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.iothub.v2021_03_31.models.ResourceIdentityType - :param user_assigned_identities: Dictionary of :code:``. - :type user_assigned_identities: dict[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. Possible values include: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.iothub.v2021_03_31.models.ResourceIdentityType + :ivar user_assigned_identities: Dictionary of :code:``. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.iothub.v2021_03_31.models.ArmUserIdentity] """ @@ -53,6 +53,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "ArmUserIdentity"]] = None, **kwargs ): + """ + :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. Possible values + include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.iothub.v2021_03_31.models.ResourceIdentityType + :keyword user_assigned_identities: Dictionary of :code:``. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2021_03_31.models.ArmUserIdentity] + """ super(ArmIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -85,6 +95,8 @@ def __init__( self, **kwargs ): + """ + """ super(ArmUserIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -93,9 +105,9 @@ def __init__( class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -108,6 +120,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of the X509 leaf certificate .cer file or just + .pem file content. + :paramtype certificate: str + """ super(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate @@ -117,8 +134,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -150,6 +167,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -161,8 +182,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription] """ _attribute_map = { @@ -175,6 +196,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -196,8 +221,8 @@ class CertificateProperties(msrest.serialization.Model): :vartype created: ~datetime.datetime :ivar updated: The certificate's last update date and time. :vartype updated: ~datetime.datetime - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -225,6 +250,10 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -285,6 +314,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -299,9 +330,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -314,6 +345,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -323,9 +359,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.CertificatePropertiesWithNonce + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -357,6 +393,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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.v2021_03_31.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -368,16 +409,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2021_03_31.models.FeedbackProperties + :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.v2021_03_31.models.FeedbackProperties """ _validation = { @@ -398,6 +439,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2021_03_31.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -407,9 +460,9 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: Health statuses have following meanings. The 'healthy' status shows that + :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 @@ -419,16 +472,16 @@ class EndpointHealthData(msrest.serialization.Model): the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or rejected from this endpoint. Possible values include: "unknown", "healthy", "degraded", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthStatus - :param last_known_error: Last error obtained when a message failed to be delivered to iot hub. - :type last_known_error: str - :param last_known_error_time: Time at which the last known error occurred. - :type last_known_error_time: ~datetime.datetime - :param last_successful_send_attempt_time: Last time iot hub successfully sent a message to the + :vartype health_status: str or ~azure.mgmt.iothub.v2021_03_31.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. - :type last_successful_send_attempt_time: ~datetime.datetime - :param last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. - :type last_send_attempt_time: ~datetime.datetime + :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 = { @@ -451,6 +504,31 @@ def __init__( last_send_attempt_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :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. Possible values include: "unknown", + "healthy", "degraded", "unhealthy", "dead". + :paramtype health_status: str or ~azure.mgmt.iothub.v2021_03_31.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(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -465,8 +543,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthData] + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthData] :ivar next_link: Link to more results. :vartype next_link: str """ @@ -486,6 +564,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -496,13 +578,13 @@ class EnrichmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to + :ivar key: Required. The key or name for the enrichment property. + :vartype key: str + :ivar value: Required. The value for the enrichment property. + :vartype value: str + :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to the message. - :type endpoint_names: list[str] + :vartype endpoint_names: list[str] """ _validation = { @@ -525,6 +607,15 @@ def __init__( endpoint_names: List[str], **kwargs ): + """ + :keyword key: Required. The key or name for the enrichment property. + :paramtype key: str + :keyword value: Required. The value for the enrichment property. + :paramtype value: str + :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to + the message. + :paramtype endpoint_names: list[str] + """ super(EnrichmentProperties, self).__init__(**kwargs) self.key = key self.value = value @@ -564,6 +655,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -576,8 +669,8 @@ class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The EventHub consumer group name. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupName + :ivar properties: Required. The EventHub consumer group name. + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupName """ _validation = { @@ -594,6 +687,10 @@ def __init__( properties: "EventHubConsumerGroupName", **kwargs ): + """ + :keyword properties: Required. The EventHub consumer group name. + :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupName + """ super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) self.properties = properties @@ -603,8 +700,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, any] + :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. @@ -636,6 +733,10 @@ def __init__( properties: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, any] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -649,8 +750,8 @@ class EventHubConsumerGroupName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. EventHub consumer group name. - :type name: str + :ivar name: Required. EventHub consumer group name. + :vartype name: str """ _validation = { @@ -667,6 +768,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. EventHub consumer group name. + :paramtype name: str + """ super(EventHubConsumerGroupName, self).__init__(**kwargs) self.name = name @@ -676,8 +781,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo] + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -697,6 +802,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -707,13 +816,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -743,6 +852,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -756,24 +874,24 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool - :param export_blob_name: The name of the blob that will be created in the provided output blob + :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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype export_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for export devices. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be exported. - :type include_configurations: bool - :param configurations_blob_name: The name of the blob that will be created in the provided + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for export devices. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.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. - :type configurations_blob_name: str + :vartype configurations_blob_name: str """ _validation = { @@ -803,6 +921,28 @@ def __init__( configurations_blob_name: Optional[str] = None, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for export devices. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.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(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -818,8 +958,8 @@ class FailoverInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str + :ivar failover_region: Required. Region the hub will be failed over to. + :vartype failover_region: str """ _validation = { @@ -836,6 +976,10 @@ def __init__( failover_region: str, **kwargs ): + """ + :keyword failover_region: Required. Region the hub will be failed over to. + :paramtype failover_region: str + """ super(FailoverInput, self).__init__(**kwargs) self.failover_region = failover_region @@ -845,22 +989,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2021_03_31.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -887,6 +1031,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2021_03_31.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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -898,17 +1061,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -929,6 +1092,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -948,8 +1124,8 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformationProperties + :ivar properties: Required. The properties for a group information object. + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformationProperties """ _validation = { @@ -972,6 +1148,10 @@ def __init__( properties: "GroupIdInformationProperties", **kwargs ): + """ + :keyword properties: Required. The properties for a group information object. + :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformationProperties + """ super(GroupIdInformation, self).__init__(**kwargs) self.id = None self.name = None @@ -982,12 +1162,12 @@ def __init__( class GroupIdInformationProperties(msrest.serialization.Model): """The properties for a group information object. - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type required_zone_names: list[str] + :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 = { @@ -1004,6 +1184,14 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :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(GroupIdInformationProperties, self).__init__(**kwargs) self.group_id = group_id self.required_members = required_members @@ -1015,25 +1203,25 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str + :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for import devices. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be imported. - :type include_configurations: bool - :param configurations_blob_name: The blob name to be used when importing configurations from - the provided input blob container. - :type configurations_blob_name: str + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for import devices. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.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 = { @@ -1065,6 +1253,28 @@ def __init__( configurations_blob_name: Optional[str] = None, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for import devices. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.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(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -1110,6 +1320,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -1130,10 +1342,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1158,6 +1370,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1179,19 +1397,19 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo - :param identity: The managed identities for the IotHub. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ArmIdentity + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo + :ivar identity: The managed identities for the IotHub. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ArmIdentity """ _validation = { @@ -1225,6 +1443,21 @@ def __init__( identity: Optional["ArmIdentity"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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.v2021_03_31.models.IotHubProperties + :keyword sku: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo + :keyword identity: The managed identities for the IotHub. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ArmIdentity + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -1237,8 +1470,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1258,6 +1491,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1266,13 +1503,13 @@ def __init__( class IotHubLocationDescription(msrest.serialization.Model): """Public representation of one of the locations where a resource is provisioned. - :param location: The name of the Azure region. - :type location: str - :param role: The role of the region, can be either primary or secondary. The primary region is + :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. Possible values include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubReplicaRoleType + :vartype role: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubReplicaRoleType """ _attribute_map = { @@ -1287,6 +1524,15 @@ def __init__( role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, **kwargs ): + """ + :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. Possible + values include: "primary", "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubReplicaRoleType + """ super(IotHubLocationDescription, self).__init__(**kwargs) self.location = location self.role = role @@ -1302,8 +1548,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -1323,6 +1569,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -1334,22 +1584,23 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :ivar public_network_access: Whether requests from Public Network are allowed. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.iothub.v2021_03_31.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_31.models.IpFilterRule] - :param network_rule_sets: Network Rule Set Properties of IotHub. - :type network_rule_sets: ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleSetProperties - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: + :vartype public_network_access: str or + ~azure.mgmt.iothub.v2021_03_31.models.PublicNetworkAccess + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_31.models.IpFilterRule] + :ivar network_rule_sets: Network Rule Set Properties of IotHub. + :vartype network_rule_sets: ~azure.mgmt.iothub.v2021_03_31.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.v2021_03_31.models.PrivateEndpointConnection] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1357,33 +1608,34 @@ class IotHubProperties(msrest.serialization.Model): :vartype state: str :ivar host_name: The name of the host. :vartype host_name: str - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2021_03_31.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :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.v2021_03_31.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2021_03_31.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2021_03_31.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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2021_03_31.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2021_03_31.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2021_03_31.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2021_03_31.models.Capabilities + :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.v2021_03_31.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2021_03_31.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubLocationDescription] """ @@ -1435,6 +1687,54 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] + :keyword public_network_access: Whether requests from Public Network are allowed. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothub.v2021_03_31.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2021_03_31.models.IpFilterRule] + :keyword network_rule_sets: Network Rule Set Properties of IotHub. + :paramtype network_rule_sets: ~azure.mgmt.iothub.v2021_03_31.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.v2021_03_31.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.v2021_03_31.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.v2021_03_31.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.v2021_03_31.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2021_03_31.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.v2021_03_31.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2021_03_31.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.public_network_access = public_network_access @@ -1485,6 +1785,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1496,8 +1798,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1517,6 +1819,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1531,10 +1837,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2021_03_31.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2021_03_31.models.IotHubCapacity """ _validation = { @@ -1556,6 +1862,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2021_03_31.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1567,8 +1879,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1588,6 +1900,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1600,15 +1916,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1629,6 +1945,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2021_03_31.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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1640,14 +1964,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2021_03_31.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2021_03_31.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1670,6 +1994,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2021_03_31.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1728,6 +2062,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1744,8 +2080,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1765,6 +2101,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1773,8 +2113,8 @@ def __init__( class ManagedIdentity(msrest.serialization.Model): """The properties of the Managed identity. - :param user_assigned_identity: The user assigned identity. - :type user_assigned_identity: str + :ivar user_assigned_identity: The user assigned identity. + :vartype user_assigned_identity: str """ _attribute_map = { @@ -1787,6 +2127,10 @@ def __init__( user_assigned_identity: Optional[str] = None, **kwargs ): + """ + :keyword user_assigned_identity: The user assigned identity. + :paramtype user_assigned_identity: str + """ super(ManagedIdentity, self).__init__(**kwargs) self.user_assigned_identity = user_assigned_identity @@ -1794,8 +2138,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties """ _attribute_map = { @@ -1808,6 +2152,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1815,16 +2163,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1845,6 +2193,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1854,10 +2214,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1872,6 +2232,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1882,13 +2248,13 @@ class NetworkRuleSetIpRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. Name of the IP filter rule. - :type filter_name: str - :param action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleIPAction - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :ivar filter_name: Required. Name of the IP filter rule. + :vartype filter_name: str + :ivar action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :vartype action: str or ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleIPAction + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1910,6 +2276,15 @@ def __init__( action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", **kwargs ): + """ + :keyword filter_name: Required. Name of the IP filter rule. + :paramtype filter_name: str + :keyword action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :paramtype action: str or ~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleIPAction + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(NetworkRuleSetIpRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1921,14 +2296,14 @@ class NetworkRuleSetProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param default_action: Default Action for Network Rule Set. Possible values include: "Deny", + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Deny", "Allow". Default value: "Deny". - :type default_action: str or ~azure.mgmt.iothub.v2021_03_31.models.DefaultAction - :param apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also + :vartype default_action: str or ~azure.mgmt.iothub.v2021_03_31.models.DefaultAction + :ivar apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also applied to BuiltIn EventHub EndPoint of IotHub. - :type apply_to_built_in_event_hub_endpoint: bool - :param ip_rules: Required. List of IP Rules. - :type ip_rules: list[~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleSetIpRule] + :vartype apply_to_built_in_event_hub_endpoint: bool + :ivar ip_rules: Required. List of IP Rules. + :vartype ip_rules: list[~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleSetIpRule] """ _validation = { @@ -1950,6 +2325,16 @@ def __init__( default_action: Optional[Union[str, "DefaultAction"]] = "Deny", **kwargs ): + """ + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Deny", + "Allow". Default value: "Deny". + :paramtype default_action: str or ~azure.mgmt.iothub.v2021_03_31.models.DefaultAction + :keyword apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also + applied to BuiltIn EventHub EndPoint of IotHub. + :paramtype apply_to_built_in_event_hub_endpoint: bool + :keyword ip_rules: Required. List of IP Rules. + :paramtype ip_rules: list[~azure.mgmt.iothub.v2021_03_31.models.NetworkRuleSetIpRule] + """ super(NetworkRuleSetProperties, self).__init__(**kwargs) self.default_action = default_action self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint @@ -1963,8 +2348,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2021_03_31.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2021_03_31.models.OperationDisplay """ _validation = { @@ -1982,6 +2367,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2021_03_31.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -2020,6 +2409,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -2032,8 +2423,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -2050,6 +2441,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -2079,6 +2474,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2105,6 +2502,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = None @@ -2122,8 +2521,8 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnectionProperties + :ivar properties: Required. The properties of a private endpoint connection. + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnectionProperties """ _validation = { @@ -2146,6 +2545,11 @@ def __init__( properties: "PrivateEndpointConnectionProperties", **kwargs ): + """ + :keyword properties: Required. The properties of a private endpoint connection. + :paramtype properties: + ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnectionProperties + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.id = None self.name = None @@ -2158,11 +2562,11 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint + :ivar private_endpoint: The private endpoint property of a private endpoint connection. + :vartype private_endpoint: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpoint + :ivar private_link_service_connection_state: Required. The current state of a private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionState """ @@ -2182,6 +2586,14 @@ def __init__( private_endpoint: Optional["PrivateEndpoint"] = None, **kwargs ): + """ + :keyword private_endpoint: The private endpoint property of a private endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpoint + :keyword private_link_service_connection_state: Required. The current state of a private + endpoint connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionState + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -2190,8 +2602,8 @@ def __init__( class PrivateLinkResources(msrest.serialization.Model): """The available private link resources for an IotHub. - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformation] + :ivar value: The list of available private link resources for an IotHub. + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformation] """ _attribute_map = { @@ -2204,6 +2616,10 @@ def __init__( value: Optional[List["GroupIdInformation"]] = None, **kwargs ): + """ + :keyword value: The list of available private link resources for an IotHub. + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.GroupIdInformation] + """ super(PrivateLinkResources, self).__init__(**kwargs) self.value = value @@ -2213,14 +2629,15 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. The status of a private endpoint connection. Possible values include: + :ivar status: Required. The status of a private endpoint connection. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint + :vartype status: str or + ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionStatus + :ivar description: Required. The description for the current state of a private endpoint connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type actions_required: str + :vartype description: str + :ivar actions_required: Actions required for a private endpoint connection. + :vartype actions_required: str """ _validation = { @@ -2242,6 +2659,17 @@ def __init__( actions_required: Optional[str] = None, **kwargs ): + """ + :keyword status: Required. The status of a private endpoint connection. Possible values + include: "Pending", "Approved", "Rejected", "Disconnected". + :paramtype status: str or + ~azure.mgmt.iothub.v2021_03_31.models.PrivateLinkServiceConnectionStatus + :keyword description: Required. The description for the current state of a private endpoint + connection. + :paramtype description: str + :keyword actions_required: Actions required for a private endpoint connection. + :paramtype actions_required: str + """ super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -2277,6 +2705,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -2286,12 +2716,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorRange """ _attribute_map = { @@ -2308,6 +2738,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorRange + """ super(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -2317,10 +2755,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -2335,6 +2773,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -2343,10 +2787,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition """ _attribute_map = { @@ -2361,6 +2805,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2021_03_31.models.RouteErrorPosition + """ super(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -2371,23 +2821,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2021_03_31.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -2415,6 +2864,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2021_03_31.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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -2426,20 +2894,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2021_03_31.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2021_03_31.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2021_03_31.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: list[~azure.mgmt.iothub.v2021_03_31.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2021_03_31.models.RoutingStorageContainerProperties] """ @@ -2459,6 +2927,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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.v2021_03_31.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.v2021_03_31.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.v2021_03_31.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.v2021_03_31.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -2471,28 +2956,28 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing event hub endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :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. Possible + values include: "keyBased", "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :ivar identity: Managed identity properties of routing event hub endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -2525,6 +3010,30 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :keyword identity: Managed identity properties of routing event hub endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2540,12 +3049,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -2562,6 +3071,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -2571,23 +3088,23 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2021_03_31.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2021_03_31.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. - :type routes: list[~azure.mgmt.iothub.v2021_03_31.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2021_03_31.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. - :type fallback_route: ~azure.mgmt.iothub.v2021_03_31.models.FallbackRouteProperties - :param enrichments: The list of user-provided enrichments that the IoT hub applies to messages + :vartype fallback_route: ~azure.mgmt.iothub.v2021_03_31.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. - :type enrichments: list[~azure.mgmt.iothub.v2021_03_31.models.EnrichmentProperties] + :vartype enrichments: list[~azure.mgmt.iothub.v2021_03_31.models.EnrichmentProperties] """ _attribute_map = { @@ -2606,6 +3123,26 @@ def __init__( enrichments: Optional[List["EnrichmentProperties"]] = None, **kwargs ): + """ + :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.v2021_03_31.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.v2021_03_31.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.v2021_03_31.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.v2021_03_31.models.EnrichmentProperties] + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -2618,30 +3155,30 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing service bus queue endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus queue endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -2674,6 +3211,32 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus queue endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2691,30 +3254,30 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing service bus topic endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus topic endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2747,6 +3310,32 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus topic endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2764,42 +3353,42 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of routing storage endpoint. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :ivar identity: Managed identity properties of routing storage endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :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'. Possible values include: "Avro", "AvroDeflate", "JSON". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingStorageContainerPropertiesEncoding """ @@ -2844,6 +3433,45 @@ def __init__( encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :keyword identity: Managed identity properties of routing storage endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :keyword name: Required. 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. + :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: Required. The name of storage container in the storage account. + :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'. Possible values include: "Avro", + "AvroDeflate", "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2021_03_31.models.RoutingStorageContainerPropertiesEncoding + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2863,10 +3491,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwinProperties """ _attribute_map = { @@ -2881,6 +3509,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2889,10 +3523,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any + :ivar desired: Twin desired properties. + :vartype desired: any + :ivar reported: Twin desired properties. + :vartype reported: any """ _attribute_map = { @@ -2907,6 +3541,12 @@ def __init__( reported: Optional[Any] = None, **kwargs ): + """ + :keyword desired: Twin desired properties. + :paramtype desired: any + :keyword reported: Twin desired properties. + :paramtype reported: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired = desired self.reported = reported @@ -2917,20 +3557,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2021_03_31.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2021_03_31.models.AccessRights """ _validation = { @@ -2954,6 +3594,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2021_03_31.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -2966,8 +3622,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -2987,6 +3644,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -2997,21 +3659,21 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype container_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for file upload. - :type identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for file upload. + :vartype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity """ _validation = { @@ -3037,6 +3699,23 @@ def __init__( identity: Optional["ManagedIdentity"] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_03_31.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for file upload. + :paramtype identity: ~azure.mgmt.iothub.v2021_03_31.models.ManagedIdentity + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -3048,8 +3727,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -3062,6 +3741,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -3069,14 +3752,14 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin + :vartype routing_source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin """ _attribute_map = { @@ -3093,6 +3776,16 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DeviceConnectionStateEvents". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2021_03_31.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin + """ super(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -3102,8 +3795,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2021_03_31.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2021_03_31.models.MatchedRoute] """ _attribute_map = { @@ -3116,6 +3809,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2021_03_31.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -3125,12 +3822,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage + :ivar route: Required. Route properties. + :vartype route: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin """ _validation = { @@ -3151,6 +3848,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2021_03_31.models.RoutingMessage + :keyword route: Required. Route properties. + :paramtype route: ~azure.mgmt.iothub.v2021_03_31.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2021_03_31.models.RoutingTwin + """ super(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -3160,10 +3865,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2021_03_31.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :vartype result: str or ~azure.mgmt.iothub.v2021_03_31.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResultDetails """ _attribute_map = { @@ -3178,6 +3883,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "true". + :paramtype result: str or ~azure.mgmt.iothub.v2021_03_31.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2021_03_31.models.TestRouteResultDetails + """ super(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -3186,8 +3898,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2021_03_31.models.RouteCompilationError] + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2021_03_31.models.RouteCompilationError] """ _attribute_map = { @@ -3200,6 +3912,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2021_03_31.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -3207,18 +3924,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2021_03_31.models.Name + :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.v2021_03_31.models.Name """ _attribute_map = { @@ -3241,6 +3958,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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.v2021_03_31.models.Name + """ super(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -3255,8 +3986,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2021_03_31.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2021_03_31.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -3276,6 +4007,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2021_03_31.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py index b51addabf293..a63605265f24 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_03_31.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py index 42dc351fc990..7a246268e179 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_operations.py @@ -5,24 +5,71 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_manual_failover_request_initial( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubOperations(object): """IotHubOperations operations. @@ -48,64 +95,53 @@ def __init__(self, client, config, serializer, deserializer): def _manual_failover_initial( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> None + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace def begin_manual_failover( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **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 @@ -121,15 +157,18 @@ def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2021_03_31.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -141,24 +180,18 @@ def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -170,4 +203,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py index 5892b4dffa1e..a13d67f3a4d4 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_iot_hub_resource_operations.py @@ -5,25 +5,916 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +938,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +963,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +988,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1039,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +1071,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +1096,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +1122,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1166,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1190,19 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2021_03_31.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1214,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1240,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1286,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1307,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescription + or ~azure.mgmt.iothub.v2021_03_31.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1333,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1355,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1379,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1414,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1439,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1450,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1487,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1524,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1549,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1569,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1580,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1619,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1652,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1663,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1704,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1747,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,18 +1774,20 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - consumer_group_body, # type: "_models.EventHubConsumerGroupBodyDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + **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. @@ -969,7 +1801,8 @@ def create_event_hub_consumer_group( :param name: The name of the consumer group to add. :type name: str :param consumer_group_body: The consumer group to add. - :type consumer_group_body: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupBodyDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: EventHubConsumerGroupInfo, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_03_31.models.EventHubConsumerGroupInfo @@ -980,40 +1813,30 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1022,17 +1845,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1055,35 +1880,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1091,14 +1906,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1108,8 +1925,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1117,36 +1936,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1159,26 +1975,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1199,34 +2017,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1235,15 +2043,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1253,8 +2063,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1262,36 +2074,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1304,24 +2113,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1331,8 +2141,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1340,36 +2152,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1382,23 +2191,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1416,36 +2226,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1454,16 +2254,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1484,38 +2286,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1524,16 +2316,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1554,38 +2348,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1594,16 +2378,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1613,8 +2400,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_03_31.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1622,36 +2411,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1664,26 +2450,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1704,34 +2492,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1740,17 +2518,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1772,38 +2554,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1812,17 +2584,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1844,38 +2620,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1884,4 +2650,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py index 6d9901ad5fb0..b9655bb17722 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2021_03_31/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py index 985f2660a5c5..c89a3fa451e1 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_endpoint_connections_operations.py @@ -5,24 +5,182 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -46,13 +204,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> List["_models.PrivateEndpointConnection"]: """List private endpoint connections. List private endpoint connection properties. @@ -71,33 +229,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -106,16 +254,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + 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. @@ -136,34 +286,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -172,56 +312,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -233,17 +363,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. @@ -255,18 +387,24 @@ def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +417,21 @@ def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -312,50 +443,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -368,16 +488,18 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + 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. @@ -390,15 +512,19 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_03_31.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -413,25 +539,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -443,4 +561,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py index 9c7893e23b63..e1cb8e6e05ae 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_private_link_resources_operations.py @@ -5,22 +5,96 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-03-31" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +118,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResources" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResources": """List private link resources. List private link resources for the given IotHub. @@ -69,33 +143,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -104,16 +168,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupIdInformation" + 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. @@ -134,34 +200,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -170,4 +226,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py index aeef2ede9af0..342b58062354 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_03_31/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2021-03-31" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-03-31" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py index 8883d8041fab..a9adde0a702d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotHubClient'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py index 16d86d588306..73456830f012 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class IotHubClientConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(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/v2021_07_01/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py index f8d1369a548c..2808835450c2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_iot_hub_client.py @@ -6,30 +6,22 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import IotHubClientConfiguration +from .operations import CertificatesOperations, IotHubOperations, IotHubResourceOperations, Operations, PrivateEndpointConnectionsOperations, PrivateLinkResourcesOperations, ResourceProviderCommonOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from . import models - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations @@ -37,73 +29,76 @@ class IotHubClient(object): :ivar iot_hub_resource: IotHubResourceOperations operations :vartype iot_hub_resource: azure.mgmt.iothub.v2021_07_01.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2021_07_01.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2021_07_01.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2021_07_01.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2021_07_01.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2021_07_01.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2021_07_01.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_07_01.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2021_07_01.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) - 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) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json index 35497d20c61e..bfae722cc4d2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_metadata.json @@ -5,13 +5,13 @@ "name": "IotHubClient", "filename": "_iot_hub_client", "description": "Use this API to manage the IoT hubs in your Azure subscription.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"HttpRequest\", \"HttpResponse\"]}}}", - "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"IotHubClientConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "operations": "Operations", diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py index 83f24ab50946..e5754a47ce68 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0" +VERSION = "1.0.0b1" diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py index a84cf700a930..28356865df6a 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_hub_client import IotHubClient __all__ = ['IotHubClient'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py index 535240e2770a..749606420966 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotHubClientConfiguration, self).__init__(**kwargs) 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.") - super(IotHubClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(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/v2021_07_01/aio/_iot_hub_client.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py index a390aadace03..8f17427a881d 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_iot_hub_client.py @@ -6,100 +6,100 @@ # 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 -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +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 -from ._configuration import IotHubClientConfiguration -from .operations import Operations -from .operations import IotHubResourceOperations -from .operations import ResourceProviderCommonOperations -from .operations import CertificatesOperations -from .operations import IotHubOperations -from .operations import PrivateLinkResourcesOperations -from .operations import PrivateEndpointConnectionsOperations -from .. import models - - -class IotHubClient(object): +class IotHubClient: """Use this API to manage the IoT hubs in your Azure subscription. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothub.v2021_07_01.aio.operations.Operations :ivar iot_hub_resource: IotHubResourceOperations operations - :vartype iot_hub_resource: azure.mgmt.iothub.v2021_07_01.aio.operations.IotHubResourceOperations + :vartype iot_hub_resource: + azure.mgmt.iothub.v2021_07_01.aio.operations.IotHubResourceOperations :ivar resource_provider_common: ResourceProviderCommonOperations operations - :vartype resource_provider_common: azure.mgmt.iothub.v2021_07_01.aio.operations.ResourceProviderCommonOperations + :vartype resource_provider_common: + azure.mgmt.iothub.v2021_07_01.aio.operations.ResourceProviderCommonOperations :ivar certificates: CertificatesOperations operations :vartype certificates: azure.mgmt.iothub.v2021_07_01.aio.operations.CertificatesOperations :ivar iot_hub: IotHubOperations operations :vartype iot_hub: azure.mgmt.iothub.v2021_07_01.aio.operations.IotHubOperations :ivar private_link_resources: PrivateLinkResourcesOperations operations - :vartype private_link_resources: azure.mgmt.iothub.v2021_07_01.aio.operations.PrivateLinkResourcesOperations + :vartype private_link_resources: + azure.mgmt.iothub.v2021_07_01.aio.operations.PrivateLinkResourcesOperations :ivar private_endpoint_connections: PrivateEndpointConnectionsOperations operations - :vartype private_endpoint_connections: azure.mgmt.iothub.v2021_07_01.aio.operations.PrivateEndpointConnectionsOperations + :vartype private_endpoint_connections: + azure.mgmt.iothub.v2021_07_01.aio.operations.PrivateEndpointConnectionsOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The subscription identifier. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: 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: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = IotHubClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotHubClientConfiguration(credential=credential, subscription_id=subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} self._serialize = Serializer(client_models) - self._serialize.client_side_validation = False 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) + - 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) - - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> 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/python/protocol/quickstart + + :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.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_patch.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/_patch.py @@ -0,0 +1,31 @@ +# 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. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py index 65d17b636757..86d212e2ad00 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_certificates_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._certificates_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_by_iot_hub_request, build_verify_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list_by_iot_hub( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -99,8 +94,11 @@ async def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -164,8 +152,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -200,41 +191,30 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -247,8 +227,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -279,35 +262,25 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -315,6 +288,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, resource_group_name: str, @@ -346,35 +321,25 @@ async def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -383,8 +348,11 @@ async def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify( self, resource_group_name: str, @@ -408,7 +376,8 @@ async def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription @@ -419,40 +388,30 @@ async def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -461,4 +420,6 @@ async def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py index a894031b3087..09e4828d3b27 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_operations import build_manual_failover_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -54,45 +58,36 @@ async def _manual_failover_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace_async async def begin_manual_failover( self, iot_hub_name: str, @@ -115,15 +110,18 @@ async def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -135,24 +133,18 @@ async def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -164,4 +156,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py index cb7cb62ba5cb..0c0227544837 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_iot_hub_resource_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._iot_hub_resource_operations import build_check_name_availability_request, build_create_event_hub_consumer_group_request, build_create_or_update_request_initial, build_delete_event_hub_consumer_group_request, build_delete_request_initial, 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_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -67,33 +73,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -102,8 +98,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -117,41 +115,29 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -163,8 +149,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -192,15 +181,20 @@ async def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -213,27 +207,21 @@ async def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -245,6 +233,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _update_initial( @@ -259,32 +248,22 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(iot_hub_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -298,8 +277,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -319,15 +301,20 @@ async def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_01.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of + cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -339,27 +326,21 @@ async def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -371,6 +352,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore async def _delete_initial( @@ -384,34 +366,23 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -427,8 +398,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -445,15 +419,20 @@ async def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either IotHubDescription or ErrorDetails or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription or + ~azure.mgmt.iothub.v2021_07_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -467,24 +446,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -496,8 +468,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -507,8 +481,10 @@ def list_by_subscription( Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -516,34 +492,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -556,17 +527,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -579,8 +552,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -588,35 +563,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -629,17 +600,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace_async async def get_stats( self, resource_group_name: str, @@ -664,33 +637,23 @@ async def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -699,8 +662,11 @@ async def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, resource_group_name: str, @@ -716,8 +682,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -725,36 +693,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -767,17 +732,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, resource_group_name: str, @@ -785,7 +752,8 @@ def list_event_hub_consumer_groups( event_hub_endpoint_name: str, **kwargs: Any ) -> AsyncIterable["_models.EventHubConsumerGroupsListResult"]: - """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. Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. @@ -797,8 +765,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -806,37 +776,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -849,17 +817,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace_async async def get_event_hub_consumer_group( self, resource_group_name: str, @@ -890,35 +860,25 @@ async def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -927,8 +887,11 @@ async def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def create_event_hub_consumer_group( self, resource_group_name: str, @@ -951,7 +914,8 @@ async def create_event_hub_consumer_group( :param name: The name of the consumer group to add. :type name: str :param consumer_group_body: The consumer group to add. - :type consumer_group_body: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: EventHubConsumerGroupInfo, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo @@ -962,40 +926,30 @@ async def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1004,8 +958,11 @@ async def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace_async async def delete_event_hub_consumer_group( self, resource_group_name: str, @@ -1036,35 +993,25 @@ async def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1072,13 +1019,16 @@ async def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.JobResponseListResult"]: - """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. 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. @@ -1088,8 +1038,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1097,36 +1049,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1139,17 +1088,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace_async async def get_job( self, resource_group_name: str, @@ -1157,7 +1108,8 @@ async def get_job( 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. 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. @@ -1178,34 +1130,24 @@ async def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1214,8 +1156,11 @@ async def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, resource_group_name: str, @@ -1231,8 +1176,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1240,36 +1187,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1282,17 +1226,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, resource_group_name: str, @@ -1308,8 +1254,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1317,36 +1265,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1359,17 +1304,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace_async async def check_name_availability( self, operation_inputs: "_models.OperationInputs", @@ -1392,36 +1339,26 @@ async def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1430,8 +1367,11 @@ async def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace_async async def test_all_routes( self, iot_hub_name: str, @@ -1459,38 +1399,28 @@ async def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1499,8 +1429,11 @@ async def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace_async async def test_route( self, iot_hub_name: str, @@ -1528,38 +1461,28 @@ async def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1568,15 +1491,19 @@ async def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, resource_group_name: str, resource_name: str, **kwargs: Any ) -> AsyncIterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: - """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. Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. @@ -1586,8 +1513,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1595,36 +1524,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1637,17 +1563,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace_async async def get_keys_for_key_name( self, resource_group_name: str, @@ -1655,7 +1583,8 @@ async def get_keys_for_key_name( 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. 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. @@ -1676,34 +1605,24 @@ async def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1712,8 +1631,11 @@ async def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def export_devices( self, resource_group_name: str, @@ -1721,7 +1643,9 @@ async def export_devices( export_devices_parameters: "_models.ExportDevicesRequest", **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. Exports all the device identities in the IoT hub identity registry to an Azure Storage blob container. For more information, see: @@ -1743,38 +1667,28 @@ async def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1783,8 +1697,11 @@ async def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace_async async def import_devices( self, resource_group_name: str, @@ -1792,7 +1709,9 @@ async def import_devices( import_devices_parameters: "_models.ImportDevicesRequest", **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. Import, update, or delete device identities in the IoT hub identity registry from a blob. For more information, see: @@ -1814,38 +1733,28 @@ async def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1854,4 +1763,6 @@ async def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py index df02361d4cf2..810279931319 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothub.v2021_07_01.models.OperationListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationListResult"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py index f97b00f7b2f3..7bfb227702fe 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_endpoint_connections_operations.py @@ -5,18 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_endpoint_connections_operations import build_delete_request_initial, build_get_request, build_list_request, build_update_request_initial T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -42,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -66,33 +71,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -101,8 +96,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -130,34 +128,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -166,8 +154,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _update_initial( self, resource_group_name: str, @@ -181,40 +171,29 @@ async def _update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -226,8 +205,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -247,18 +229,24 @@ async def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -271,28 +259,21 @@ async def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -304,6 +285,7 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_initial( @@ -318,35 +300,24 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -359,8 +330,11 @@ async def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -380,15 +354,19 @@ async def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either PrivateEndpointConnection or the + result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -403,25 +381,17 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -433,4 +403,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py index 51a0aec9cc56..2969ebe9ef94 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_private_link_resources_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._private_link_resources_operations import build_get_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, resource_group_name: str, @@ -64,33 +69,23 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -99,8 +94,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -128,34 +126,24 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -164,4 +152,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py index 0b0852664095..cecb59652ea7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/aio/operations/_resource_provider_common_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._resource_provider_common_operations import build_get_subscription_quota_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_subscription_quota( self, **kwargs: Any @@ -58,31 +63,21 @@ async def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -91,4 +86,6 @@ async def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py index 1491e763a154..138c7dde883f 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/__init__.py @@ -6,170 +6,88 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ArmIdentity - from ._models_py3 import ArmUserIdentity - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificatePropertiesWithNonce - from ._models_py3 import CertificateVerificationDescription - from ._models_py3 import CertificateWithNonceDescription - from ._models_py3 import CloudToDeviceProperties - from ._models_py3 import EndpointHealthData - from ._models_py3 import EndpointHealthDataListResult - from ._models_py3 import EnrichmentProperties - from ._models_py3 import ErrorDetails - from ._models_py3 import EventHubConsumerGroupBodyDescription - from ._models_py3 import EventHubConsumerGroupInfo - from ._models_py3 import EventHubConsumerGroupName - from ._models_py3 import EventHubConsumerGroupsListResult - from ._models_py3 import EventHubProperties - from ._models_py3 import ExportDevicesRequest - from ._models_py3 import FailoverInput - from ._models_py3 import FallbackRouteProperties - from ._models_py3 import FeedbackProperties - from ._models_py3 import GroupIdInformation - from ._models_py3 import GroupIdInformationProperties - from ._models_py3 import ImportDevicesRequest - from ._models_py3 import IotHubCapacity - from ._models_py3 import IotHubDescription - from ._models_py3 import IotHubDescriptionListResult - from ._models_py3 import IotHubLocationDescription - from ._models_py3 import IotHubNameAvailabilityInfo - from ._models_py3 import IotHubProperties - from ._models_py3 import IotHubQuotaMetricInfo - from ._models_py3 import IotHubQuotaMetricInfoListResult - from ._models_py3 import IotHubSkuDescription - from ._models_py3 import IotHubSkuDescriptionListResult - from ._models_py3 import IotHubSkuInfo - from ._models_py3 import IpFilterRule - from ._models_py3 import JobResponse - from ._models_py3 import JobResponseListResult - from ._models_py3 import ManagedIdentity - from ._models_py3 import MatchedRoute - from ._models_py3 import MessagingEndpointProperties - from ._models_py3 import Name - from ._models_py3 import NetworkRuleSetIpRule - from ._models_py3 import NetworkRuleSetProperties - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationInputs - from ._models_py3 import OperationListResult - from ._models_py3 import PrivateEndpoint - from ._models_py3 import PrivateEndpointConnection - from ._models_py3 import PrivateEndpointConnectionProperties - from ._models_py3 import PrivateLinkResources - from ._models_py3 import PrivateLinkServiceConnectionState - from ._models_py3 import RegistryStatistics - from ._models_py3 import Resource - from ._models_py3 import RouteCompilationError - from ._models_py3 import RouteErrorPosition - from ._models_py3 import RouteErrorRange - from ._models_py3 import RouteProperties - from ._models_py3 import RoutingEndpoints - from ._models_py3 import RoutingEventHubProperties - from ._models_py3 import RoutingMessage - from ._models_py3 import RoutingProperties - from ._models_py3 import RoutingServiceBusQueueEndpointProperties - from ._models_py3 import RoutingServiceBusTopicEndpointProperties - from ._models_py3 import RoutingStorageContainerProperties - from ._models_py3 import RoutingTwin - from ._models_py3 import RoutingTwinProperties - from ._models_py3 import SharedAccessSignatureAuthorizationRule - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import StorageEndpointProperties - from ._models_py3 import TagsResource - from ._models_py3 import TestAllRoutesInput - from ._models_py3 import TestAllRoutesResult - from ._models_py3 import TestRouteInput - from ._models_py3 import TestRouteResult - from ._models_py3 import TestRouteResultDetails - from ._models_py3 import UserSubscriptionQuota - from ._models_py3 import UserSubscriptionQuotaListResult -except (SyntaxError, ImportError): - from ._models import ArmIdentity # type: ignore - from ._models import ArmUserIdentity # type: ignore - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificatePropertiesWithNonce # type: ignore - from ._models import CertificateVerificationDescription # type: ignore - from ._models import CertificateWithNonceDescription # type: ignore - from ._models import CloudToDeviceProperties # type: ignore - from ._models import EndpointHealthData # type: ignore - from ._models import EndpointHealthDataListResult # type: ignore - from ._models import EnrichmentProperties # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import EventHubConsumerGroupBodyDescription # type: ignore - from ._models import EventHubConsumerGroupInfo # type: ignore - from ._models import EventHubConsumerGroupName # type: ignore - from ._models import EventHubConsumerGroupsListResult # type: ignore - from ._models import EventHubProperties # type: ignore - from ._models import ExportDevicesRequest # type: ignore - from ._models import FailoverInput # type: ignore - from ._models import FallbackRouteProperties # type: ignore - from ._models import FeedbackProperties # type: ignore - from ._models import GroupIdInformation # type: ignore - from ._models import GroupIdInformationProperties # type: ignore - from ._models import ImportDevicesRequest # type: ignore - from ._models import IotHubCapacity # type: ignore - from ._models import IotHubDescription # type: ignore - from ._models import IotHubDescriptionListResult # type: ignore - from ._models import IotHubLocationDescription # type: ignore - from ._models import IotHubNameAvailabilityInfo # type: ignore - from ._models import IotHubProperties # type: ignore - from ._models import IotHubQuotaMetricInfo # type: ignore - from ._models import IotHubQuotaMetricInfoListResult # type: ignore - from ._models import IotHubSkuDescription # type: ignore - from ._models import IotHubSkuDescriptionListResult # type: ignore - from ._models import IotHubSkuInfo # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import JobResponse # type: ignore - from ._models import JobResponseListResult # type: ignore - from ._models import ManagedIdentity # type: ignore - from ._models import MatchedRoute # type: ignore - from ._models import MessagingEndpointProperties # type: ignore - from ._models import Name # type: ignore - from ._models import NetworkRuleSetIpRule # type: ignore - from ._models import NetworkRuleSetProperties # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationInputs # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import PrivateEndpoint # type: ignore - from ._models import PrivateEndpointConnection # type: ignore - from ._models import PrivateEndpointConnectionProperties # type: ignore - from ._models import PrivateLinkResources # type: ignore - from ._models import PrivateLinkServiceConnectionState # type: ignore - from ._models import RegistryStatistics # type: ignore - from ._models import Resource # type: ignore - from ._models import RouteCompilationError # type: ignore - from ._models import RouteErrorPosition # type: ignore - from ._models import RouteErrorRange # type: ignore - from ._models import RouteProperties # type: ignore - from ._models import RoutingEndpoints # type: ignore - from ._models import RoutingEventHubProperties # type: ignore - from ._models import RoutingMessage # type: ignore - from ._models import RoutingProperties # type: ignore - from ._models import RoutingServiceBusQueueEndpointProperties # type: ignore - from ._models import RoutingServiceBusTopicEndpointProperties # type: ignore - from ._models import RoutingStorageContainerProperties # type: ignore - from ._models import RoutingTwin # type: ignore - from ._models import RoutingTwinProperties # type: ignore - from ._models import SharedAccessSignatureAuthorizationRule # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import StorageEndpointProperties # type: ignore - from ._models import TagsResource # type: ignore - from ._models import TestAllRoutesInput # type: ignore - from ._models import TestAllRoutesResult # type: ignore - from ._models import TestRouteInput # type: ignore - from ._models import TestRouteResult # type: ignore - from ._models import TestRouteResultDetails # type: ignore - from ._models import UserSubscriptionQuota # type: ignore - from ._models import UserSubscriptionQuotaListResult # type: ignore +from ._models_py3 import ArmIdentity +from ._models_py3 import ArmUserIdentity +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificatePropertiesWithNonce +from ._models_py3 import CertificateVerificationDescription +from ._models_py3 import CertificateWithNonceDescription +from ._models_py3 import CloudToDeviceProperties +from ._models_py3 import EndpointHealthData +from ._models_py3 import EndpointHealthDataListResult +from ._models_py3 import EnrichmentProperties +from ._models_py3 import ErrorDetails +from ._models_py3 import EventHubConsumerGroupBodyDescription +from ._models_py3 import EventHubConsumerGroupInfo +from ._models_py3 import EventHubConsumerGroupName +from ._models_py3 import EventHubConsumerGroupsListResult +from ._models_py3 import EventHubProperties +from ._models_py3 import ExportDevicesRequest +from ._models_py3 import FailoverInput +from ._models_py3 import FallbackRouteProperties +from ._models_py3 import FeedbackProperties +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import ImportDevicesRequest +from ._models_py3 import IotHubCapacity +from ._models_py3 import IotHubDescription +from ._models_py3 import IotHubDescriptionListResult +from ._models_py3 import IotHubLocationDescription +from ._models_py3 import IotHubNameAvailabilityInfo +from ._models_py3 import IotHubProperties +from ._models_py3 import IotHubQuotaMetricInfo +from ._models_py3 import IotHubQuotaMetricInfoListResult +from ._models_py3 import IotHubSkuDescription +from ._models_py3 import IotHubSkuDescriptionListResult +from ._models_py3 import IotHubSkuInfo +from ._models_py3 import IpFilterRule +from ._models_py3 import JobResponse +from ._models_py3 import JobResponseListResult +from ._models_py3 import ManagedIdentity +from ._models_py3 import MatchedRoute +from ._models_py3 import MessagingEndpointProperties +from ._models_py3 import Name +from ._models_py3 import NetworkRuleSetIpRule +from ._models_py3 import NetworkRuleSetProperties +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationInputs +from ._models_py3 import OperationListResult +from ._models_py3 import PrivateEndpoint +from ._models_py3 import PrivateEndpointConnection +from ._models_py3 import PrivateEndpointConnectionProperties +from ._models_py3 import PrivateLinkResources +from ._models_py3 import PrivateLinkServiceConnectionState +from ._models_py3 import RegistryStatistics +from ._models_py3 import Resource +from ._models_py3 import RouteCompilationError +from ._models_py3 import RouteErrorPosition +from ._models_py3 import RouteErrorRange +from ._models_py3 import RouteProperties +from ._models_py3 import RoutingEndpoints +from ._models_py3 import RoutingEventHubProperties +from ._models_py3 import RoutingMessage +from ._models_py3 import RoutingProperties +from ._models_py3 import RoutingServiceBusQueueEndpointProperties +from ._models_py3 import RoutingServiceBusTopicEndpointProperties +from ._models_py3 import RoutingStorageContainerProperties +from ._models_py3 import RoutingTwin +from ._models_py3 import RoutingTwinProperties +from ._models_py3 import SharedAccessSignatureAuthorizationRule +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import StorageEndpointProperties +from ._models_py3 import TagsResource +from ._models_py3 import TestAllRoutesInput +from ._models_py3 import TestAllRoutesResult +from ._models_py3 import TestRouteInput +from ._models_py3 import TestRouteResult +from ._models_py3 import TestRouteResultDetails +from ._models_py3 import UserSubscriptionQuota +from ._models_py3 import UserSubscriptionQuotaListResult + from ._iot_hub_client_enums import ( AccessRights, diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py index 77789fe60025..9f70b1792da9 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_iot_hub_client_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRights(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The permissions assigned to the shared access policy. """ @@ -46,28 +31,28 @@ class AccessRights(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryWrite, ServiceConnect, DeviceConnect" REGISTRY_READ_REGISTRY_WRITE_SERVICE_CONNECT_DEVICE_CONNECT = "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect" -class AuthenticationType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AuthenticationType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies authentication type being used for connecting to the storage account. """ KEY_BASED = "keyBased" IDENTITY_BASED = "identityBased" -class Capabilities(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Capabilities(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The capabilities and features enabled for the IoT hub. """ NONE = "None" DEVICE_MANAGEMENT = "DeviceManagement" -class DefaultAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DefaultAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Default Action for Network Rule Set """ DENY = "Deny" ALLOW = "Allow" -class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class EndpointHealthStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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 @@ -85,14 +70,14 @@ class EndpointHealthStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): UNHEALTHY = "unhealthy" DEAD = "dead" -class IotHubNameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubNameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The reason for unavailability. """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubReplicaRoleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -101,7 +86,7 @@ class IotHubReplicaRoleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)) PRIMARY = "primary" SECONDARY = "secondary" -class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubScaleType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the scaling enabled. """ @@ -109,7 +94,7 @@ class IotHubScaleType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANUAL = "Manual" NONE = "None" -class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The name of the SKU. """ @@ -121,7 +106,7 @@ class IotHubSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): B2 = "B2" B3 = "B3" -class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IotHubSkuTier(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The billing tier for the IoT hub. """ @@ -129,14 +114,14 @@ class IotHubSkuTier(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): STANDARD = "Standard" BASIC = "Basic" -class IpFilterActionType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterActionType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The desired action for requests captured by this rule. """ ACCEPT = "Accept" REJECT = "Reject" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of the job. """ @@ -147,7 +132,7 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "failed" CANCELLED = "cancelled" -class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of the job. """ @@ -162,13 +147,13 @@ class JobType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FACTORY_RESET_DEVICE = "factoryResetDevice" FIRMWARE_UPDATE = "firmwareUpdate" -class NetworkRuleIPAction(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NetworkRuleIPAction(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """IP Filter Action """ ALLOW = "Allow" -class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of a private endpoint connection """ @@ -177,14 +162,14 @@ class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta REJECTED = "Rejected" DISCONNECTED = "Disconnected" -class PublicNetworkAccess(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PublicNetworkAccess(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether requests from Public Network are allowed """ ENABLED = "Enabled" DISABLED = "Disabled" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """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. @@ -195,14 +180,14 @@ class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SYSTEM_ASSIGNED_USER_ASSIGNED = "SystemAssigned, UserAssigned" NONE = "None" -class RouteErrorSeverity(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RouteErrorSeverity(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Severity of the route error """ ERROR = "error" WARNING = "warning" -class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingSource(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The source that the routing rule is to be applied to, such as DeviceMessages. """ @@ -213,7 +198,7 @@ class RoutingSource(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEVICE_JOB_LIFECYCLE_EVENTS = "DeviceJobLifecycleEvents" DEVICE_CONNECTION_STATE_EVENTS = "DeviceConnectionStateEvents" -class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RoutingStorageContainerPropertiesEncoding(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Encoding that is used to serialize messages to blobs. Supported values are 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. """ @@ -222,7 +207,7 @@ class RoutingStorageContainerPropertiesEncoding(with_metaclass(_CaseInsensitiveE AVRO_DEFLATE = "AvroDeflate" JSON = "JSON" -class TestResultStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TestResultStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Result of testing route """ diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models.py deleted file mode 100644 index 4f074f1b0a30..000000000000 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models.py +++ /dev/null @@ -1,3026 +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.core.exceptions import HttpResponseError -import msrest.serialization - - -class ArmIdentity(msrest.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 - :param 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. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.iothub.v2021_07_01.models.ResourceIdentityType - :param user_assigned_identities: Dictionary of :code:``. - :type user_assigned_identities: dict[str, - ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(ArmIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - self.user_assigned_identities = kwargs.get('user_assigned_identities', None) - - -class ArmUserIdentity(msrest.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 - ): - super(ArmUserIdentity, self).__init__(**kwargs) - self.principal_id = None - self.client_id = None - - -class CertificateBodyDescription(msrest.serialization.Model): - """The JSON-serialized X509 Certificate. - - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem - file content. - :type certificate: str - :param is_verified: True indicates that the certificate will be created in verified state and - proof of possession will not be required. - :type is_verified: bool - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateBodyDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - self.is_verified = kwargs.get('is_verified', None) - - -class CertificateDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(CertificateDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateListDescription, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class CertificateProperties(msrest.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 - :param is_verified: Determines whether certificate has been verified. - :type 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 - :param certificate: The certificate content. - :type 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, - **kwargs - ): - super(CertificateProperties, self).__init__(**kwargs) - self.subject = None - self.expiry = None - self.thumbprint = None - self.is_verified = kwargs.get('is_verified', None) - self.created = None - self.updated = None - self.certificate = kwargs.get('certificate', None) - - -class CertificatePropertiesWithNonce(msrest.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 - ): - super(CertificatePropertiesWithNonce, self).__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(msrest.serialization.Model): - """The JSON-serialized leaf certificate. - - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: str - """ - - _attribute_map = { - 'certificate': {'key': 'certificate', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(CertificateVerificationDescription, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class CertificateWithNonceDescription(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The description of an X509 CA Certificate including the challenge nonce - issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(CertificateWithNonceDescription, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = None - - -class CloudToDeviceProperties(msrest.serialization.Model): - """The IoT hub cloud-to-device messaging properties. - - :param 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. - :type max_delivery_count: int - :param 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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(CloudToDeviceProperties, self).__init__(**kwargs) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - self.default_ttl_as_iso8601 = kwargs.get('default_ttl_as_iso8601', None) - self.feedback = kwargs.get('feedback', None) - - -class EndpointHealthData(msrest.serialization.Model): - """The health data for an endpoint. - - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param 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. Possible values include: "unknown", "healthy", "degraded", - "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthStatus - :param last_known_error: Last error obtained when a message failed to be delivered to iot hub. - :type last_known_error: str - :param last_known_error_time: Time at which the last known error occurred. - :type last_known_error_time: ~datetime.datetime - :param last_successful_send_attempt_time: Last time iot hub successfully sent a message to the - endpoint. - :type last_successful_send_attempt_time: ~datetime.datetime - :param last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. - :type 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, - **kwargs - ): - super(EndpointHealthData, self).__init__(**kwargs) - self.endpoint_id = kwargs.get('endpoint_id', None) - self.health_status = kwargs.get('health_status', None) - self.last_known_error = kwargs.get('last_known_error', None) - self.last_known_error_time = kwargs.get('last_known_error_time', None) - self.last_successful_send_attempt_time = kwargs.get('last_successful_send_attempt_time', None) - self.last_send_attempt_time = kwargs.get('last_send_attempt_time', None) - - -class EndpointHealthDataListResult(msrest.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. - - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(EndpointHealthDataListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EnrichmentProperties(msrest.serialization.Model): - """The properties of an enrichment that your IoT hub applies to messages delivered to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to - the message. - :type 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, - **kwargs - ): - super(EnrichmentProperties, self).__init__(**kwargs) - self.key = kwargs['key'] - self.value = kwargs['value'] - self.endpoint_names = kwargs['endpoint_names'] - - -class ErrorDetails(msrest.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 - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = None - self.http_status_code = None - self.message = None - self.details = None - - -class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): - """The EventHub consumer group. - - All required parameters must be populated in order to send to Azure. - - :param properties: Required. The EventHub consumer group name. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupName - """ - - _validation = { - 'properties': {'required': True}, - } - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'EventHubConsumerGroupName'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) - self.properties = kwargs['properties'] - - -class EventHubConsumerGroupInfo(msrest.serialization.Model): - """The properties of the EventHubConsumerGroupInfo object. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: The tags. - :type 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, - **kwargs - ): - super(EventHubConsumerGroupInfo, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.type = None - self.etag = None - - -class EventHubConsumerGroupName(msrest.serialization.Model): - """The EventHub consumer group name. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. EventHub consumer group name. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(EventHubConsumerGroupName, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class EventHubConsumerGroupsListResult(msrest.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. - - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class EventHubProperties(msrest.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. - - :param 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. - :type retention_time_in_days: long - :param 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. - :type 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': 'long'}, - '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, - **kwargs - ): - super(EventHubProperties, self).__init__(**kwargs) - self.retention_time_in_days = kwargs.get('retention_time_in_days', None) - self.partition_count = kwargs.get('partition_count', None) - self.partition_ids = None - self.path = None - self.endpoint = None - - -class ExportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an export of all devices in the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during - export. - :type exclude_keys: bool - :param 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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for export devices. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be exported. - :type include_configurations: bool - :param 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. - :type 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, - **kwargs - ): - super(ExportDevicesRequest, self).__init__(**kwargs) - self.export_blob_container_uri = kwargs['export_blob_container_uri'] - self.exclude_keys = kwargs['exclude_keys'] - self.export_blob_name = kwargs.get('export_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.include_configurations = kwargs.get('include_configurations', None) - self.configurations_blob_name = kwargs.get('configurations_blob_name', None) - - -class FailoverInput(msrest.serialization.Model): - """Use to provide failover region when requesting manual Failover for a hub. - - All required parameters must be populated in order to send to Azure. - - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str - """ - - _validation = { - 'failover_region': {'required': True}, - } - - _attribute_map = { - 'failover_region': {'key': 'failoverRegion', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(FailoverInput, self).__init__(**kwargs) - self.failover_region = kwargs['failover_region'] - - -class FallbackRouteProperties(msrest.serialization.Model): - """The properties of the fallback route. IoT Hub uses these properties when it routes messages to the fallback endpoint. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the - condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type 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, - **kwargs - ): - super(FallbackRouteProperties, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class FeedbackProperties(msrest.serialization.Model): - """The properties of the feedback queue for cloud-to-device messages. - - :param 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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(FeedbackProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class GroupIdInformation(msrest.serialization.Model): - """The group information for creating a private endpoint on an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(GroupIdInformation, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class GroupIdInformationProperties(msrest.serialization.Model): - """The properties for a group information object. - - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type 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, - **kwargs - ): - super(GroupIdInformationProperties, self).__init__(**kwargs) - self.group_id = kwargs.get('group_id', None) - self.required_members = kwargs.get('required_members', None) - self.required_zone_names = kwargs.get('required_zone_names', None) - - -class ImportDevicesRequest(msrest.serialization.Model): - """Use to provide parameters when requesting an import of all devices in the hub. - - All required parameters must be populated in order to send to Azure. - - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob - container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for import devices. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be imported. - :type include_configurations: bool - :param configurations_blob_name: The blob name to be used when importing configurations from - the provided input blob container. - :type 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, - **kwargs - ): - super(ImportDevicesRequest, self).__init__(**kwargs) - self.input_blob_container_uri = kwargs['input_blob_container_uri'] - self.output_blob_container_uri = kwargs['output_blob_container_uri'] - self.input_blob_name = kwargs.get('input_blob_name', None) - self.output_blob_name = kwargs.get('output_blob_name', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.include_configurations = kwargs.get('include_configurations', None) - self.configurations_blob_name = kwargs.get('configurations_blob_name', None) - - -class IotHubCapacity(msrest.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: long - :ivar maximum: The maximum number of units. - :vartype maximum: long - :ivar default: The default number of units. - :vartype default: long - :ivar scale_type: The type of the scaling enabled. Possible values include: "Automatic", - "Manual", "None". - :vartype scale_type: str or ~azure.mgmt.iothub.v2021_07_01.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': 'long'}, - 'maximum': {'key': 'maximum', 'type': 'long'}, - 'default': {'key': 'default', 'type': 'long'}, - 'scale_type': {'key': 'scaleType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubCapacity, self).__init__(**kwargs) - self.minimum = None - self.maximum = None - self.default = None - self.scale_type = None - - -class Resource(msrest.serialization.Model): - """The common properties of an Azure resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type 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, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.location = kwargs['location'] - self.tags = kwargs.get('tags', None) - - -class IotHubDescription(Resource): - """The description of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo - :param identity: The managed identities for the IotHub. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ArmIdentity - """ - - _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'}, - 'identity': {'key': 'identity', 'type': 'ArmIdentity'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs.get('properties', None) - self.sku = kwargs['sku'] - self.identity = kwargs.get('identity', None) - - -class IotHubDescriptionListResult(msrest.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. - - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(IotHubDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubLocationDescription(msrest.serialization.Model): - """Public representation of one of the locations where a resource is provisioned. - - :param location: The name of the Azure region. - :type location: str - :param 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. Possible values - include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubReplicaRoleType - """ - - _attribute_map = { - 'location': {'key': 'location', 'type': 'str'}, - 'role': {'key': 'role', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubLocationDescription, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.role = kwargs.get('role', None) - - -class IotHubNameAvailabilityInfo(msrest.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. Possible values include: "Invalid", - "AlreadyExists". - :vartype reason: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type 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, - **kwargs - ): - super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = None - self.reason = None - self.message = kwargs.get('message', None) - - -class IotHubProperties(msrest.serialization.Model): - """The properties of an IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param authorization_policies: The shared access policies you can use to secure a connection to - the IoT hub. - :type authorization_policies: - list[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] - :param disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for - authentication. - :type disable_local_auth: bool - :param disable_device_sas: If true, all device(including Edge devices but excluding modules) - scoped SAS keys cannot be used for authentication. - :type disable_device_sas: bool - :param disable_module_sas: If true, all module scoped SAS keys cannot be used for - authentication. - :type disable_module_sas: bool - :param restrict_outbound_network_access: If true, egress from IotHub will be restricted to only - the allowed FQDNs that are configured via allowedFqdnList. - :type restrict_outbound_network_access: bool - :param allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from - Iot Hub. - :type allowed_fqdn_list: list[str] - :param public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.iothub.v2021_07_01.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2021_07_01.models.IpFilterRule] - :param network_rule_sets: Network Rule Set Properties of IotHub. - :type network_rule_sets: ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleSetProperties - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: - list[~azure.mgmt.iothub.v2021_07_01.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 - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2021_07_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2021_07_01.models.RoutingProperties - :param 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. - :type storage_endpoints: dict[str, - ~azure.mgmt.iothub.v2021_07_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification - queue. - :type messaging_endpoints: dict[str, - ~azure.mgmt.iothub.v2021_07_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2021_07_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2021_07_01.models.Capabilities - :ivar locations: Primary and secondary location for iot hub. - :vartype locations: list[~azure.mgmt.iothub.v2021_07_01.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]'}, - '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]'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubProperties, self).__init__(**kwargs) - self.authorization_policies = kwargs.get('authorization_policies', None) - self.disable_local_auth = kwargs.get('disable_local_auth', None) - self.disable_device_sas = kwargs.get('disable_device_sas', None) - self.disable_module_sas = kwargs.get('disable_module_sas', None) - self.restrict_outbound_network_access = kwargs.get('restrict_outbound_network_access', None) - self.allowed_fqdn_list = kwargs.get('allowed_fqdn_list', None) - self.public_network_access = kwargs.get('public_network_access', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.network_rule_sets = kwargs.get('network_rule_sets', None) - self.min_tls_version = kwargs.get('min_tls_version', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - self.provisioning_state = None - self.state = None - self.host_name = None - self.event_hub_endpoints = kwargs.get('event_hub_endpoints', None) - self.routing = kwargs.get('routing', None) - self.storage_endpoints = kwargs.get('storage_endpoints', None) - self.messaging_endpoints = kwargs.get('messaging_endpoints', None) - self.enable_file_upload_notifications = kwargs.get('enable_file_upload_notifications', None) - self.cloud_to_device = kwargs.get('cloud_to_device', None) - self.comments = kwargs.get('comments', None) - self.features = kwargs.get('features', None) - self.locations = None - - -class IotHubQuotaMetricInfo(msrest.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: long - :ivar max_value: The maximum value of the quota metric. - :vartype max_value: long - """ - - _validation = { - 'name': {'readonly': True}, - 'current_value': {'readonly': True}, - 'max_value': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'current_value': {'key': 'currentValue', 'type': 'long'}, - 'max_value': {'key': 'maxValue', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubQuotaMetricInfo, self).__init__(**kwargs) - self.name = None - self.current_value = None - self.max_value = None - - -class IotHubQuotaMetricInfoListResult(msrest.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. - - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuDescription(msrest.serialization.Model): - """SKU properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar resource_type: The type of the resource. - :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(IotHubSkuDescription, self).__init__(**kwargs) - self.resource_type = None - self.sku = kwargs['sku'] - self.capacity = kwargs['capacity'] - - -class IotHubSkuDescriptionListResult(msrest.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. - - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotHubSkuInfo(msrest.serialization.Model): - """Information about the SKU of the IoT hub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", - "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSku - :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", - "Basic". - :vartype tier: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: - https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long - """ - - _validation = { - 'name': {'required': True}, - 'tier': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'tier': {'key': 'tier', 'type': 'str'}, - 'capacity': {'key': 'capacity', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubSkuInfo, self).__init__(**kwargs) - self.name = kwargs['name'] - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for the IoT hub. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values - include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2021_07_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(IpFilterRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs['action'] - self.ip_mask = kwargs['ip_mask'] - - -class JobResponse(msrest.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. Possible values include: "unknown", "export", "import", - "backup", "readDeviceProperties", "writeDeviceProperties", "updateDeviceConfiguration", - "rebootDevice", "factoryResetDevice", "firmwareUpdate". - :vartype type: str or ~azure.mgmt.iothub.v2021_07_01.models.JobType - :ivar status: The status of the job. Possible values include: "unknown", "enqueued", "running", - "completed", "failed", "cancelled". - :vartype status: str or ~azure.mgmt.iothub.v2021_07_01.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 - ): - super(JobResponse, self).__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(msrest.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. - - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(JobResponseListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class ManagedIdentity(msrest.serialization.Model): - """The properties of the Managed identity. - - :param user_assigned_identity: The user assigned identity. - :type user_assigned_identity: str - """ - - _attribute_map = { - 'user_assigned_identity': {'key': 'userAssignedIdentity', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ManagedIdentity, self).__init__(**kwargs) - self.user_assigned_identity = kwargs.get('user_assigned_identity', None) - - -class MatchedRoute(msrest.serialization.Model): - """Routes that matched. - - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties - """ - - _attribute_map = { - 'properties': {'key': 'properties', 'type': 'RouteProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(MatchedRoute, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - - -class MessagingEndpointProperties(msrest.serialization.Model): - """The properties of the messaging endpoints used by this IoT hub. - - :param lock_duration_as_iso8601: The lock duration. See: - https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param 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. - :type ttl_as_iso8601: ~datetime.timedelta - :param 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. - :type 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, - **kwargs - ): - super(MessagingEndpointProperties, self).__init__(**kwargs) - self.lock_duration_as_iso8601 = kwargs.get('lock_duration_as_iso8601', None) - self.ttl_as_iso8601 = kwargs.get('ttl_as_iso8601', None) - self.max_delivery_count = kwargs.get('max_delivery_count', None) - - -class Name(msrest.serialization.Model): - """Name of Iot Hub type. - - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - 'localized_value': {'key': 'localizedValue', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Name, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.localized_value = kwargs.get('localized_value', None) - - -class NetworkRuleSetIpRule(msrest.serialization.Model): - """IP Rule to be applied as part of Network Rule Set. - - All required parameters must be populated in order to send to Azure. - - :param filter_name: Required. Name of the IP filter rule. - :type filter_name: str - :param action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleIPAction - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type 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, - **kwargs - ): - super(NetworkRuleSetIpRule, self).__init__(**kwargs) - self.filter_name = kwargs['filter_name'] - self.action = kwargs.get('action', "Allow") - self.ip_mask = kwargs['ip_mask'] - - -class NetworkRuleSetProperties(msrest.serialization.Model): - """Network Rule Set Properties of IotHub. - - All required parameters must be populated in order to send to Azure. - - :param default_action: Default Action for Network Rule Set. Possible values include: "Deny", - "Allow". Default value: "Deny". - :type default_action: str or ~azure.mgmt.iothub.v2021_07_01.models.DefaultAction - :param apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also - applied to BuiltIn EventHub EndPoint of IotHub. - :type apply_to_built_in_event_hub_endpoint: bool - :param ip_rules: Required. List of IP Rules. - :type ip_rules: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(NetworkRuleSetProperties, self).__init__(**kwargs) - self.default_action = kwargs.get('default_action', "Deny") - self.apply_to_built_in_event_hub_endpoint = kwargs['apply_to_built_in_event_hub_endpoint'] - self.ip_rules = kwargs['ip_rules'] - - -class Operation(msrest.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 - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2021_07_01.models.OperationDisplay - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.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 - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class OperationInputs(msrest.serialization.Model): - """Input values. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the IoT hub to check. - :type name: str - """ - - _validation = { - 'name': {'required': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInputs, self).__init__(**kwargs) - self.name = kwargs['name'] - - -class OperationListResult(msrest.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.v2021_07_01.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 - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = None - self.next_link = None - - -class PrivateEndpoint(msrest.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 - ): - super(PrivateEndpoint, self).__init__(**kwargs) - self.id = None - - -class PrivateEndpointConnection(msrest.serialization.Model): - """The private endpoint connection of an IotHub. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: The resource identifier. - :vartype id: str - :ivar name: The resource name. - :vartype name: str - :ivar type: The resource type. - :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(PrivateEndpointConnection, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.properties = kwargs['properties'] - - -class PrivateEndpointConnectionProperties(msrest.serialization.Model): - """The properties of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint - connection. - :type private_link_service_connection_state: - ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) - self.private_endpoint = kwargs.get('private_endpoint', None) - self.private_link_service_connection_state = kwargs['private_link_service_connection_state'] - - -class PrivateLinkResources(msrest.serialization.Model): - """The available private link resources for an IotHub. - - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[GroupIdInformation]'}, - } - - def __init__( - self, - **kwargs - ): - super(PrivateLinkResources, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class PrivateLinkServiceConnectionState(msrest.serialization.Model): - """The current state of a private endpoint connection. - - All required parameters must be populated in order to send to Azure. - - :param status: Required. The status of a private endpoint connection. Possible values include: - "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint - connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type 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, - **kwargs - ): - super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) - self.status = kwargs['status'] - self.description = kwargs['description'] - self.actions_required = kwargs.get('actions_required', None) - - -class RegistryStatistics(msrest.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: long - :ivar enabled_device_count: The count of enabled devices in the identity registry. - :vartype enabled_device_count: long - :ivar disabled_device_count: The count of disabled devices in the identity registry. - :vartype disabled_device_count: long - """ - - _validation = { - 'total_device_count': {'readonly': True}, - 'enabled_device_count': {'readonly': True}, - 'disabled_device_count': {'readonly': True}, - } - - _attribute_map = { - 'total_device_count': {'key': 'totalDeviceCount', 'type': 'long'}, - 'enabled_device_count': {'key': 'enabledDeviceCount', 'type': 'long'}, - 'disabled_device_count': {'key': 'disabledDeviceCount', 'type': 'long'}, - } - - def __init__( - self, - **kwargs - ): - super(RegistryStatistics, self).__init__(**kwargs) - self.total_device_count = None - self.enabled_device_count = None - self.disabled_device_count = None - - -class RouteCompilationError(msrest.serialization.Model): - """Compilation error when evaluating route. - - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorRange - """ - - _attribute_map = { - 'message': {'key': 'message', 'type': 'str'}, - 'severity': {'key': 'severity', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'RouteErrorRange'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteCompilationError, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.severity = kwargs.get('severity', None) - self.location = kwargs.get('location', None) - - -class RouteErrorPosition(msrest.serialization.Model): - """Position where the route error happened. - - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int - """ - - _attribute_map = { - 'line': {'key': 'line', 'type': 'int'}, - 'column': {'key': 'column', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorPosition, self).__init__(**kwargs) - self.line = kwargs.get('line', None) - self.column = kwargs.get('column', None) - - -class RouteErrorRange(msrest.serialization.Model): - """Range of route errors. - - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition - """ - - _attribute_map = { - 'start': {'key': 'start', 'type': 'RouteErrorPosition'}, - 'end': {'key': 'end', 'type': 'RouteErrorPosition'}, - } - - def __init__( - self, - **kwargs - ): - super(RouteErrorRange, self).__init__(**kwargs) - self.start = kwargs.get('start', None) - self.end = kwargs.get('end', None) - - -class RouteProperties(msrest.serialization.Model): - """The properties of a routing rule that your IoT hub uses to route messages to endpoints. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as - DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", - "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource - :param 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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the - condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type 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, - **kwargs - ): - super(RouteProperties, self).__init__(**kwargs) - self.name = kwargs['name'] - self.source = kwargs['source'] - self.condition = kwargs.get('condition', None) - self.endpoint_names = kwargs['endpoint_names'] - self.is_enabled = kwargs['is_enabled'] - - -class RoutingEndpoints(msrest.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. - - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the - messages to, based on the routing rules. - :type service_bus_queues: - list[~azure.mgmt.iothub.v2021_07_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the - messages to, based on the routing rules. - :type service_bus_topics: - list[~azure.mgmt.iothub.v2021_07_01.models.RoutingServiceBusTopicEndpointProperties] - :param 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. - :type event_hubs: list[~azure.mgmt.iothub.v2021_07_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages - to, based on the routing rules. - :type storage_containers: - list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(RoutingEndpoints, self).__init__(**kwargs) - self.service_bus_queues = kwargs.get('service_bus_queues', None) - self.service_bus_topics = kwargs.get('service_bus_topics', None) - self.event_hubs = kwargs.get('event_hubs', None) - self.storage_containers = kwargs.get('storage_containers', None) - - -class RoutingEventHubProperties(msrest.serialization.Model): - """The properties related to an event hub endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing event hub endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type 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, - **kwargs - ): - super(RoutingEventHubProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingMessage(msrest.serialization.Model): - """Routing message. - - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type 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, - **kwargs - ): - super(RoutingMessage, self).__init__(**kwargs) - self.body = kwargs.get('body', None) - self.app_properties = kwargs.get('app_properties', None) - self.system_properties = kwargs.get('system_properties', None) - - -class RoutingProperties(msrest.serialization.Model): - """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - - :param 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. - :type endpoints: ~azure.mgmt.iothub.v2021_07_01.models.RoutingEndpoints - :param 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. - :type routes: list[~azure.mgmt.iothub.v2021_07_01.models.RouteProperties] - :param 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. - :type fallback_route: ~azure.mgmt.iothub.v2021_07_01.models.FallbackRouteProperties - :param 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. - :type enrichments: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(RoutingProperties, self).__init__(**kwargs) - self.endpoints = kwargs.get('endpoints', None) - self.routes = kwargs.get('routes', None) - self.fallback_route = kwargs.get('fallback_route', None) - self.enrichments = kwargs.get('enrichments', None) - - -class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): - """The properties related to service bus queue endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing service bus queue endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): - """The properties related to service bus topic endpoint types. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol - sb://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing service bus topic endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type 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, - **kwargs - ): - super(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.entity_path = kwargs.get('entity_path', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - - -class RoutingStorageContainerProperties(msrest.serialization.Model): - """The properties related to a storage container endpoint. - - All required parameters must be populated in order to send to Azure. - - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible - values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing storage endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param 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. - :type file_name_format: str - :param 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. - :type batch_frequency_in_seconds: int - :param 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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are - 'avro', 'avrodeflate', and 'JSON'. Default value is 'avro'. Possible values include: "Avro", - "AvroDeflate", "JSON". - :type encoding: str or - ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(RoutingStorageContainerProperties, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.connection_string = kwargs.get('connection_string', None) - self.endpoint_uri = kwargs.get('endpoint_uri', None) - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - self.name = kwargs['name'] - self.subscription_id = kwargs.get('subscription_id', None) - self.resource_group = kwargs.get('resource_group', None) - self.container_name = kwargs['container_name'] - self.file_name_format = kwargs.get('file_name_format', None) - self.batch_frequency_in_seconds = kwargs.get('batch_frequency_in_seconds', None) - self.max_chunk_size_in_bytes = kwargs.get('max_chunk_size_in_bytes', None) - self.encoding = kwargs.get('encoding', None) - - -class RoutingTwin(msrest.serialization.Model): - """Twin reference input parameter. This is an optional parameter. - - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwinProperties - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': 'object'}, - 'properties': {'key': 'properties', 'type': 'RoutingTwinProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwin, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.properties = kwargs.get('properties', None) - - -class RoutingTwinProperties(msrest.serialization.Model): - """RoutingTwinProperties. - - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any - """ - - _attribute_map = { - 'desired': {'key': 'desired', 'type': 'object'}, - 'reported': {'key': 'reported', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(RoutingTwinProperties, self).__init__(**kwargs) - self.desired = kwargs.get('desired', None) - self.reported = kwargs.get('reported', None) - - -class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): - """The properties of an IoT hub shared access policy. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values - include: "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", - "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) - self.key_name = kwargs['key_name'] - self.primary_key = kwargs.get('primary_key', None) - self.secondary_key = kwargs.get('secondary_key', None) - self.rights = kwargs['rights'] - - -class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Model): - """The list of shared access policies with a next link. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class StorageEndpointProperties(msrest.serialization.Model): - """The properties of the Azure Storage endpoint for file upload. - - All required parameters must be populated in order to send to Azure. - - :param 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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The - container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the - storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for file upload. - :type identity: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(StorageEndpointProperties, self).__init__(**kwargs) - self.sas_ttl_as_iso8601 = kwargs.get('sas_ttl_as_iso8601', None) - self.connection_string = kwargs['connection_string'] - self.container_name = kwargs['container_name'] - self.authentication_type = kwargs.get('authentication_type', None) - self.identity = kwargs.get('identity', None) - - -class TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TestAllRoutesInput(msrest.serialization.Model): - """Input for testing all routes. - - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", - "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", - "DeviceConnectionStateEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin - """ - - _attribute_map = { - 'routing_source': {'key': 'routingSource', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'RoutingMessage'}, - 'twin': {'key': 'twin', 'type': 'RoutingTwin'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesInput, self).__init__(**kwargs) - self.routing_source = kwargs.get('routing_source', None) - self.message = kwargs.get('message', None) - self.twin = kwargs.get('twin', None) - - -class TestAllRoutesResult(msrest.serialization.Model): - """Result of testing all routes. - - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2021_07_01.models.MatchedRoute] - """ - - _attribute_map = { - 'routes': {'key': 'routes', 'type': '[MatchedRoute]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestAllRoutesResult, self).__init__(**kwargs) - self.routes = kwargs.get('routes', None) - - -class TestRouteInput(msrest.serialization.Model): - """Input for testing route. - - All required parameters must be populated in order to send to Azure. - - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(TestRouteInput, self).__init__(**kwargs) - self.message = kwargs.get('message', None) - self.route = kwargs['route'] - self.twin = kwargs.get('twin', None) - - -class TestRouteResult(msrest.serialization.Model): - """Result of testing one route. - - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2021_07_01.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResultDetails - """ - - _attribute_map = { - 'result': {'key': 'result', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'TestRouteResultDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResult, self).__init__(**kwargs) - self.result = kwargs.get('result', None) - self.details = kwargs.get('details', None) - - -class TestRouteResultDetails(msrest.serialization.Model): - """Detailed result of testing a route. - - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2021_07_01.models.RouteCompilationError] - """ - - _attribute_map = { - 'compilation_errors': {'key': 'compilationErrors', 'type': '[RouteCompilationError]'}, - } - - def __init__( - self, - **kwargs - ): - super(TestRouteResultDetails, self).__init__(**kwargs) - self.compilation_errors = kwargs.get('compilation_errors', None) - - -class UserSubscriptionQuota(msrest.serialization.Model): - """User subscription quota response. - - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(UserSubscriptionQuota, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.type = kwargs.get('type', None) - self.unit = kwargs.get('unit', None) - self.current_value = kwargs.get('current_value', None) - self.limit = kwargs.get('limit', None) - self.name = kwargs.get('name', None) - - -class UserSubscriptionQuotaListResult(msrest.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. - - :param value: - :type value: list[~azure.mgmt.iothub.v2021_07_01.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, - **kwargs - ): - super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py index cf884965f372..095997944480 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/models/_models_py3.py @@ -24,13 +24,13 @@ class ArmIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: Tenant Id. :vartype tenant_id: str - :param 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. Possible values - include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". - :type type: str or ~azure.mgmt.iothub.v2021_07_01.models.ResourceIdentityType - :param user_assigned_identities: Dictionary of :code:``. - :type user_assigned_identities: dict[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. Possible values include: "SystemAssigned", + "UserAssigned", "SystemAssigned, UserAssigned", "None". + :vartype type: str or ~azure.mgmt.iothub.v2021_07_01.models.ResourceIdentityType + :ivar user_assigned_identities: Dictionary of :code:``. + :vartype user_assigned_identities: dict[str, ~azure.mgmt.iothub.v2021_07_01.models.ArmUserIdentity] """ @@ -53,6 +53,16 @@ def __init__( user_assigned_identities: Optional[Dict[str, "ArmUserIdentity"]] = None, **kwargs ): + """ + :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. Possible values + include: "SystemAssigned", "UserAssigned", "SystemAssigned, UserAssigned", "None". + :paramtype type: str or ~azure.mgmt.iothub.v2021_07_01.models.ResourceIdentityType + :keyword user_assigned_identities: Dictionary of :code:``. + :paramtype user_assigned_identities: dict[str, + ~azure.mgmt.iothub.v2021_07_01.models.ArmUserIdentity] + """ super(ArmIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -85,6 +95,8 @@ def __init__( self, **kwargs ): + """ + """ super(ArmUserIdentity, self).__init__(**kwargs) self.principal_id = None self.client_id = None @@ -93,12 +105,12 @@ def __init__( class CertificateBodyDescription(msrest.serialization.Model): """The JSON-serialized X509 Certificate. - :param certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem + :ivar certificate: base-64 representation of the X509 leaf certificate .cer file or just .pem file content. - :type certificate: str - :param is_verified: True indicates that the certificate will be created in verified state and + :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. - :type is_verified: bool + :vartype is_verified: bool """ _attribute_map = { @@ -113,6 +125,14 @@ def __init__( is_verified: Optional[bool] = None, **kwargs ): + """ + :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(CertificateBodyDescription, self).__init__(**kwargs) self.certificate = certificate self.is_verified = is_verified @@ -123,8 +143,8 @@ class CertificateDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.CertificateProperties + :ivar properties: The description of an X509 CA Certificate. + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -156,6 +176,10 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: The description of an X509 CA Certificate. + :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.CertificateProperties + """ super(CertificateDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -167,8 +191,8 @@ def __init__( class CertificateListDescription(msrest.serialization.Model): """The JSON-serialized array of Certificate objects. - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription] """ _attribute_map = { @@ -181,6 +205,10 @@ def __init__( value: Optional[List["CertificateDescription"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -196,14 +224,14 @@ class CertificateProperties(msrest.serialization.Model): :vartype expiry: ~datetime.datetime :ivar thumbprint: The certificate's thumbprint. :vartype thumbprint: str - :param is_verified: Determines whether certificate has been verified. - :type is_verified: bool + :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 - :param certificate: The certificate content. - :type certificate: str + :ivar certificate: The certificate content. + :vartype certificate: str """ _validation = { @@ -231,6 +259,12 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword is_verified: Determines whether certificate has been verified. + :paramtype is_verified: bool + :keyword certificate: The certificate content. + :paramtype certificate: str + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -291,6 +325,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificatePropertiesWithNonce, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -305,9 +341,9 @@ def __init__( class CertificateVerificationDescription(msrest.serialization.Model): """The JSON-serialized leaf certificate. - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: str + :vartype certificate: str """ _attribute_map = { @@ -320,6 +356,11 @@ def __init__( certificate: Optional[str] = None, **kwargs ): + """ + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: str + """ super(CertificateVerificationDescription, self).__init__(**kwargs) self.certificate = certificate @@ -329,9 +370,9 @@ class CertificateWithNonceDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The description of an X509 CA Certificate including the challenge nonce + :ivar properties: The description of an X509 CA Certificate including the challenge nonce issued for the Proof-Of-Possession flow. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.CertificatePropertiesWithNonce + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.CertificatePropertiesWithNonce :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -363,6 +404,11 @@ def __init__( properties: Optional["CertificatePropertiesWithNonce"] = None, **kwargs ): + """ + :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.v2021_07_01.models.CertificatePropertiesWithNonce + """ super(CertificateWithNonceDescription, self).__init__(**kwargs) self.properties = properties self.id = None @@ -374,16 +420,16 @@ def __init__( class CloudToDeviceProperties(msrest.serialization.Model): """The IoT hub cloud-to-device messaging properties. - :param max_delivery_count: The max delivery count for cloud-to-device messages in the device + :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. - :type max_delivery_count: int - :param default_ttl_as_iso8601: The default time to live for cloud-to-device messages in the + :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. - :type default_ttl_as_iso8601: ~datetime.timedelta - :param feedback: The properties of the feedback queue for cloud-to-device messages. - :type feedback: ~azure.mgmt.iothub.v2021_07_01.models.FeedbackProperties + :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.v2021_07_01.models.FeedbackProperties """ _validation = { @@ -404,6 +450,18 @@ def __init__( feedback: Optional["FeedbackProperties"] = None, **kwargs ): + """ + :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.v2021_07_01.models.FeedbackProperties + """ super(CloudToDeviceProperties, self).__init__(**kwargs) self.max_delivery_count = max_delivery_count self.default_ttl_as_iso8601 = default_ttl_as_iso8601 @@ -413,9 +471,9 @@ def __init__( class EndpointHealthData(msrest.serialization.Model): """The health data for an endpoint. - :param endpoint_id: Id of the endpoint. - :type endpoint_id: str - :param health_status: Health statuses have following meanings. The 'healthy' status shows that + :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 @@ -425,16 +483,16 @@ class EndpointHealthData(msrest.serialization.Model): the IoT Hub has not established a connection with the endpoint. No messages have been delivered to or rejected from this endpoint. Possible values include: "unknown", "healthy", "degraded", "unhealthy", "dead". - :type health_status: str or ~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthStatus - :param last_known_error: Last error obtained when a message failed to be delivered to iot hub. - :type last_known_error: str - :param last_known_error_time: Time at which the last known error occurred. - :type last_known_error_time: ~datetime.datetime - :param last_successful_send_attempt_time: Last time iot hub successfully sent a message to the + :vartype health_status: str or ~azure.mgmt.iothub.v2021_07_01.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. - :type last_successful_send_attempt_time: ~datetime.datetime - :param last_send_attempt_time: Last time iot hub tried to send a message to the endpoint. - :type last_send_attempt_time: ~datetime.datetime + :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 = { @@ -457,6 +515,31 @@ def __init__( last_send_attempt_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :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. Possible values include: "unknown", + "healthy", "degraded", "unhealthy", "dead". + :paramtype health_status: str or ~azure.mgmt.iothub.v2021_07_01.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(EndpointHealthData, self).__init__(**kwargs) self.endpoint_id = endpoint_id self.health_status = health_status @@ -471,8 +554,8 @@ class EndpointHealthDataListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: JSON-serialized array of Endpoint health data. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthData] + :ivar value: JSON-serialized array of Endpoint health data. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthData] :ivar next_link: Link to more results. :vartype next_link: str """ @@ -492,6 +575,10 @@ def __init__( value: Optional[List["EndpointHealthData"]] = None, **kwargs ): + """ + :keyword value: JSON-serialized array of Endpoint health data. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthData] + """ super(EndpointHealthDataListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -502,13 +589,13 @@ class EnrichmentProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key: Required. The key or name for the enrichment property. - :type key: str - :param value: Required. The value for the enrichment property. - :type value: str - :param endpoint_names: Required. The list of endpoints for which the enrichment is applied to + :ivar key: Required. The key or name for the enrichment property. + :vartype key: str + :ivar value: Required. The value for the enrichment property. + :vartype value: str + :ivar endpoint_names: Required. The list of endpoints for which the enrichment is applied to the message. - :type endpoint_names: list[str] + :vartype endpoint_names: list[str] """ _validation = { @@ -531,6 +618,15 @@ def __init__( endpoint_names: List[str], **kwargs ): + """ + :keyword key: Required. The key or name for the enrichment property. + :paramtype key: str + :keyword value: Required. The value for the enrichment property. + :paramtype value: str + :keyword endpoint_names: Required. The list of endpoints for which the enrichment is applied to + the message. + :paramtype endpoint_names: list[str] + """ super(EnrichmentProperties, self).__init__(**kwargs) self.key = key self.value = value @@ -570,6 +666,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -582,8 +680,8 @@ class EventHubConsumerGroupBodyDescription(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param properties: Required. The EventHub consumer group name. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupName + :ivar properties: Required. The EventHub consumer group name. + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupName """ _validation = { @@ -600,6 +698,10 @@ def __init__( properties: "EventHubConsumerGroupName", **kwargs ): + """ + :keyword properties: Required. The EventHub consumer group name. + :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupName + """ super(EventHubConsumerGroupBodyDescription, self).__init__(**kwargs) self.properties = properties @@ -609,8 +711,8 @@ class EventHubConsumerGroupInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: The tags. - :type properties: dict[str, any] + :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. @@ -642,6 +744,10 @@ def __init__( properties: Optional[Dict[str, Any]] = None, **kwargs ): + """ + :keyword properties: The tags. + :paramtype properties: dict[str, any] + """ super(EventHubConsumerGroupInfo, self).__init__(**kwargs) self.properties = properties self.id = None @@ -655,8 +761,8 @@ class EventHubConsumerGroupName(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. EventHub consumer group name. - :type name: str + :ivar name: Required. EventHub consumer group name. + :vartype name: str """ _validation = { @@ -673,6 +779,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. EventHub consumer group name. + :paramtype name: str + """ super(EventHubConsumerGroupName, self).__init__(**kwargs) self.name = name @@ -682,8 +792,8 @@ class EventHubConsumerGroupsListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of consumer groups objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo] + :ivar value: List of consumer groups objects. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -703,6 +813,10 @@ def __init__( value: Optional[List["EventHubConsumerGroupInfo"]] = None, **kwargs ): + """ + :keyword value: List of consumer groups objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo] + """ super(EventHubConsumerGroupsListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -713,13 +827,13 @@ class EventHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param retention_time_in_days: The retention time for device-to-cloud messages in days. See: + :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. - :type retention_time_in_days: long - :param partition_count: The number of partitions for receiving device-to-cloud messages in the + :vartype retention_time_in_days: long + :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. - :type partition_count: int + :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. @@ -749,6 +863,15 @@ def __init__( partition_count: Optional[int] = None, **kwargs ): + """ + :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: long + :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(EventHubProperties, self).__init__(**kwargs) self.retention_time_in_days = retention_time_in_days self.partition_count = partition_count @@ -762,24 +885,24 @@ class ExportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param export_blob_container_uri: Required. The export blob container URI. - :type export_blob_container_uri: str - :param exclude_keys: Required. The value indicating whether keys should be excluded during + :ivar export_blob_container_uri: Required. The export blob container URI. + :vartype export_blob_container_uri: str + :ivar exclude_keys: Required. The value indicating whether keys should be excluded during export. - :type exclude_keys: bool - :param export_blob_name: The name of the blob that will be created in the provided output blob + :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. - :type export_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype export_blob_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for export devices. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be exported. - :type include_configurations: bool - :param configurations_blob_name: The name of the blob that will be created in the provided + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for export devices. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.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. - :type configurations_blob_name: str + :vartype configurations_blob_name: str """ _validation = { @@ -809,6 +932,28 @@ def __init__( configurations_blob_name: Optional[str] = None, **kwargs ): + """ + :keyword export_blob_container_uri: Required. The export blob container URI. + :paramtype export_blob_container_uri: str + :keyword exclude_keys: Required. The value indicating whether keys should be excluded during + export. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for export devices. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.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(ExportDevicesRequest, self).__init__(**kwargs) self.export_blob_container_uri = export_blob_container_uri self.exclude_keys = exclude_keys @@ -824,8 +969,8 @@ class FailoverInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param failover_region: Required. Region the hub will be failed over to. - :type failover_region: str + :ivar failover_region: Required. Region the hub will be failed over to. + :vartype failover_region: str """ _validation = { @@ -842,6 +987,10 @@ def __init__( failover_region: str, **kwargs ): + """ + :keyword failover_region: Required. Region the hub will be failed over to. + :paramtype failover_region: str + """ super(FailoverInput, self).__init__(**kwargs) self.failover_region = failover_region @@ -851,22 +1000,22 @@ class FallbackRouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: The name of the route. The name can only include alphanumeric characters, periods, + :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. - :type name: str - :param source: Required. The source to which the routing rule is to be applied to. For example, + :vartype name: str + :ivar source: Required. The source to which the routing rule is to be applied to. For example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource - :param condition: The condition which is evaluated in order to apply the fallback route. If the + :vartype source: str or ~azure.mgmt.iothub.v2021_07_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which the messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which the messages that satisfy the condition are routed to. Currently only 1 endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether the fallback route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether the fallback route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -893,6 +1042,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :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: Required. The source to which the routing rule is to be applied to. For + example, DeviceMessages. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2021_07_01.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: Required. The list of endpoints to which the messages that satisfy the + condition are routed to. Currently only 1 endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether the fallback route is enabled. + :paramtype is_enabled: bool + """ super(FallbackRouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -904,17 +1072,17 @@ def __init__( class FeedbackProperties(msrest.serialization.Model): """The properties of the feedback queue for cloud-to-device messages. - :param lock_duration_as_iso8601: The lock duration for the feedback queue. See: + :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. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message on the + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -935,6 +1103,19 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(FeedbackProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -954,8 +1135,8 @@ class GroupIdInformation(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties for a group information object. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformationProperties + :ivar properties: Required. The properties for a group information object. + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformationProperties """ _validation = { @@ -978,6 +1159,10 @@ def __init__( properties: "GroupIdInformationProperties", **kwargs ): + """ + :keyword properties: Required. The properties for a group information object. + :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformationProperties + """ super(GroupIdInformation, self).__init__(**kwargs) self.id = None self.name = None @@ -988,12 +1173,12 @@ def __init__( class GroupIdInformationProperties(msrest.serialization.Model): """The properties for a group information object. - :param group_id: The group id. - :type group_id: str - :param required_members: The required members for a specific group id. - :type required_members: list[str] - :param required_zone_names: The required DNS zones for a specific group id. - :type required_zone_names: list[str] + :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 = { @@ -1010,6 +1195,14 @@ def __init__( required_zone_names: Optional[List[str]] = None, **kwargs ): + """ + :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(GroupIdInformationProperties, self).__init__(**kwargs) self.group_id = group_id self.required_members = required_members @@ -1021,25 +1214,25 @@ class ImportDevicesRequest(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param input_blob_container_uri: Required. The input blob container URI. - :type input_blob_container_uri: str - :param output_blob_container_uri: Required. The output blob container URI. - :type output_blob_container_uri: str - :param input_blob_name: The blob name to be used when importing from the provided input blob + :ivar input_blob_container_uri: Required. The input blob container URI. + :vartype input_blob_container_uri: str + :ivar output_blob_container_uri: Required. The output blob container URI. + :vartype output_blob_container_uri: str + :ivar input_blob_name: The blob name to be used when importing from the provided input blob container. - :type input_blob_name: str - :param output_blob_name: The blob name to use for storing the status of the import job. - :type output_blob_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for import devices. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param include_configurations: The value indicating whether configurations should be imported. - :type include_configurations: bool - :param configurations_blob_name: The blob name to be used when importing configurations from - the provided input blob container. - :type configurations_blob_name: str + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for import devices. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.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 = { @@ -1071,6 +1264,28 @@ def __init__( configurations_blob_name: Optional[str] = None, **kwargs ): + """ + :keyword input_blob_container_uri: Required. The input blob container URI. + :paramtype input_blob_container_uri: str + :keyword output_blob_container_uri: Required. The output blob container URI. + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for import devices. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.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(ImportDevicesRequest, self).__init__(**kwargs) self.input_blob_container_uri = input_blob_container_uri self.output_blob_container_uri = output_blob_container_uri @@ -1116,6 +1331,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubCapacity, self).__init__(**kwargs) self.minimum = None self.maximum = None @@ -1136,10 +1353,10 @@ class Resource(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of tags. The resource tags. + :vartype tags: dict[str, str] """ _validation = { @@ -1164,6 +1381,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of tags. The resource tags. + :paramtype tags: dict[str, str] + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -1185,19 +1408,19 @@ class IotHubDescription(Resource): :vartype name: str :ivar type: The resource type. :vartype type: str - :param location: Required. The resource location. - :type location: str - :param tags: A set of tags. The resource tags. - :type tags: dict[str, str] - :param etag: The Etag field is *not* required. If it is provided in the response body, it must + :ivar location: Required. The resource location. + :vartype location: str + :ivar tags: A set of 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. - :type etag: str - :param properties: IotHub properties. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.IotHubProperties - :param sku: Required. IotHub SKU info. - :type sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo - :param identity: The managed identities for the IotHub. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ArmIdentity + :vartype etag: str + :ivar properties: IotHub properties. + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.IotHubProperties + :ivar sku: Required. IotHub SKU info. + :vartype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo + :ivar identity: The managed identities for the IotHub. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ArmIdentity """ _validation = { @@ -1231,6 +1454,21 @@ def __init__( identity: Optional["ArmIdentity"] = None, **kwargs ): + """ + :keyword location: Required. The resource location. + :paramtype location: str + :keyword tags: A set of 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.v2021_07_01.models.IotHubProperties + :keyword sku: Required. IotHub SKU info. + :paramtype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo + :keyword identity: The managed identities for the IotHub. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ArmIdentity + """ super(IotHubDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties @@ -1243,8 +1481,8 @@ class IotHubDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubDescription objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + :ivar value: The array of IotHubDescription objects. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1264,6 +1502,10 @@ def __init__( value: Optional[List["IotHubDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubDescription objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] + """ super(IotHubDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1272,13 +1514,13 @@ def __init__( class IotHubLocationDescription(msrest.serialization.Model): """Public representation of one of the locations where a resource is provisioned. - :param location: The name of the Azure region. - :type location: str - :param role: The role of the region, can be either primary or secondary. The primary region is + :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. Possible values include: "primary", "secondary". - :type role: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubReplicaRoleType + :vartype role: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubReplicaRoleType """ _attribute_map = { @@ -1293,6 +1535,15 @@ def __init__( role: Optional[Union[str, "IotHubReplicaRoleType"]] = None, **kwargs ): + """ + :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. Possible + values include: "primary", "secondary". + :paramtype role: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubReplicaRoleType + """ super(IotHubLocationDescription, self).__init__(**kwargs) self.location = location self.role = role @@ -1308,8 +1559,8 @@ class IotHubNameAvailabilityInfo(msrest.serialization.Model): :ivar reason: The reason for unavailability. Possible values include: "Invalid", "AlreadyExists". :vartype reason: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubNameUnavailabilityReason - :param message: The detailed reason message. - :type message: str + :ivar message: The detailed reason message. + :vartype message: str """ _validation = { @@ -1329,6 +1580,10 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword message: The detailed reason message. + :paramtype message: str + """ super(IotHubNameAvailabilityInfo, self).__init__(**kwargs) self.name_available = None self.reason = None @@ -1340,37 +1595,38 @@ class IotHubProperties(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param authorization_policies: The shared access policies you can use to secure a connection to + :ivar authorization_policies: The shared access policies you can use to secure a connection to the IoT hub. - :type authorization_policies: + :vartype authorization_policies: list[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] - :param disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for + :ivar disable_local_auth: If true, SAS tokens with Iot hub scoped SAS keys cannot be used for authentication. - :type disable_local_auth: bool - :param disable_device_sas: If true, all device(including Edge devices but excluding modules) + :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. - :type disable_device_sas: bool - :param disable_module_sas: If true, all module scoped SAS keys cannot be used for + :vartype disable_device_sas: bool + :ivar disable_module_sas: If true, all module scoped SAS keys cannot be used for authentication. - :type disable_module_sas: bool - :param restrict_outbound_network_access: If true, egress from IotHub will be restricted to only + :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. - :type restrict_outbound_network_access: bool - :param allowed_fqdn_list: List of allowed FQDNs(Fully Qualified Domain Name) for egress from - Iot Hub. - :type allowed_fqdn_list: list[str] - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :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. Possible values include: "Enabled", "Disabled". - :type public_network_access: str or ~azure.mgmt.iothub.v2021_07_01.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothub.v2021_07_01.models.IpFilterRule] - :param network_rule_sets: Network Rule Set Properties of IotHub. - :type network_rule_sets: ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleSetProperties - :param 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. - :type min_tls_version: str - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: + :vartype public_network_access: str or + ~azure.mgmt.iothub.v2021_07_01.models.PublicNetworkAccess + :ivar ip_filter_rules: The IP filter rules. + :vartype ip_filter_rules: list[~azure.mgmt.iothub.v2021_07_01.models.IpFilterRule] + :ivar network_rule_sets: Network Rule Set Properties of IotHub. + :vartype network_rule_sets: ~azure.mgmt.iothub.v2021_07_01.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.v2021_07_01.models.PrivateEndpointConnection] :ivar provisioning_state: The provisioning state. :vartype provisioning_state: str @@ -1378,33 +1634,34 @@ class IotHubProperties(msrest.serialization.Model): :vartype state: str :ivar host_name: The name of the host. :vartype host_name: str - :param 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. - :type event_hub_endpoints: dict[str, ~azure.mgmt.iothub.v2021_07_01.models.EventHubProperties] - :param routing: The routing related properties of the IoT hub. See: + :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.v2021_07_01.models.EventHubProperties] + :ivar routing: The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :type routing: ~azure.mgmt.iothub.v2021_07_01.models.RoutingProperties - :param storage_endpoints: The list of Azure Storage endpoints where you can upload files. + :vartype routing: ~azure.mgmt.iothub.v2021_07_01.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. - :type storage_endpoints: dict[str, + :vartype storage_endpoints: dict[str, ~azure.mgmt.iothub.v2021_07_01.models.StorageEndpointProperties] - :param messaging_endpoints: The messaging endpoint properties for the file upload notification + :ivar messaging_endpoints: The messaging endpoint properties for the file upload notification queue. - :type messaging_endpoints: dict[str, + :vartype messaging_endpoints: dict[str, ~azure.mgmt.iothub.v2021_07_01.models.MessagingEndpointProperties] - :param enable_file_upload_notifications: If True, file upload notifications are enabled. - :type enable_file_upload_notifications: bool - :param cloud_to_device: The IoT hub cloud-to-device messaging properties. - :type cloud_to_device: ~azure.mgmt.iothub.v2021_07_01.models.CloudToDeviceProperties - :param comments: IoT hub comments. - :type comments: str - :param features: The capabilities and features enabled for the IoT hub. Possible values - include: "None", "DeviceManagement". - :type features: str or ~azure.mgmt.iothub.v2021_07_01.models.Capabilities + :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.v2021_07_01.models.CloudToDeviceProperties + :ivar comments: IoT hub comments. + :vartype comments: str + :ivar features: The capabilities and features enabled for the IoT hub. Possible values include: + "None", "DeviceManagement". + :vartype features: str or ~azure.mgmt.iothub.v2021_07_01.models.Capabilities :ivar locations: Primary and secondary location for iot hub. :vartype locations: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubLocationDescription] """ @@ -1466,6 +1723,69 @@ def __init__( features: Optional[Union[str, "Capabilities"]] = None, **kwargs ): + """ + :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.v2021_07_01.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. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothub.v2021_07_01.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothub.v2021_07_01.models.IpFilterRule] + :keyword network_rule_sets: Network Rule Set Properties of IotHub. + :paramtype network_rule_sets: ~azure.mgmt.iothub.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.models.StorageEndpointProperties] + :keyword messaging_endpoints: The messaging endpoint properties for the file upload + notification queue. + :paramtype messaging_endpoints: dict[str, + ~azure.mgmt.iothub.v2021_07_01.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.v2021_07_01.models.CloudToDeviceProperties + :keyword comments: IoT hub comments. + :paramtype comments: str + :keyword features: The capabilities and features enabled for the IoT hub. Possible values + include: "None", "DeviceManagement". + :paramtype features: str or ~azure.mgmt.iothub.v2021_07_01.models.Capabilities + """ super(IotHubProperties, self).__init__(**kwargs) self.authorization_policies = authorization_policies self.disable_local_auth = disable_local_auth @@ -1521,6 +1841,8 @@ def __init__( self, **kwargs ): + """ + """ super(IotHubQuotaMetricInfo, self).__init__(**kwargs) self.name = None self.current_value = None @@ -1532,8 +1854,8 @@ class IotHubQuotaMetricInfoListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of quota metrics objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfo] + :ivar value: The array of quota metrics objects. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfo] :ivar next_link: The next link. :vartype next_link: str """ @@ -1553,6 +1875,10 @@ def __init__( value: Optional[List["IotHubQuotaMetricInfo"]] = None, **kwargs ): + """ + :keyword value: The array of quota metrics objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfo] + """ super(IotHubQuotaMetricInfoListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1567,10 +1893,10 @@ class IotHubSkuDescription(msrest.serialization.Model): :ivar resource_type: The type of the resource. :vartype resource_type: str - :param sku: Required. The type of the resource. - :type sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo - :param capacity: Required. IotHub capacity. - :type capacity: ~azure.mgmt.iothub.v2021_07_01.models.IotHubCapacity + :ivar sku: Required. The type of the resource. + :vartype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo + :ivar capacity: Required. IotHub capacity. + :vartype capacity: ~azure.mgmt.iothub.v2021_07_01.models.IotHubCapacity """ _validation = { @@ -1592,6 +1918,12 @@ def __init__( capacity: "IotHubCapacity", **kwargs ): + """ + :keyword sku: Required. The type of the resource. + :paramtype sku: ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuInfo + :keyword capacity: Required. IotHub capacity. + :paramtype capacity: ~azure.mgmt.iothub.v2021_07_01.models.IotHubCapacity + """ super(IotHubSkuDescription, self).__init__(**kwargs) self.resource_type = None self.sku = sku @@ -1603,8 +1935,8 @@ class IotHubSkuDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of IotHubSkuDescription. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescription] + :ivar value: The array of IotHubSkuDescription. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescription] :ivar next_link: The next link. :vartype next_link: str """ @@ -1624,6 +1956,10 @@ def __init__( value: Optional[List["IotHubSkuDescription"]] = None, **kwargs ): + """ + :keyword value: The array of IotHubSkuDescription. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescription] + """ super(IotHubSkuDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1636,15 +1972,15 @@ class IotHubSkuInfo(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + :ivar name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", "B1", "B2", "B3". - :type name: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSku + :vartype name: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSku :ivar tier: The billing tier for the IoT hub. Possible values include: "Free", "Standard", "Basic". :vartype tier: str or ~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuTier - :param capacity: The number of provisioned IoT Hub units. See: + :ivar capacity: The number of provisioned IoT Hub units. See: https://docs.microsoft.com/azure/azure-subscription-service-limits#iot-hub-limits. - :type capacity: long + :vartype capacity: long """ _validation = { @@ -1665,6 +2001,14 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Required. The name of the SKU. Possible values include: "F1", "S1", "S2", "S3", + "B1", "B2", "B3". + :paramtype name: str or ~azure.mgmt.iothub.v2021_07_01.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: long + """ super(IotHubSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -1676,14 +2020,14 @@ class IpFilterRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. The name of the IP filter rule. - :type filter_name: str - :param action: Required. The desired action for requests captured by this rule. Possible values + :ivar filter_name: Required. The name of the IP filter rule. + :vartype filter_name: str + :ivar action: Required. The desired action for requests captured by this rule. Possible values include: "Accept", "Reject". - :type action: str or ~azure.mgmt.iothub.v2021_07_01.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :vartype action: str or ~azure.mgmt.iothub.v2021_07_01.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1706,6 +2050,16 @@ def __init__( ip_mask: str, **kwargs ): + """ + :keyword filter_name: Required. The name of the IP filter rule. + :paramtype filter_name: str + :keyword action: Required. The desired action for requests captured by this rule. Possible + values include: "Accept", "Reject". + :paramtype action: str or ~azure.mgmt.iothub.v2021_07_01.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1764,6 +2118,8 @@ def __init__( self, **kwargs ): + """ + """ super(JobResponse, self).__init__(**kwargs) self.job_id = None self.start_time_utc = None @@ -1780,8 +2136,8 @@ class JobResponseListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The array of JobResponse objects. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.JobResponse] + :ivar value: The array of JobResponse objects. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.JobResponse] :ivar next_link: The next link. :vartype next_link: str """ @@ -1801,6 +2157,10 @@ def __init__( value: Optional[List["JobResponse"]] = None, **kwargs ): + """ + :keyword value: The array of JobResponse objects. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.JobResponse] + """ super(JobResponseListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1809,8 +2169,8 @@ def __init__( class ManagedIdentity(msrest.serialization.Model): """The properties of the Managed identity. - :param user_assigned_identity: The user assigned identity. - :type user_assigned_identity: str + :ivar user_assigned_identity: The user assigned identity. + :vartype user_assigned_identity: str """ _attribute_map = { @@ -1823,6 +2183,10 @@ def __init__( user_assigned_identity: Optional[str] = None, **kwargs ): + """ + :keyword user_assigned_identity: The user assigned identity. + :paramtype user_assigned_identity: str + """ super(ManagedIdentity, self).__init__(**kwargs) self.user_assigned_identity = user_assigned_identity @@ -1830,8 +2194,8 @@ def __init__( class MatchedRoute(msrest.serialization.Model): """Routes that matched. - :param properties: Properties of routes that matched. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties + :ivar properties: Properties of routes that matched. + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties """ _attribute_map = { @@ -1844,6 +2208,10 @@ def __init__( properties: Optional["RouteProperties"] = None, **kwargs ): + """ + :keyword properties: Properties of routes that matched. + :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties + """ super(MatchedRoute, self).__init__(**kwargs) self.properties = properties @@ -1851,16 +2219,16 @@ def __init__( class MessagingEndpointProperties(msrest.serialization.Model): """The properties of the messaging endpoints used by this IoT hub. - :param lock_duration_as_iso8601: The lock duration. See: + :ivar lock_duration_as_iso8601: The lock duration. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload. - :type lock_duration_as_iso8601: ~datetime.timedelta - :param ttl_as_iso8601: The period of time for which a message is available to consume before it + :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. - :type ttl_as_iso8601: ~datetime.timedelta - :param max_delivery_count: The number of times the IoT hub attempts to deliver a message. See: + :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. - :type max_delivery_count: int + :vartype max_delivery_count: int """ _validation = { @@ -1881,6 +2249,18 @@ def __init__( max_delivery_count: Optional[int] = None, **kwargs ): + """ + :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(MessagingEndpointProperties, self).__init__(**kwargs) self.lock_duration_as_iso8601 = lock_duration_as_iso8601 self.ttl_as_iso8601 = ttl_as_iso8601 @@ -1890,10 +2270,10 @@ def __init__( class Name(msrest.serialization.Model): """Name of Iot Hub type. - :param value: IotHub type. - :type value: str - :param localized_value: Localized value of name. - :type localized_value: str + :ivar value: IotHub type. + :vartype value: str + :ivar localized_value: Localized value of name. + :vartype localized_value: str """ _attribute_map = { @@ -1908,6 +2288,12 @@ def __init__( localized_value: Optional[str] = None, **kwargs ): + """ + :keyword value: IotHub type. + :paramtype value: str + :keyword localized_value: Localized value of name. + :paramtype localized_value: str + """ super(Name, self).__init__(**kwargs) self.value = value self.localized_value = localized_value @@ -1918,13 +2304,13 @@ class NetworkRuleSetIpRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param filter_name: Required. Name of the IP filter rule. - :type filter_name: str - :param action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". - :type action: str or ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleIPAction - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the + :ivar filter_name: Required. Name of the IP filter rule. + :vartype filter_name: str + :ivar action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :vartype action: str or ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleIPAction + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str + :vartype ip_mask: str """ _validation = { @@ -1946,6 +2332,15 @@ def __init__( action: Optional[Union[str, "NetworkRuleIPAction"]] = "Allow", **kwargs ): + """ + :keyword filter_name: Required. Name of the IP filter rule. + :paramtype filter_name: str + :keyword action: IP Filter Action. Possible values include: "Allow". Default value: "Allow". + :paramtype action: str or ~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleIPAction + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + """ super(NetworkRuleSetIpRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -1957,14 +2352,14 @@ class NetworkRuleSetProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param default_action: Default Action for Network Rule Set. Possible values include: "Deny", + :ivar default_action: Default Action for Network Rule Set. Possible values include: "Deny", "Allow". Default value: "Deny". - :type default_action: str or ~azure.mgmt.iothub.v2021_07_01.models.DefaultAction - :param apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also + :vartype default_action: str or ~azure.mgmt.iothub.v2021_07_01.models.DefaultAction + :ivar apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also applied to BuiltIn EventHub EndPoint of IotHub. - :type apply_to_built_in_event_hub_endpoint: bool - :param ip_rules: Required. List of IP Rules. - :type ip_rules: list[~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleSetIpRule] + :vartype apply_to_built_in_event_hub_endpoint: bool + :ivar ip_rules: Required. List of IP Rules. + :vartype ip_rules: list[~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleSetIpRule] """ _validation = { @@ -1986,6 +2381,16 @@ def __init__( default_action: Optional[Union[str, "DefaultAction"]] = "Deny", **kwargs ): + """ + :keyword default_action: Default Action for Network Rule Set. Possible values include: "Deny", + "Allow". Default value: "Deny". + :paramtype default_action: str or ~azure.mgmt.iothub.v2021_07_01.models.DefaultAction + :keyword apply_to_built_in_event_hub_endpoint: Required. If True, then Network Rule Set is also + applied to BuiltIn EventHub EndPoint of IotHub. + :paramtype apply_to_built_in_event_hub_endpoint: bool + :keyword ip_rules: Required. List of IP Rules. + :paramtype ip_rules: list[~azure.mgmt.iothub.v2021_07_01.models.NetworkRuleSetIpRule] + """ super(NetworkRuleSetProperties, self).__init__(**kwargs) self.default_action = default_action self.apply_to_built_in_event_hub_endpoint = apply_to_built_in_event_hub_endpoint @@ -1999,8 +2404,8 @@ class Operation(msrest.serialization.Model): :ivar name: Operation name: {provider}/{resource}/{read | write | action | delete}. :vartype name: str - :param display: The object that represents the operation. - :type display: ~azure.mgmt.iothub.v2021_07_01.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothub.v2021_07_01.models.OperationDisplay """ _validation = { @@ -2018,6 +2423,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothub.v2021_07_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -2056,6 +2465,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -2068,8 +2479,8 @@ class OperationInputs(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. The name of the IoT hub to check. - :type name: str + :ivar name: Required. The name of the IoT hub to check. + :vartype name: str """ _validation = { @@ -2086,6 +2497,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the IoT hub to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -2115,6 +2530,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -2141,6 +2558,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = None @@ -2158,8 +2577,8 @@ class PrivateEndpointConnection(msrest.serialization.Model): :vartype name: str :ivar type: The resource type. :vartype type: str - :param properties: Required. The properties of a private endpoint connection. - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnectionProperties + :ivar properties: Required. The properties of a private endpoint connection. + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnectionProperties """ _validation = { @@ -2182,6 +2601,11 @@ def __init__( properties: "PrivateEndpointConnectionProperties", **kwargs ): + """ + :keyword properties: Required. The properties of a private endpoint connection. + :paramtype properties: + ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnectionProperties + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.id = None self.name = None @@ -2194,11 +2618,11 @@ class PrivateEndpointConnectionProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param private_endpoint: The private endpoint property of a private endpoint connection. - :type private_endpoint: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpoint - :param private_link_service_connection_state: Required. The current state of a private endpoint + :ivar private_endpoint: The private endpoint property of a private endpoint connection. + :vartype private_endpoint: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpoint + :ivar private_link_service_connection_state: Required. The current state of a private endpoint connection. - :type private_link_service_connection_state: + :vartype private_link_service_connection_state: ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionState """ @@ -2218,6 +2642,14 @@ def __init__( private_endpoint: Optional["PrivateEndpoint"] = None, **kwargs ): + """ + :keyword private_endpoint: The private endpoint property of a private endpoint connection. + :paramtype private_endpoint: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpoint + :keyword private_link_service_connection_state: Required. The current state of a private + endpoint connection. + :paramtype private_link_service_connection_state: + ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionState + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -2226,8 +2658,8 @@ def __init__( class PrivateLinkResources(msrest.serialization.Model): """The available private link resources for an IotHub. - :param value: The list of available private link resources for an IotHub. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformation] + :ivar value: The list of available private link resources for an IotHub. + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformation] """ _attribute_map = { @@ -2240,6 +2672,10 @@ def __init__( value: Optional[List["GroupIdInformation"]] = None, **kwargs ): + """ + :keyword value: The list of available private link resources for an IotHub. + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.GroupIdInformation] + """ super(PrivateLinkResources, self).__init__(**kwargs) self.value = value @@ -2249,14 +2685,15 @@ class PrivateLinkServiceConnectionState(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param status: Required. The status of a private endpoint connection. Possible values include: + :ivar status: Required. The status of a private endpoint connection. Possible values include: "Pending", "Approved", "Rejected", "Disconnected". - :type status: str or ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionStatus - :param description: Required. The description for the current state of a private endpoint + :vartype status: str or + ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionStatus + :ivar description: Required. The description for the current state of a private endpoint connection. - :type description: str - :param actions_required: Actions required for a private endpoint connection. - :type actions_required: str + :vartype description: str + :ivar actions_required: Actions required for a private endpoint connection. + :vartype actions_required: str """ _validation = { @@ -2278,6 +2715,17 @@ def __init__( actions_required: Optional[str] = None, **kwargs ): + """ + :keyword status: Required. The status of a private endpoint connection. Possible values + include: "Pending", "Approved", "Rejected", "Disconnected". + :paramtype status: str or + ~azure.mgmt.iothub.v2021_07_01.models.PrivateLinkServiceConnectionStatus + :keyword description: Required. The description for the current state of a private endpoint + connection. + :paramtype description: str + :keyword actions_required: Actions required for a private endpoint connection. + :paramtype actions_required: str + """ super(PrivateLinkServiceConnectionState, self).__init__(**kwargs) self.status = status self.description = description @@ -2313,6 +2761,8 @@ def __init__( self, **kwargs ): + """ + """ super(RegistryStatistics, self).__init__(**kwargs) self.total_device_count = None self.enabled_device_count = None @@ -2322,12 +2772,12 @@ def __init__( class RouteCompilationError(msrest.serialization.Model): """Compilation error when evaluating route. - :param message: Route error message. - :type message: str - :param severity: Severity of the route error. Possible values include: "error", "warning". - :type severity: str or ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorSeverity - :param location: Location where the route error happened. - :type location: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorRange + :ivar message: Route error message. + :vartype message: str + :ivar severity: Severity of the route error. Possible values include: "error", "warning". + :vartype severity: str or ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorSeverity + :ivar location: Location where the route error happened. + :vartype location: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorRange """ _attribute_map = { @@ -2344,6 +2794,14 @@ def __init__( location: Optional["RouteErrorRange"] = None, **kwargs ): + """ + :keyword message: Route error message. + :paramtype message: str + :keyword severity: Severity of the route error. Possible values include: "error", "warning". + :paramtype severity: str or ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorSeverity + :keyword location: Location where the route error happened. + :paramtype location: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorRange + """ super(RouteCompilationError, self).__init__(**kwargs) self.message = message self.severity = severity @@ -2353,10 +2811,10 @@ def __init__( class RouteErrorPosition(msrest.serialization.Model): """Position where the route error happened. - :param line: Line where the route error happened. - :type line: int - :param column: Column where the route error happened. - :type column: int + :ivar line: Line where the route error happened. + :vartype line: int + :ivar column: Column where the route error happened. + :vartype column: int """ _attribute_map = { @@ -2371,6 +2829,12 @@ def __init__( column: Optional[int] = None, **kwargs ): + """ + :keyword line: Line where the route error happened. + :paramtype line: int + :keyword column: Column where the route error happened. + :paramtype column: int + """ super(RouteErrorPosition, self).__init__(**kwargs) self.line = line self.column = column @@ -2379,10 +2843,10 @@ def __init__( class RouteErrorRange(msrest.serialization.Model): """Range of route errors. - :param start: Start where the route error happened. - :type start: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition - :param end: End where the route error happened. - :type end: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition + :ivar start: Start where the route error happened. + :vartype start: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition + :ivar end: End where the route error happened. + :vartype end: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition """ _attribute_map = { @@ -2397,6 +2861,12 @@ def __init__( end: Optional["RouteErrorPosition"] = None, **kwargs ): + """ + :keyword start: Start where the route error happened. + :paramtype start: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition + :keyword end: End where the route error happened. + :paramtype end: ~azure.mgmt.iothub.v2021_07_01.models.RouteErrorPosition + """ super(RouteErrorRange, self).__init__(**kwargs) self.start = start self.end = end @@ -2407,23 +2877,22 @@ class RouteProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param name: Required. 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. - :type name: str - :param source: Required. The source that the routing rule is to be applied to, such as + :ivar name: Required. 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: Required. The source that the routing rule is to be applied to, such as DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource - :param condition: The condition that is evaluated to apply the routing rule. If no condition is + :vartype source: str or ~azure.mgmt.iothub.v2021_07_01.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. - :type condition: str - :param endpoint_names: Required. The list of endpoints to which messages that satisfy the + :vartype condition: str + :ivar endpoint_names: Required. The list of endpoints to which messages that satisfy the condition are routed. Currently only one endpoint is allowed. - :type endpoint_names: list[str] - :param is_enabled: Required. Used to specify whether a route is enabled. - :type is_enabled: bool + :vartype endpoint_names: list[str] + :ivar is_enabled: Required. Used to specify whether a route is enabled. + :vartype is_enabled: bool """ _validation = { @@ -2451,6 +2920,25 @@ def __init__( condition: Optional[str] = None, **kwargs ): + """ + :keyword name: Required. 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: Required. The source that the routing rule is to be applied to, such as + DeviceMessages. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", + "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". + :paramtype source: str or ~azure.mgmt.iothub.v2021_07_01.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: Required. The list of endpoints to which messages that satisfy the + condition are routed. Currently only one endpoint is allowed. + :paramtype endpoint_names: list[str] + :keyword is_enabled: Required. Used to specify whether a route is enabled. + :paramtype is_enabled: bool + """ super(RouteProperties, self).__init__(**kwargs) self.name = name self.source = source @@ -2462,20 +2950,20 @@ def __init__( class RoutingEndpoints(msrest.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. - :param service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the + :ivar service_bus_queues: The list of Service Bus queue endpoints that IoT hub routes the messages to, based on the routing rules. - :type service_bus_queues: + :vartype service_bus_queues: list[~azure.mgmt.iothub.v2021_07_01.models.RoutingServiceBusQueueEndpointProperties] - :param service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the + :ivar service_bus_topics: The list of Service Bus topic endpoints that the IoT hub routes the messages to, based on the routing rules. - :type service_bus_topics: + :vartype service_bus_topics: list[~azure.mgmt.iothub.v2021_07_01.models.RoutingServiceBusTopicEndpointProperties] - :param event_hubs: The list of Event Hubs endpoints that IoT hub routes messages to, based on + :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. - :type event_hubs: list[~azure.mgmt.iothub.v2021_07_01.models.RoutingEventHubProperties] - :param storage_containers: The list of storage container endpoints that IoT hub routes messages + :vartype event_hubs: list[~azure.mgmt.iothub.v2021_07_01.models.RoutingEventHubProperties] + :ivar storage_containers: The list of storage container endpoints that IoT hub routes messages to, based on the routing rules. - :type storage_containers: + :vartype storage_containers: list[~azure.mgmt.iothub.v2021_07_01.models.RoutingStorageContainerProperties] """ @@ -2495,6 +2983,23 @@ def __init__( storage_containers: Optional[List["RoutingStorageContainerProperties"]] = None, **kwargs ): + """ + :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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.models.RoutingStorageContainerProperties] + """ super(RoutingEndpoints, self).__init__(**kwargs) self.service_bus_queues = service_bus_queues self.service_bus_topics = service_bus_topics @@ -2507,28 +3012,28 @@ class RoutingEventHubProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the event hub endpoint. - :type id: str - :param connection_string: The connection string of the event hub endpoint. - :type connection_string: str - :param endpoint_uri: The url of the event hub endpoint. It must include the protocol sb://. - :type endpoint_uri: str - :param entity_path: Event hub name on the event hub namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the event hub endpoint. - Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing event hub endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :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. Possible + values include: "keyBased", "identityBased". + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :ivar identity: Managed identity properties of routing event hub endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the event hub endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the event hub endpoint. - :type resource_group: str + :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 = { @@ -2561,6 +3066,30 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :keyword identity: Managed identity properties of routing event hub endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingEventHubProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2576,12 +3105,12 @@ def __init__( class RoutingMessage(msrest.serialization.Model): """Routing message. - :param body: Body of routing message. - :type body: str - :param app_properties: App properties. - :type app_properties: dict[str, str] - :param system_properties: System properties. - :type system_properties: dict[str, str] + :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 = { @@ -2598,6 +3127,14 @@ def __init__( system_properties: Optional[Dict[str, str]] = None, **kwargs ): + """ + :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(RoutingMessage, self).__init__(**kwargs) self.body = body self.app_properties = app_properties @@ -2607,23 +3144,23 @@ def __init__( class RoutingProperties(msrest.serialization.Model): """The routing related properties of the IoT hub. See: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-messaging. - :param endpoints: The properties related to the custom endpoints to which your IoT hub routes + :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. - :type endpoints: ~azure.mgmt.iothub.v2021_07_01.models.RoutingEndpoints - :param routes: The list of user-provided routing rules that the IoT hub uses to route messages + :vartype endpoints: ~azure.mgmt.iothub.v2021_07_01.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. - :type routes: list[~azure.mgmt.iothub.v2021_07_01.models.RouteProperties] - :param fallback_route: The properties of the route that is used as a fall-back route when none + :vartype routes: list[~azure.mgmt.iothub.v2021_07_01.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. - :type fallback_route: ~azure.mgmt.iothub.v2021_07_01.models.FallbackRouteProperties - :param enrichments: The list of user-provided enrichments that the IoT hub applies to messages + :vartype fallback_route: ~azure.mgmt.iothub.v2021_07_01.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. - :type enrichments: list[~azure.mgmt.iothub.v2021_07_01.models.EnrichmentProperties] + :vartype enrichments: list[~azure.mgmt.iothub.v2021_07_01.models.EnrichmentProperties] """ _attribute_map = { @@ -2642,6 +3179,26 @@ def __init__( enrichments: Optional[List["EnrichmentProperties"]] = None, **kwargs ): + """ + :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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.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.v2021_07_01.models.EnrichmentProperties] + """ super(RoutingProperties, self).__init__(**kwargs) self.endpoints = endpoints self.routes = routes @@ -2654,30 +3211,30 @@ class RoutingServiceBusQueueEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus queue endpoint. - :type id: str - :param connection_string: The connection string of the service bus queue endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus queue endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus namespace. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus queue endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing service bus queue endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus queue endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus queue endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus queue endpoint. - :type resource_group: str + :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 = { @@ -2710,6 +3267,32 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus queue endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingServiceBusQueueEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2727,30 +3310,30 @@ class RoutingServiceBusTopicEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the service bus topic endpoint. - :type id: str - :param connection_string: The connection string of the service bus topic endpoint. - :type connection_string: str - :param endpoint_uri: The url of the service bus topic endpoint. It must include the protocol + :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://. - :type endpoint_uri: str - :param entity_path: Queue name on the service bus topic. - :type entity_path: str - :param authentication_type: Method used to authenticate against the service bus topic endpoint. + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing service bus topic endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :ivar identity: Managed identity properties of routing service bus topic endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the service bus topic endpoint. - :type subscription_id: str - :param resource_group: The name of the resource group of the service bus topic endpoint. - :type resource_group: str + :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 = { @@ -2783,6 +3366,32 @@ def __init__( resource_group: Optional[str] = None, **kwargs ): + """ + :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. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :keyword identity: Managed identity properties of routing service bus topic endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :keyword name: Required. 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. + :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(RoutingServiceBusTopicEndpointProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2800,42 +3409,42 @@ class RoutingStorageContainerProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: Id of the storage container endpoint. - :type id: str - :param connection_string: The connection string of the storage account. - :type connection_string: str - :param endpoint_uri: The url of the storage endpoint. It must include the protocol https://. - :type endpoint_uri: str - :param authentication_type: Method used to authenticate against the storage endpoint. Possible + :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. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of routing storage endpoint. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity - :param name: Required. The name that identifies this endpoint. The name can only include + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :ivar identity: Managed identity properties of routing storage endpoint. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :ivar name: Required. 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. - :type name: str - :param subscription_id: The subscription identifier of the storage account. - :type subscription_id: str - :param resource_group: The name of the resource group of the storage account. - :type resource_group: str - :param container_name: Required. The name of storage container in the storage account. - :type container_name: str - :param file_name_format: File name format for the blob. Default format is + :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: Required. The name of storage container in the storage account. + :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. - :type file_name_format: str - :param batch_frequency_in_seconds: Time interval at which blobs are written to storage. Value + :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. - :type batch_frequency_in_seconds: int - :param max_chunk_size_in_bytes: Maximum number of bytes for each blob written to storage. Value + :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). - :type max_chunk_size_in_bytes: int - :param encoding: Encoding that is used to serialize messages to blobs. Supported values are + :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'. Possible values include: "Avro", "AvroDeflate", "JSON". - :type encoding: str or + :vartype encoding: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingStorageContainerPropertiesEncoding """ @@ -2880,6 +3489,45 @@ def __init__( encoding: Optional[Union[str, "RoutingStorageContainerPropertiesEncoding"]] = None, **kwargs ): + """ + :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. + Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :keyword identity: Managed identity properties of routing storage endpoint. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :keyword name: Required. 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. + :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: Required. The name of storage container in the storage account. + :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'. Possible values include: "Avro", + "AvroDeflate", "JSON". + :paramtype encoding: str or + ~azure.mgmt.iothub.v2021_07_01.models.RoutingStorageContainerPropertiesEncoding + """ super(RoutingStorageContainerProperties, self).__init__(**kwargs) self.id = id self.connection_string = connection_string @@ -2899,10 +3547,10 @@ def __init__( class RoutingTwin(msrest.serialization.Model): """Twin reference input parameter. This is an optional parameter. - :param tags: A set of tags. Twin Tags. - :type tags: any - :param properties: - :type properties: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwinProperties + :ivar tags: A set of tags. Twin Tags. + :vartype tags: any + :ivar properties: + :vartype properties: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwinProperties """ _attribute_map = { @@ -2917,6 +3565,12 @@ def __init__( properties: Optional["RoutingTwinProperties"] = None, **kwargs ): + """ + :keyword tags: A set of tags. Twin Tags. + :paramtype tags: any + :keyword properties: + :paramtype properties: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwinProperties + """ super(RoutingTwin, self).__init__(**kwargs) self.tags = tags self.properties = properties @@ -2925,10 +3579,10 @@ def __init__( class RoutingTwinProperties(msrest.serialization.Model): """RoutingTwinProperties. - :param desired: Twin desired properties. - :type desired: any - :param reported: Twin desired properties. - :type reported: any + :ivar desired: Twin desired properties. + :vartype desired: any + :ivar reported: Twin desired properties. + :vartype reported: any """ _attribute_map = { @@ -2943,6 +3597,12 @@ def __init__( reported: Optional[Any] = None, **kwargs ): + """ + :keyword desired: Twin desired properties. + :paramtype desired: any + :keyword reported: Twin desired properties. + :paramtype reported: any + """ super(RoutingTwinProperties, self).__init__(**kwargs) self.desired = desired self.reported = reported @@ -2953,20 +3613,20 @@ class SharedAccessSignatureAuthorizationRule(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param key_name: Required. The name of the shared access policy. - :type key_name: str - :param primary_key: The primary key. - :type primary_key: str - :param secondary_key: The secondary key. - :type secondary_key: str - :param rights: Required. The permissions assigned to the shared access policy. Possible values + :ivar key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". - :type rights: str or ~azure.mgmt.iothub.v2021_07_01.models.AccessRights + :vartype rights: str or ~azure.mgmt.iothub.v2021_07_01.models.AccessRights """ _validation = { @@ -2990,6 +3650,22 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. The name of the shared access policy. + :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: Required. The permissions assigned to the shared access policy. Possible + values include: "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", "RegistryRead, RegistryWrite, ServiceConnect, DeviceConnect". + :paramtype rights: str or ~azure.mgmt.iothub.v2021_07_01.models.AccessRights + """ super(SharedAccessSignatureAuthorizationRule, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -3002,8 +3678,9 @@ class SharedAccessSignatureAuthorizationRuleListResult(msrest.serialization.Mode Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of shared access policies. - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] + :ivar value: The list of shared access policies. + :vartype value: + list[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] :ivar next_link: The next link. :vartype next_link: str """ @@ -3023,6 +3700,11 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRule"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRule] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -3033,21 +3715,21 @@ class StorageEndpointProperties(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + :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. - :type sas_ttl_as_iso8601: ~datetime.timedelta - :param connection_string: Required. The connection string for the Azure Storage account to - which files are uploaded. - :type connection_string: str - :param container_name: Required. The name of the root container where you upload files. The + :vartype sas_ttl_as_iso8601: ~datetime.timedelta + :ivar connection_string: Required. The connection string for the Azure Storage account to which + files are uploaded. + :vartype connection_string: str + :ivar container_name: Required. The name of the root container where you upload files. The container need not exist but should be creatable using the connectionString specified. - :type container_name: str - :param authentication_type: Specifies authentication type being used for connecting to the + :vartype container_name: str + :ivar authentication_type: Specifies authentication type being used for connecting to the storage account. Possible values include: "keyBased", "identityBased". - :type authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType - :param identity: Managed identity properties of storage endpoint for file upload. - :type identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + :vartype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :ivar identity: Managed identity properties of storage endpoint for file upload. + :vartype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity """ _validation = { @@ -3073,6 +3755,23 @@ def __init__( identity: Optional["ManagedIdentity"] = None, **kwargs ): + """ + :keyword sas_ttl_as_iso8601: The period of time for which the SAS URI generated by IoT Hub for + file upload is valid. See: + https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-file-upload#file-upload-notification-configuration-options. + :paramtype sas_ttl_as_iso8601: ~datetime.timedelta + :keyword connection_string: Required. The connection string for the Azure Storage account to + which files are uploaded. + :paramtype connection_string: str + :keyword container_name: Required. The name of the root container where you upload files. The + container need not exist but should be creatable using the connectionString specified. + :paramtype container_name: str + :keyword authentication_type: Specifies authentication type being used for connecting to the + storage account. Possible values include: "keyBased", "identityBased". + :paramtype authentication_type: str or ~azure.mgmt.iothub.v2021_07_01.models.AuthenticationType + :keyword identity: Managed identity properties of storage endpoint for file upload. + :paramtype identity: ~azure.mgmt.iothub.v2021_07_01.models.ManagedIdentity + """ super(StorageEndpointProperties, self).__init__(**kwargs) self.sas_ttl_as_iso8601 = sas_ttl_as_iso8601 self.connection_string = connection_string @@ -3084,8 +3783,8 @@ def __init__( class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on an IoT Hub instance. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -3098,6 +3797,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsResource, self).__init__(**kwargs) self.tags = tags @@ -3105,14 +3808,14 @@ def __init__( class TestAllRoutesInput(msrest.serialization.Model): """Input for testing all routes. - :param routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + :ivar routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", "DeviceConnectionStateEvents". - :type routing_source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin + :vartype routing_source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin """ _attribute_map = { @@ -3129,6 +3832,16 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword routing_source: Routing source. Possible values include: "Invalid", "DeviceMessages", + "TwinChangeEvents", "DeviceLifecycleEvents", "DeviceJobLifecycleEvents", + "DeviceConnectionStateEvents". + :paramtype routing_source: str or ~azure.mgmt.iothub.v2021_07_01.models.RoutingSource + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin + """ super(TestAllRoutesInput, self).__init__(**kwargs) self.routing_source = routing_source self.message = message @@ -3138,8 +3851,8 @@ def __init__( class TestAllRoutesResult(msrest.serialization.Model): """Result of testing all routes. - :param routes: JSON-serialized array of matched routes. - :type routes: list[~azure.mgmt.iothub.v2021_07_01.models.MatchedRoute] + :ivar routes: JSON-serialized array of matched routes. + :vartype routes: list[~azure.mgmt.iothub.v2021_07_01.models.MatchedRoute] """ _attribute_map = { @@ -3152,6 +3865,10 @@ def __init__( routes: Optional[List["MatchedRoute"]] = None, **kwargs ): + """ + :keyword routes: JSON-serialized array of matched routes. + :paramtype routes: list[~azure.mgmt.iothub.v2021_07_01.models.MatchedRoute] + """ super(TestAllRoutesResult, self).__init__(**kwargs) self.routes = routes @@ -3161,12 +3878,12 @@ class TestRouteInput(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param message: Routing message. - :type message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage - :param route: Required. Route properties. - :type route: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties - :param twin: Routing Twin Reference. - :type twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin + :ivar message: Routing message. + :vartype message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage + :ivar route: Required. Route properties. + :vartype route: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties + :ivar twin: Routing Twin Reference. + :vartype twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin """ _validation = { @@ -3187,6 +3904,14 @@ def __init__( twin: Optional["RoutingTwin"] = None, **kwargs ): + """ + :keyword message: Routing message. + :paramtype message: ~azure.mgmt.iothub.v2021_07_01.models.RoutingMessage + :keyword route: Required. Route properties. + :paramtype route: ~azure.mgmt.iothub.v2021_07_01.models.RouteProperties + :keyword twin: Routing Twin Reference. + :paramtype twin: ~azure.mgmt.iothub.v2021_07_01.models.RoutingTwin + """ super(TestRouteInput, self).__init__(**kwargs) self.message = message self.route = route @@ -3196,10 +3921,10 @@ def __init__( class TestRouteResult(msrest.serialization.Model): """Result of testing one route. - :param result: Result of testing route. Possible values include: "undefined", "false", "true". - :type result: str or ~azure.mgmt.iothub.v2021_07_01.models.TestResultStatus - :param details: Detailed result of testing route. - :type details: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResultDetails + :ivar result: Result of testing route. Possible values include: "undefined", "false", "true". + :vartype result: str or ~azure.mgmt.iothub.v2021_07_01.models.TestResultStatus + :ivar details: Detailed result of testing route. + :vartype details: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResultDetails """ _attribute_map = { @@ -3214,6 +3939,13 @@ def __init__( details: Optional["TestRouteResultDetails"] = None, **kwargs ): + """ + :keyword result: Result of testing route. Possible values include: "undefined", "false", + "true". + :paramtype result: str or ~azure.mgmt.iothub.v2021_07_01.models.TestResultStatus + :keyword details: Detailed result of testing route. + :paramtype details: ~azure.mgmt.iothub.v2021_07_01.models.TestRouteResultDetails + """ super(TestRouteResult, self).__init__(**kwargs) self.result = result self.details = details @@ -3222,8 +3954,8 @@ def __init__( class TestRouteResultDetails(msrest.serialization.Model): """Detailed result of testing a route. - :param compilation_errors: JSON-serialized list of route compilation errors. - :type compilation_errors: list[~azure.mgmt.iothub.v2021_07_01.models.RouteCompilationError] + :ivar compilation_errors: JSON-serialized list of route compilation errors. + :vartype compilation_errors: list[~azure.mgmt.iothub.v2021_07_01.models.RouteCompilationError] """ _attribute_map = { @@ -3236,6 +3968,11 @@ def __init__( compilation_errors: Optional[List["RouteCompilationError"]] = None, **kwargs ): + """ + :keyword compilation_errors: JSON-serialized list of route compilation errors. + :paramtype compilation_errors: + list[~azure.mgmt.iothub.v2021_07_01.models.RouteCompilationError] + """ super(TestRouteResultDetails, self).__init__(**kwargs) self.compilation_errors = compilation_errors @@ -3243,18 +3980,18 @@ def __init__( class UserSubscriptionQuota(msrest.serialization.Model): """User subscription quota response. - :param id: IotHub type id. - :type id: str - :param type: Response type. - :type type: str - :param unit: Unit of IotHub type. - :type unit: str - :param current_value: Current number of IotHub type. - :type current_value: int - :param limit: Numerical limit on IotHub type. - :type limit: int - :param name: IotHub type. - :type name: ~azure.mgmt.iothub.v2021_07_01.models.Name + :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.v2021_07_01.models.Name """ _attribute_map = { @@ -3277,6 +4014,20 @@ def __init__( name: Optional["Name"] = None, **kwargs ): + """ + :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.v2021_07_01.models.Name + """ super(UserSubscriptionQuota, self).__init__(**kwargs) self.id = id self.type = type @@ -3291,8 +4042,8 @@ class UserSubscriptionQuotaListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: - :type value: list[~azure.mgmt.iothub.v2021_07_01.models.UserSubscriptionQuota] + :ivar value: + :vartype value: list[~azure.mgmt.iothub.v2021_07_01.models.UserSubscriptionQuota] :ivar next_link: :vartype next_link: str """ @@ -3312,6 +4063,10 @@ def __init__( value: Optional[List["UserSubscriptionQuota"]] = None, **kwargs ): + """ + :keyword value: + :paramtype value: list[~azure.mgmt.iothub.v2021_07_01.models.UserSubscriptionQuota] + """ super(UserSubscriptionQuotaListResult, self).__init__(**kwargs) self.value = value self.next_link = None diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py index cb70d45419e0..17c6e3a304c3 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_certificates_operations.py @@ -5,22 +5,274 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_generate_verification_code_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_verify_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + certificate_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class CertificatesOperations(object): """CertificatesOperations operations. @@ -44,13 +296,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_iot_hub( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get the certificate list. Returns the list of certificates. @@ -69,33 +321,23 @@ def list_by_iot_hub( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.list_by_iot_hub.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_by_iot_hub_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_by_iot_hub.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateListDescription', pipeline_response) @@ -104,16 +346,18 @@ def list_by_iot_hub( return cls(pipeline_response, deserialized, {}) return deserialized + list_by_iot_hub.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + **kwargs: Any + ) -> "_models.CertificateDescription": """Get the certificate. Returns the certificate. @@ -134,34 +378,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -170,18 +404,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + certificate_description: "_models.CertificateDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateDescription": """Upload the certificate to the IoT hub. Adds new or replaces existing certificate. @@ -207,41 +443,30 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_description, 'CertificateDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_description, 'CertificateDescription') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if response.status_code == 200: @@ -254,17 +479,19 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -287,35 +514,25 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.delete.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -323,15 +540,16 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def generate_verification_code( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateWithNonceDescription" + 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 @@ -355,35 +573,25 @@ def generate_verification_code( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.generate_verification_code.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_generate_verification_code_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + if_match=if_match, + template_url=self.generate_verification_code.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateWithNonceDescription', pipeline_response) @@ -392,18 +600,20 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify( self, - resource_group_name, # type: str - resource_name, # type: str - certificate_name, # type: str - if_match, # type: str - certificate_verification_body, # type: "_models.CertificateVerificationDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateDescription" + resource_group_name: str, + resource_name: str, + certificate_name: str, + if_match: str, + certificate_verification_body: "_models.CertificateVerificationDescription", + **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 @@ -418,7 +628,8 @@ def verify( :param if_match: ETag of the Certificate. :type if_match: str :param certificate_verification_body: The name of the certificate. - :type certificate_verification_body: ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription + :type certificate_verification_body: + ~azure.mgmt.iothub.v2021_07_01.models.CertificateVerificationDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: CertificateDescription, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.CertificateDescription @@ -429,40 +640,30 @@ def verify( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.verify.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', pattern=r'^[A-Za-z0-9-._]{1,64}$'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(certificate_verification_body, 'CertificateVerificationDescription') + + request = build_verify_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + certificate_name=certificate_name, + content_type=content_type, + if_match=if_match, + json=_json, + template_url=self.verify.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateDescription', pipeline_response) @@ -471,4 +672,6 @@ def verify( return cls(pipeline_response, deserialized, {}) return deserialized + verify.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py index 0c1633b87c2a..bd2145e69f1e 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_operations.py @@ -5,24 +5,71 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_manual_failover_request_initial( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubOperations(object): """IotHubOperations operations. @@ -48,64 +95,53 @@ def __init__(self, client, config, serializer, deserializer): def _manual_failover_initial( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> None + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._manual_failover_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(failover_input, 'FailoverInput') + + request = build_manual_failover_request_initial( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self._manual_failover_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(failover_input, 'FailoverInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _manual_failover_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore + + @distributed_trace def begin_manual_failover( self, - iot_hub_name, # type: str - resource_group_name, # type: str - failover_input, # type: "_models.FailoverInput" - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + iot_hub_name: str, + resource_group_name: str, + failover_input: "_models.FailoverInput", + **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 @@ -121,15 +157,18 @@ def begin_manual_failover( :type failover_input: ~azure.mgmt.iothub.v2021_07_01.models.FailoverInput :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -141,24 +180,18 @@ def begin_manual_failover( iot_hub_name=iot_hub_name, resource_group_name=resource_group_name, failover_input=failover_input, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -170,4 +203,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_manual_failover.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/failover'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py index 21d82dbf997a..f4cfb1ea2ee7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_iot_hub_resource_operations.py @@ -5,25 +5,916 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if if_match is not None: + header_parameters['If-Match'] = _SERIALIZER.header("if_match", if_match, 'str') + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_stats_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_valid_skus_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_event_hub_consumer_groups_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_event_hub_consumer_group_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_jobs_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_job_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + job_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_quota_metrics_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_endpoint_health_request( + subscription_id: str, + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_name_availability_request( + subscription_id: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_all_routes_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_test_route_request( + iot_hub_name: str, + subscription_id: str, + resource_group_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_keys_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_keys_for_key_name_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + key_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_export_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_import_devices_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class IotHubResourceOperations(object): """IotHubResourceOperations operations. @@ -47,13 +938,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + 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. @@ -72,33 +963,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -107,57 +988,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_description, 'IotHubDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_description, 'IotHubDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + if_match=if_match, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('IotHubDescription', pipeline_response) @@ -169,17 +1039,19 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_description, # type: "_models.IotHubDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_description: "_models.IotHubDescription", + 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 @@ -199,15 +1071,19 @@ def begin_create_or_update( :type if_match: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -220,27 +1096,21 @@ def begin_create_or_update( resource_name=resource_name, iot_hub_description=iot_hub_description, if_match=if_match, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -252,47 +1122,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubDescription" + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.IotHubDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(iot_hub_tags, 'TagsResource') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(iot_hub_tags, 'TagsResource') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response @@ -306,16 +1166,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - iot_hub_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.IotHubDescription"] + resource_group_name: str, + resource_name: str, + iot_hub_tags: "_models.TagsResource", + **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. @@ -328,15 +1190,19 @@ def begin_update( :type iot_hub_tags: ~azure.mgmt.iothub.v2021_07_01.models.TagsResource :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -348,27 +1214,21 @@ def begin_update( resource_group_name=resource_group_name, resource_name=resource_name, iot_hub_tags=iot_hub_tags, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -380,48 +1240,37 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: cls = kwargs.pop('cls', None) # type: ClsType[Optional[Union["_models.IotHubDescription", "_models.ErrorDetails"]]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204, 404]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -437,15 +1286,17 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> LROPoller[Union["_models.IotHubDescription", "_models.ErrorDetails"]]: """Delete an IoT hub. Delete an IoT hub. @@ -456,15 +1307,19 @@ def begin_delete( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either IotHubDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either IotHubDescription or ErrorDetails or the + result of cls(response) + :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescription + or ~azure.mgmt.iothub.v2021_07_01.models.ErrorDetails] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[Union["_models.IotHubDescription", "_models.ErrorDetails"]] lro_delay = kwargs.pop( 'polling_interval', @@ -478,24 +1333,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('IotHubDescription', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -507,20 +1355,23 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a subscription. Get all the IoT hubs in a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -528,34 +1379,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -568,23 +1414,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubDescriptionListResult"]: """Get all the IoT hubs in a resource group. Get all the IoT hubs in a resource group. @@ -592,8 +1439,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group that contains the IoT hub. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] + :return: An iterator like instance of either IotHubDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubDescriptionListResult"] @@ -601,35 +1450,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -642,24 +1487,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs'} # type: ignore + @distributed_trace def get_stats( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.RegistryStatistics" + 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. @@ -678,33 +1524,23 @@ def get_stats( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_stats.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_stats_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_stats.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('RegistryStatistics', pipeline_response) @@ -713,15 +1549,17 @@ def get_stats( return cls(pipeline_response, deserialized, {}) return deserialized + get_stats.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubStats'} # type: ignore + + @distributed_trace def get_valid_skus( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubSkuDescriptionListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubSkuDescriptionListResult"]: """Get the list of valid SKUs for an IoT hub. Get the list of valid SKUs for an IoT hub. @@ -731,8 +1569,10 @@ def get_valid_skus( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescriptionListResult] + :return: An iterator like instance of either IotHubSkuDescriptionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubSkuDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubSkuDescriptionListResult"] @@ -740,36 +1580,33 @@ def get_valid_skus( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_valid_skus.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_valid_skus_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubSkuDescriptionListResult', pipeline_response) + deserialized = self._deserialize("IotHubSkuDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -782,26 +1619,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/skus'} # type: ignore + @distributed_trace def list_event_hub_consumer_groups( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EventHubConsumerGroupsListResult"] - """Get a list of the consumer groups in the Event Hub-compatible device-to-cloud endpoint in an IoT hub. + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + **kwargs: Any + ) -> Iterable["_models.EventHubConsumerGroupsListResult"]: + """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. @@ -813,8 +1652,10 @@ def list_event_hub_consumer_groups( :param event_hub_endpoint_name: The name of the Event Hub-compatible endpoint. :type event_hub_endpoint_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupsListResult] + :return: An iterator like instance of either EventHubConsumerGroupsListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EventHubConsumerGroupsListResult"] @@ -822,37 +1663,35 @@ def list_event_hub_consumer_groups( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_event_hub_consumer_groups.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=self.list_event_hub_consumer_groups.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_event_hub_consumer_groups_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EventHubConsumerGroupsListResult', pipeline_response) + deserialized = self._deserialize("EventHubConsumerGroupsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -865,26 +1704,27 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_event_hub_consumer_groups.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups'} # type: ignore + @distributed_trace def get_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + 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. @@ -907,35 +1747,25 @@ def get_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.get_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -944,18 +1774,20 @@ def get_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + get_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def create_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - consumer_group_body, # type: "_models.EventHubConsumerGroupBodyDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.EventHubConsumerGroupInfo" + resource_group_name: str, + resource_name: str, + event_hub_endpoint_name: str, + name: str, + consumer_group_body: "_models.EventHubConsumerGroupBodyDescription", + **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. @@ -969,7 +1801,8 @@ def create_event_hub_consumer_group( :param name: The name of the consumer group to add. :type name: str :param consumer_group_body: The consumer group to add. - :type consumer_group_body: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription + :type consumer_group_body: + ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupBodyDescription :keyword callable cls: A custom type or function that will be passed the direct response :return: EventHubConsumerGroupInfo, or the result of cls(response) :rtype: ~azure.mgmt.iothub.v2021_07_01.models.EventHubConsumerGroupInfo @@ -980,40 +1813,30 @@ def create_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') + + request = build_create_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + content_type=content_type, + json=_json, + template_url=self.create_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(consumer_group_body, 'EventHubConsumerGroupBodyDescription') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('EventHubConsumerGroupInfo', pipeline_response) @@ -1022,17 +1845,19 @@ def create_event_hub_consumer_group( return cls(pipeline_response, deserialized, {}) return deserialized + create_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def delete_event_hub_consumer_group( self, - resource_group_name, # type: str - resource_name, # type: str - event_hub_endpoint_name, # type: str - name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + 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. @@ -1055,35 +1880,25 @@ def delete_event_hub_consumer_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.delete_event_hub_consumer_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'eventHubEndpointName': self._serialize.url("event_hub_endpoint_name", event_hub_endpoint_name, 'str'), - 'name': self._serialize.url("name", name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_event_hub_consumer_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + event_hub_endpoint_name=event_hub_endpoint_name, + name=name, + template_url=self.delete_event_hub_consumer_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) if cls: @@ -1091,14 +1906,16 @@ def delete_event_hub_consumer_group( delete_event_hub_consumer_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/eventHubEndpoints/{eventHubEndpointName}/ConsumerGroups/{name}'} # type: ignore + + @distributed_trace def list_jobs( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.JobResponseListResult"] - """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. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.JobResponseListResult"]: + """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. @@ -1108,8 +1925,10 @@ def list_jobs( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either JobResponseListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponseListResult] + :return: An iterator like instance of either JobResponseListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.JobResponseListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobResponseListResult"] @@ -1117,36 +1936,33 @@ def list_jobs( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_jobs.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_jobs.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_jobs_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('JobResponseListResult', pipeline_response) + deserialized = self._deserialize("JobResponseListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1159,26 +1975,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_jobs.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs'} # type: ignore + @distributed_trace def get_job( self, - resource_group_name, # type: str - resource_name, # type: str - job_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1199,34 +2017,24 @@ def get_job( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_job.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_job_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + job_id=job_id, + template_url=self.get_job.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1235,15 +2043,17 @@ def get_job( return cls(pipeline_response, deserialized, {}) return deserialized + get_job.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def get_quota_metrics( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotHubQuotaMetricInfoListResult"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.IotHubQuotaMetricInfoListResult"]: """Get the quota metrics for an IoT hub. Get the quota metrics for an IoT hub. @@ -1253,8 +2063,10 @@ def get_quota_metrics( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfoListResult] + :return: An iterator like instance of either IotHubQuotaMetricInfoListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.IotHubQuotaMetricInfoListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotHubQuotaMetricInfoListResult"] @@ -1262,36 +2074,33 @@ def get_quota_metrics( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_quota_metrics.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get_quota_metrics.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_quota_metrics_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('IotHubQuotaMetricInfoListResult', pipeline_response) + deserialized = self._deserialize("IotHubQuotaMetricInfoListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1304,24 +2113,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_quota_metrics.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/quotaMetrics'} # type: ignore + @distributed_trace def get_endpoint_health( self, - resource_group_name, # type: str - iot_hub_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.EndpointHealthDataListResult"] + resource_group_name: str, + iot_hub_name: str, + **kwargs: Any + ) -> Iterable["_models.EndpointHealthDataListResult"]: """Get the health for routing endpoints. Get the health for routing endpoints. @@ -1331,8 +2141,10 @@ def get_endpoint_health( :param iot_hub_name: :type iot_hub_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either EndpointHealthDataListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthDataListResult] + :return: An iterator like instance of either EndpointHealthDataListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.EndpointHealthDataListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.EndpointHealthDataListResult"] @@ -1340,36 +2152,33 @@ def get_endpoint_health( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.get_endpoint_health.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=self.get_endpoint_health.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_endpoint_health_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + iot_hub_name=iot_hub_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('EndpointHealthDataListResult', pipeline_response) + deserialized = self._deserialize("EndpointHealthDataListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1382,23 +2191,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) get_endpoint_health.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routingEndpointsHealth'} # type: ignore + @distributed_trace def check_name_availability( self, - operation_inputs, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.IotHubNameAvailabilityInfo" + operation_inputs: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.IotHubNameAvailabilityInfo": """Check if an IoT hub name is available. Check if an IoT hub name is available. @@ -1416,36 +2226,26 @@ def check_name_availability( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.check_name_availability.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(operation_inputs, 'OperationInputs') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(operation_inputs, 'OperationInputs') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('IotHubNameAvailabilityInfo', pipeline_response) @@ -1454,16 +2254,18 @@ def check_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkNameAvailability'} # type: ignore + + @distributed_trace def test_all_routes( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestAllRoutesInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestAllRoutesResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestAllRoutesInput", + **kwargs: Any + ) -> "_models.TestAllRoutesResult": """Test all routes. Test all routes configured in this Iot Hub. @@ -1484,38 +2286,28 @@ def test_all_routes( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_all_routes.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestAllRoutesInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_all_routes_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_all_routes.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestAllRoutesInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestAllRoutesResult', pipeline_response) @@ -1524,16 +2316,18 @@ def test_all_routes( return cls(pipeline_response, deserialized, {}) return deserialized + test_all_routes.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testall'} # type: ignore + + @distributed_trace def test_route( self, - iot_hub_name, # type: str - resource_group_name, # type: str - input, # type: "_models.TestRouteInput" - **kwargs # type: Any - ): - # type: (...) -> "_models.TestRouteResult" + iot_hub_name: str, + resource_group_name: str, + input: "_models.TestRouteInput", + **kwargs: Any + ) -> "_models.TestRouteResult": """Test the new route. Test the new route for this Iot Hub. @@ -1554,38 +2348,28 @@ def test_route( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.test_route.metadata['url'] # type: ignore - path_format_arguments = { - 'iotHubName': self._serialize.url("iot_hub_name", iot_hub_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(input, 'TestRouteInput') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_test_route_request( + iot_hub_name=iot_hub_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + content_type=content_type, + json=_json, + template_url=self.test_route.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(input, 'TestRouteInput') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('TestRouteResult', pipeline_response) @@ -1594,16 +2378,19 @@ def test_route( return cls(pipeline_response, deserialized, {}) return deserialized + test_route.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{iotHubName}/routing/routes/$testnew'} # type: ignore + + @distributed_trace def list_keys( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] - """Get the security metadata for an IoT hub. For more information, see: https://docs.microsoft.com/azure/iot-hub/iot-hub-devguide-security. + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: + """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. @@ -1613,8 +2400,10 @@ def list_keys( :param resource_name: The name of the IoT hub. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothub.v2021_07_01.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -1622,36 +2411,33 @@ def list_keys( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_keys.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_keys.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_keys_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -1664,26 +2450,28 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_keys.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/listkeys'} # type: ignore + @distributed_trace def get_keys_for_key_name( self, - resource_group_name, # type: str - resource_name, # type: str - key_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_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. + 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. @@ -1704,34 +2492,24 @@ def get_keys_for_key_name( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'keyName': self._serialize.url("key_name", key_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_keys_for_key_name_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + key_name=key_name, + template_url=self.get_keys_for_key_name.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.post(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('SharedAccessSignatureAuthorizationRule', pipeline_response) @@ -1740,17 +2518,21 @@ def get_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + get_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/IotHubKeys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def export_devices( self, - resource_group_name, # type: str - resource_name, # type: str - export_devices_parameters, # type: "_models.ExportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + export_devices_parameters: "_models.ExportDevicesRequest", + **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: @@ -1772,38 +2554,28 @@ def export_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.export_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_export_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.export_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(export_devices_parameters, 'ExportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1812,17 +2584,21 @@ def export_devices( return cls(pipeline_response, deserialized, {}) return deserialized + export_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/exportDevices'} # type: ignore + + @distributed_trace def import_devices( self, - resource_group_name, # type: str - resource_name, # type: str - import_devices_parameters, # type: "_models.ImportDevicesRequest" - **kwargs # type: Any - ): - # type: (...) -> "_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. + resource_group_name: str, + resource_name: str, + import_devices_parameters: "_models.ImportDevicesRequest", + **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: @@ -1844,38 +2620,28 @@ def import_devices( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.import_devices.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') + + request = build_import_devices_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.import_devices.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(import_devices_parameters, 'ImportDevicesRequest') - body_content_kwargs['content'] = body_content - request = self._client.post(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('JobResponse', pipeline_response) @@ -1884,4 +2650,6 @@ def import_devices( return cls(pipeline_response, deserialized, {}) return deserialized + import_devices.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/IotHubs/{resourceName}/importDevices'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py index 1a1761258b1f..f537383113e7 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_operations.py @@ -5,23 +5,50 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Devices/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationListResult"]: """Lists all of the available IoT Hub REST API operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationListResult', pipeline_response) + deserialized = self._deserialize("OperationListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) map_error(status_code=response.status_code, 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/v2021_07_01/operations/_private_endpoint_connections_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py index 201961a3f22c..2cecc8862475 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_endpoint_connections_operations.py @@ -5,24 +5,182 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, List, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateEndpointConnectionsOperations(object): """PrivateEndpointConnectionsOperations operations. @@ -46,13 +204,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> List["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> List["_models.PrivateEndpointConnection"]: """List private endpoint connections. List private endpoint connection properties. @@ -71,33 +229,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('[PrivateEndpointConnection]', pipeline_response) @@ -106,16 +254,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + 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. @@ -136,34 +286,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -172,56 +312,46 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _update_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateEndpointConnection" + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> "_models.PrivateEndpointConnection": cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + content_type=content_type, + json=_json, + template_url=self._update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(private_endpoint_connection, 'PrivateEndpointConnection') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **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, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) @@ -233,17 +363,19 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - private_endpoint_connection, # type: "_models.PrivateEndpointConnection" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + private_endpoint_connection: "_models.PrivateEndpointConnection", + **kwargs: Any + ) -> LROPoller["_models.PrivateEndpointConnection"]: """Update private endpoint connection. Update the status of a private endpoint connection with the specified name. @@ -255,18 +387,24 @@ def begin_update( :param private_endpoint_connection_name: The name of the private endpoint connection. :type private_endpoint_connection_name: str :param private_endpoint_connection: The private endpoint connection with updated properties. - :type private_endpoint_connection: ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -279,28 +417,21 @@ def begin_update( resource_name=resource_name, private_endpoint_connection_name=private_endpoint_connection_name, private_endpoint_connection=private_endpoint_connection, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -312,50 +443,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_initial( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.PrivateEndpointConnection"] + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any + ) -> Optional["_models.PrivateEndpointConnection"]: cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.PrivateEndpointConnection"]] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + private_endpoint_connection_name=private_endpoint_connection_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) deserialized = None if response.status_code == 200: @@ -368,16 +488,18 @@ def _delete_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - resource_name, # type: str - private_endpoint_connection_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.PrivateEndpointConnection"] + 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. @@ -390,15 +512,19 @@ def begin_delete( :type private_endpoint_connection_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] - :raises ~azure.core.exceptions.HttpResponseError: + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either PrivateEndpointConnection or the result + of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothub.v2021_07_01.models.PrivateEndpointConnection] + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.PrivateEndpointConnection"] lro_delay = kwargs.pop( 'polling_interval', @@ -413,25 +539,17 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('PrivateEndpointConnection', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'privateEndpointConnectionName': self._serialize.url("private_endpoint_connection_name", private_endpoint_connection_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -443,4 +561,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py index fbd771d5cd42..b23e32727caf 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_private_link_resources_operations.py @@ -5,22 +5,96 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-07-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}') + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class PrivateLinkResourcesOperations(object): """PrivateLinkResourcesOperations operations. @@ -44,13 +118,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.PrivateLinkResources" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.PrivateLinkResources": """List private link resources. List private link resources for the given IotHub. @@ -69,33 +143,23 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('PrivateLinkResources', pipeline_response) @@ -104,16 +168,18 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - group_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.GroupIdInformation" + 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. @@ -134,34 +200,24 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'groupId': self._serialize.url("group_id", group_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + group_id=group_id, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('GroupIdInformation', pipeline_response) @@ -170,4 +226,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/iotHubs/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py index 3663daf69b22..8d1262788fb2 100644 --- a/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py +++ b/sdk/iothub/azure-mgmt-iothub/azure/mgmt/iothub/v2021_07_01/operations/_resource_provider_common_operations.py @@ -5,22 +5,55 @@ # 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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +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: + api_version = "2021-07-01" + 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 = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ResourceProviderCommonOperations(object): """ResourceProviderCommonOperations operations. @@ -44,11 +77,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_subscription_quota( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.UserSubscriptionQuotaListResult" + **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. @@ -63,31 +96,21 @@ def get_subscription_quota( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-07-01" - accept = "application/json" - - # Construct URL - url = self.get_subscription_quota.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_get_subscription_quota_request( + subscription_id=self._config.subscription_id, + template_url=self.get_subscription_quota.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('UserSubscriptionQuotaListResult', pipeline_response) @@ -96,4 +119,6 @@ def get_subscription_quota( return cls(pipeline_response, deserialized, {}) return deserialized + get_subscription_quota.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/usages'} # type: ignore +