diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md b/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md index e296ced163ee..0e238c69fd27 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/CHANGELOG.md @@ -1,5 +1,14 @@ # Release History +## 1.1.0 (2022-02-07) + +**Features** + + - Model CertificateResponse has a new parameter system_data + - Model IotDpsPropertiesDescription has a new parameter enable_data_residency + - Model PrivateEndpointConnection has a new parameter system_data + - Model ProvisioningServiceDescription has a new parameter system_data + ## 1.0.0 (2021-08-18) **Features** diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/_meta.json b/sdk/iothub/azure-mgmt-iothubprovisioningservices/_meta.json index 9a155702e00a..1fb827bbaeab 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/_meta.json +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/_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": "933b6d3d88fd5fc93be36731c2837b7b109ba49a", + "commit": "1134038a45bd1e65b1f6d77351b17df3617388f1", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/deviceprovisioningservices/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/deviceprovisioningservices/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/deviceprovisioningservices/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py index b5e3690011d6..ae180a5867e1 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['IotDpsClient'] -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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_configuration.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_configuration.py index 405f264e3bbf..56f64e498d4e 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_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,20 +33,19 @@ class IotDpsClientConfiguration(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(IotDpsClientConfiguration, 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(IotDpsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-03-01" + self.api_version = "2021-10-15" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-iothubprovisioningservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py index 014d5efa2400..a628fc94cabc 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_iot_dps_client.py @@ -6,84 +6,86 @@ # 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 IotDpsClientConfiguration +from .operations import DpsCertificateOperations, IotDpsResourceOperations, 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 IotDpsClientConfiguration -from .operations import Operations -from .operations import DpsCertificateOperations -from .operations import IotDpsResourceOperations -from . import models - -class IotDpsClient(object): +class IotDpsClient: """API for using the Azure IoT Hub Device Provisioning Service features. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothubprovisioningservices.operations.Operations :ivar dps_certificate: DpsCertificateOperations operations - :vartype dps_certificate: azure.mgmt.iothubprovisioningservices.operations.DpsCertificateOperations + :vartype dps_certificate: + azure.mgmt.iothubprovisioningservices.operations.DpsCertificateOperations :ivar iot_dps_resource: IotDpsResourceOperations operations - :vartype iot_dps_resource: azure.mgmt.iothubprovisioningservices.operations.IotDpsResourceOperations + :vartype iot_dps_resource: + azure.mgmt.iothubprovisioningservices.operations.IotDpsResourceOperations :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 = IotDpsClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = IotDpsClientConfiguration(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.dps_certificate = DpsCertificateOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_dps_resource = IotDpsResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.dps_certificate = DpsCertificateOperations( - self._client, self._config, self._serialize, self._deserialize) - self.iot_dps_resource = IotDpsResourceOperations( - 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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json index 29371a3a47cf..e993676a8c68 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2020-03-01", - "total_api_version_list": ["2020-03-01"], + "chosen_version": "2021-10-15", + "total_api_version_list": ["2021-10-15"], "client": { "name": "IotDpsClient", "filename": "_iot_dps_client", "description": "API for using the Azure IoT Hub Device Provisioning Service features.", - "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\": [\"IotDpsClientConfiguration\"]}}, \"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\": [\"IotDpsClientConfiguration\"]}}, \"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\": [\"IotDpsClientConfiguration\"]}}, \"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\": [\"IotDpsClientConfiguration\"]}}, \"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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_patch.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_vendor.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py index c47f66669f1b..59deb8c7263b 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.1.0" diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py index 8e34e5ce2b5e..c8929d76b8ae 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/__init__.py @@ -8,3 +8,8 @@ from ._iot_dps_client import IotDpsClient __all__ = ['IotDpsClient'] + +# `._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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_configuration.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_configuration.py index 369882d4724b..66c5084c7e5f 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_configuration.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/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,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(IotDpsClientConfiguration, 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(IotDpsClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2020-03-01" + self.api_version = "2021-10-15" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-iothubprovisioningservices/{}'.format(VERSION)) self._configure(**kwargs) @@ -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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py index 5fde1ad85d8f..f82d1c38896d 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_iot_dps_client.py @@ -6,80 +6,86 @@ # 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 IotDpsClientConfiguration +from .operations import DpsCertificateOperations, IotDpsResourceOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import IotDpsClientConfiguration -from .operations import Operations -from .operations import DpsCertificateOperations -from .operations import IotDpsResourceOperations -from .. import models - - -class IotDpsClient(object): +class IotDpsClient: """API for using the Azure IoT Hub Device Provisioning Service features. :ivar operations: Operations operations :vartype operations: azure.mgmt.iothubprovisioningservices.aio.operations.Operations :ivar dps_certificate: DpsCertificateOperations operations - :vartype dps_certificate: azure.mgmt.iothubprovisioningservices.aio.operations.DpsCertificateOperations + :vartype dps_certificate: + azure.mgmt.iothubprovisioningservices.aio.operations.DpsCertificateOperations :ivar iot_dps_resource: IotDpsResourceOperations operations - :vartype iot_dps_resource: azure.mgmt.iothubprovisioningservices.aio.operations.IotDpsResourceOperations + :vartype iot_dps_resource: + azure.mgmt.iothubprovisioningservices.aio.operations.IotDpsResourceOperations :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 = IotDpsClientConfiguration(credential, subscription_id, **kwargs) + self._config = IotDpsClientConfiguration(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.dps_certificate = DpsCertificateOperations(self._client, self._config, self._serialize, self._deserialize) + self.iot_dps_resource = IotDpsResourceOperations(self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.dps_certificate = DpsCertificateOperations( - self._client, self._config, self._serialize, self._deserialize) - self.iot_dps_resource = IotDpsResourceOperations( - 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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_patch.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py index 02951540ce7d..cc88345014b9 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_dps_certificate_operations.py @@ -6,16 +6,20 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime +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._dps_certificate_operations import build_create_or_update_request, build_delete_request, build_generate_verification_code_request, build_get_request, build_list_request, build_verify_certificate_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, certificate_name: str, @@ -70,36 +75,25 @@ 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 = { - 'certificateName': self._serialize.url("certificate_name", certificate_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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(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( + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + if_match=if_match, + 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] - if if_match is not None: - header_parameters['If-Match'] = self._serialize.header("if_match", if_match, 'str') - 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('CertificateResponse', pipeline_response) @@ -108,8 +102,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -130,7 +127,8 @@ async def create_or_update( :param certificate_name: The name of the certificate create or update. :type certificate_name: str :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothubprovisioningservices.models.CertificateBodyDescription + :type certificate_description: + ~azure.mgmt.iothubprovisioningservices.models.CertificateBodyDescription :param if_match: ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. :type if_match: str @@ -144,41 +142,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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', max_length=256, min_length=0), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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, + provisioning_service_name=provisioning_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateResponse', pipeline_response) @@ -187,8 +174,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/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -226,7 +216,8 @@ async def delete( private key. :type certificate_is_verified: bool :param certificate_purpose: A description that mentions the purpose of the certificate. - :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose :param certificate_created: Time the certificate is created. :type certificate_created: ~datetime.datetime :param certificate_last_updated: Time the certificate is last updated. @@ -245,51 +236,33 @@ 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if certificate_name1 is not None: - query_parameters['certificate.name'] = self._serialize.query("certificate_name1", certificate_name1, 'str') - if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = self._serialize.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') - if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = self._serialize.query("certificate_is_verified", certificate_is_verified, 'bool') - if certificate_purpose is not None: - query_parameters['certificate.purpose'] = self._serialize.query("certificate_purpose", certificate_purpose, 'str') - if certificate_created is not None: - query_parameters['certificate.created'] = self._serialize.query("certificate_created", certificate_created, 'iso-8601') - if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = self._serialize.query("certificate_last_updated", certificate_last_updated, 'iso-8601') - if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificate_has_private_key", certificate_has_private_key, 'bool') - if certificate_nonce is not None: - query_parameters['certificate.nonce'] = self._serialize.query("certificate_nonce", certificate_nonce, 'str') - 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 = self._client.delete(url, query_parameters, header_parameters) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + certificate_name=certificate_name, + if_match=if_match, + certificate_name1=certificate_name1, + certificate_raw_bytes=certificate_raw_bytes, + certificate_is_verified=certificate_is_verified, + certificate_purpose=certificate_purpose, + certificate_created=certificate_created, + certificate_last_updated=certificate_last_updated, + certificate_has_private_key=certificate_has_private_key, + certificate_nonce=certificate_nonce, + template_url=self.delete.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, 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: @@ -297,6 +270,8 @@ async def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace_async async def list( self, resource_group_name: str, @@ -319,33 +294,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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(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, + provisioning_service_name=provisioning_service_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 = 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) @@ -354,8 +319,11 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates'} # type: ignore + + @distributed_trace_async async def generate_verification_code( self, certificate_name: str, @@ -392,7 +360,8 @@ async def generate_verification_code( private key. :type certificate_is_verified: bool :param certificate_purpose: Description mentioning the purpose of the certificate. - :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose :param certificate_created: Certificate creation time. :type certificate_created: ~datetime.datetime :param certificate_last_updated: Certificate last updated time. @@ -411,51 +380,33 @@ 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 = { - 'certificateName': self._serialize.url("certificate_name", certificate_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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if certificate_name1 is not None: - query_parameters['certificate.name'] = self._serialize.query("certificate_name1", certificate_name1, 'str') - if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = self._serialize.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') - if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = self._serialize.query("certificate_is_verified", certificate_is_verified, 'bool') - if certificate_purpose is not None: - query_parameters['certificate.purpose'] = self._serialize.query("certificate_purpose", certificate_purpose, 'str') - if certificate_created is not None: - query_parameters['certificate.created'] = self._serialize.query("certificate_created", certificate_created, 'iso-8601') - if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = self._serialize.query("certificate_last_updated", certificate_last_updated, 'iso-8601') - if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificate_has_private_key", certificate_has_private_key, 'bool') - if certificate_nonce is not None: - query_parameters['certificate.nonce'] = self._serialize.query("certificate_nonce", certificate_nonce, 'str') - 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 = self._client.post(url, query_parameters, header_parameters) + + + request = build_generate_verification_code_request( + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + if_match=if_match, + certificate_name1=certificate_name1, + certificate_raw_bytes=certificate_raw_bytes, + certificate_is_verified=certificate_is_verified, + certificate_purpose=certificate_purpose, + certificate_created=certificate_created, + certificate_last_updated=certificate_last_updated, + certificate_has_private_key=certificate_has_private_key, + certificate_nonce=certificate_nonce, + template_url=self.generate_verification_code.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('VerificationCodeResponse', pipeline_response) @@ -464,8 +415,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/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace_async async def verify_certificate( self, certificate_name: str, @@ -507,7 +461,8 @@ async def verify_certificate( private key. :type certificate_is_verified: bool :param certificate_purpose: Describe the purpose of the certificate. - :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose :param certificate_created: Certificate creation time. :type certificate_created: ~datetime.datetime :param certificate_last_updated: Certificate last updated time. @@ -526,56 +481,38 @@ async def verify_certificate( 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_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'certificateName': self._serialize.url("certificate_name", certificate_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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if certificate_name1 is not None: - query_parameters['certificate.name'] = self._serialize.query("certificate_name1", certificate_name1, 'str') - if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = self._serialize.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') - if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = self._serialize.query("certificate_is_verified", certificate_is_verified, 'bool') - if certificate_purpose is not None: - query_parameters['certificate.purpose'] = self._serialize.query("certificate_purpose", certificate_purpose, 'str') - if certificate_created is not None: - query_parameters['certificate.created'] = self._serialize.query("certificate_created", certificate_created, 'iso-8601') - if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = self._serialize.query("certificate_last_updated", certificate_last_updated, 'iso-8601') - if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificate_has_private_key", certificate_has_private_key, 'bool') - if certificate_nonce is not None: - query_parameters['certificate.nonce'] = self._serialize.query("certificate_nonce", certificate_nonce, 'str') - 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(request, 'VerificationCodeRequest') - 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(request, 'VerificationCodeRequest') + + request = build_verify_certificate_request( + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + content_type=content_type, + if_match=if_match, + json=_json, + certificate_name1=certificate_name1, + certificate_raw_bytes=certificate_raw_bytes, + certificate_is_verified=certificate_is_verified, + certificate_purpose=certificate_purpose, + certificate_created=certificate_created, + certificate_last_updated=certificate_last_updated, + certificate_has_private_key=certificate_has_private_key, + certificate_nonce=certificate_nonce, + template_url=self.verify_certificate.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('CertificateResponse', pipeline_response) @@ -584,4 +521,6 @@ async def verify_certificate( return cls(pipeline_response, deserialized, {}) return deserialized + verify_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_resource_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_resource_operations.py index ce2bd7cc82e9..86225427c2de 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_iot_dps_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, List, 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_dps_resource_operations import build_check_provisioning_service_name_availability_request, build_create_or_update_private_endpoint_connection_request_initial, build_create_or_update_request_initial, build_delete_private_endpoint_connection_request_initial, build_delete_request_initial, build_get_operation_result_request, build_get_private_endpoint_connection_request, build_get_private_link_resources_request, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_list_keys_for_key_name_request, build_list_keys_request, build_list_private_endpoint_connections_request, build_list_private_link_resources_request, build_list_valid_skus_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, provisioning_service_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 = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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('ProvisioningServiceDescription', 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/provisioningServices/{provisioningServiceName}'} # 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 = "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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(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_dps_description, 'ProvisioningServiceDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_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_dps_description, 'ProvisioningServiceDescription') - 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('ProvisioningServiceDescription', 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/provisioningServices/{provisioningServiceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -180,18 +170,24 @@ async def begin_create_or_update( :param provisioning_service_name: Name of provisioning service to create or update. :type provisioning_service_name: str :param iot_dps_description: Description of the provisioning service to create or update. - :type iot_dps_description: ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription + :type iot_dps_description: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription :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 ProvisioningServiceDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :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 ProvisioningServiceDescription or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :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.ProvisioningServiceDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -203,27 +199,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, iot_dps_description=iot_dps_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('ProvisioningServiceDescription', 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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: @@ -235,6 +225,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/provisioningServices/{provisioningServiceName}'} # type: ignore async def _update_initial( @@ -249,32 +240,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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(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(provisioning_service_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, + provisioning_service_name=provisioning_service_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(provisioning_service_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 @@ -288,8 +269,11 @@ async def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + + @distributed_trace_async async def begin_update( self, resource_group_name: str, @@ -311,15 +295,20 @@ async def begin_update( :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.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 ProvisioningServiceDescription or the result of cls(response) - :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :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 ProvisioningServiceDescription or + the result of cls(response) + :rtype: + ~azure.core.polling.AsyncLROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :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.ProvisioningServiceDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -331,27 +320,21 @@ async def begin_update( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, provisioning_service_tags=provisioning_service_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('ProvisioningServiceDescription', 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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: @@ -363,6 +346,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/provisioningServices/{provisioningServiceName}'} # type: ignore async def _delete_initial( @@ -376,40 +360,31 @@ 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 = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, provisioning_service_name: str, @@ -426,15 +401,17 @@ async def begin_delete( :type resource_group_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. + :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] + 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', @@ -448,21 +425,14 @@ 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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: @@ -474,8 +444,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/provisioningServices/{provisioningServiceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -485,8 +457,10 @@ def list_by_subscription( List all the provisioning services for a given subscription id. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] + :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] @@ -494,34 +468,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('ProvisioningServiceDescriptionListResult', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -534,17 +503,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/provisioningServices'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -555,8 +526,10 @@ def list_by_resource_group( :param resource_group_name: Resource group identifier. :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 ProvisioningServiceDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] + :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the + result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] @@ -564,35 +537,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('ProvisioningServiceDescriptionListResult', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -605,17 +574,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/provisioningServices'} # type: ignore + @distributed_trace_async async def get_operation_result( self, operation_id: str, @@ -648,35 +619,25 @@ async def get_operation_result( 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_operation_result.metadata['url'] # type: ignore - path_format_arguments = { - 'operationId': self._serialize.url("operation_id", operation_id, '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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['asyncinfo'] = self._serialize.query("asyncinfo", asyncinfo, 'str') - 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_operation_result_request( + operation_id=operation_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + asyncinfo=asyncinfo, + template_url=self.get_operation_result.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('AsyncOperationResult', pipeline_response) @@ -685,8 +646,11 @@ async def get_operation_result( return cls(pipeline_response, deserialized, {}) return deserialized + get_operation_result.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}'} # type: ignore + + @distributed_trace def list_valid_skus( self, provisioning_service_name: str, @@ -702,8 +666,10 @@ def list_valid_skus( :param resource_group_name: Name of resource group. :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 IotDpsSkuDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinitionListResult] + :return: An iterator like instance of either IotDpsSkuDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotDpsSkuDefinitionListResult"] @@ -711,36 +677,33 @@ def list_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.list_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_valid_skus_request( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_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_list_valid_skus_request( + provisioning_service_name=provisioning_service_name, + 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('IotDpsSkuDefinitionListResult', pipeline_response) + deserialized = self._deserialize("IotDpsSkuDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -753,17 +716,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_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus'} # type: ignore + @distributed_trace_async async def check_provisioning_service_name_availability( self, arguments: "_models.OperationInputs", @@ -787,36 +752,26 @@ async def check_provisioning_service_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_provisioning_service_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(arguments, 'OperationInputs') + + request = build_check_provisioning_service_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_provisioning_service_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(arguments, '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('NameAvailabilityInfo', pipeline_response) @@ -825,8 +780,11 @@ async def check_provisioning_service_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_provisioning_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, provisioning_service_name: str, @@ -843,8 +801,10 @@ def list_keys( :param resource_group_name: resource group name. :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 SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -852,36 +812,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 = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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( + provisioning_service_name=provisioning_service_name, + 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('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -894,17 +851,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/provisioningServices/{provisioningServiceName}/listkeys'} # type: ignore + @distributed_trace_async async def list_keys_for_key_name( self, provisioning_service_name: str, @@ -924,8 +883,10 @@ async def list_keys_for_key_name( service. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription, or the result of cls(response) - :rtype: ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription + :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription, or the result of + cls(response) + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"] @@ -933,34 +894,24 @@ async def list_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.list_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - 'keyName': self._serialize.url("key_name", key_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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_for_key_name_request( + provisioning_service_name=provisioning_service_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_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('SharedAccessSignatureAuthorizationRuleAccessRightsDescription', pipeline_response) @@ -969,8 +920,11 @@ async def list_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys'} # type: ignore + + @distributed_trace_async async def list_private_link_resources( self, resource_group_name: str, @@ -996,33 +950,23 @@ async def list_private_link_resources( 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_private_link_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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_private_link_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_private_link_resources.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) @@ -1031,8 +975,11 @@ async def list_private_link_resources( return cls(pipeline_response, deserialized, {}) return deserialized + list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace_async async def get_private_link_resources( self, resource_group_name: str, @@ -1061,34 +1008,24 @@ async def get_private_link_resources( 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_private_link_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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_private_link_resources_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_private_link_resources.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) @@ -1097,8 +1034,11 @@ async def get_private_link_resources( return cls(pipeline_response, deserialized, {}) return deserialized + get_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + + @distributed_trace_async async def list_private_endpoint_connections( self, resource_group_name: str, @@ -1124,33 +1064,23 @@ async def list_private_endpoint_connections( 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_private_endpoint_connections.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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_private_endpoint_connections_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_private_endpoint_connections.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) @@ -1159,8 +1089,11 @@ async def list_private_endpoint_connections( return cls(pipeline_response, deserialized, {}) return deserialized + list_private_endpoint_connections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace_async async def get_private_endpoint_connection( self, resource_group_name: str, @@ -1189,34 +1122,24 @@ async def get_private_endpoint_connection( 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_private_endpoint_connection.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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_private_endpoint_connection_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_private_endpoint_connection.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) @@ -1225,8 +1148,10 @@ async def get_private_endpoint_connection( return cls(pipeline_response, deserialized, {}) return deserialized + get_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + async def _create_or_update_private_endpoint_connection_initial( self, resource_group_name: str, @@ -1240,40 +1165,29 @@ async def _create_or_update_private_endpoint_connection_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_private_endpoint_connection_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_create_or_update_private_endpoint_connection_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._create_or_update_private_endpoint_connection_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) @@ -1285,8 +1199,11 @@ async def _create_or_update_private_endpoint_connection_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update_private_endpoint_connection( self, resource_group_name: str, @@ -1307,18 +1224,24 @@ async def begin_create_or_update_private_endpoint_connection( :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.iothubprovisioningservices.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothubprovisioningservices.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.iothubprovisioningservices.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.iothubprovisioningservices.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', @@ -1331,28 +1254,21 @@ async def begin_create_or_update_private_endpoint_connection( 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: @@ -1364,6 +1280,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_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore async def _delete_private_endpoint_connection_initial( @@ -1378,35 +1295,24 @@ async def _delete_private_endpoint_connection_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_private_endpoint_connection_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_private_endpoint_connection_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_private_endpoint_connection_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: @@ -1419,8 +1325,11 @@ async def _delete_private_endpoint_connection_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace_async async def begin_delete_private_endpoint_connection( self, resource_group_name: str, @@ -1441,15 +1350,19 @@ async def begin_delete_private_endpoint_connection( :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.iothubprovisioningservices.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.iothubprovisioningservices.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', @@ -1464,25 +1377,17 @@ async def begin_delete_private_endpoint_connection( 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: @@ -1494,4 +1399,5 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_operations.py index b30023fea877..fab2c7bf0e5f 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/aio/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/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.iothubprovisioningservices.models.OperationListResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.iothubprovisioningservices.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-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py index 12e61b97212a..936fe672799d 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/__init__.py @@ -6,81 +6,48 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AsyncOperationResult - from ._models_py3 import CertificateBodyDescription - from ._models_py3 import CertificateListDescription - from ._models_py3 import CertificateProperties - from ._models_py3 import CertificateResponse - from ._models_py3 import ErrorDetails - from ._models_py3 import ErrorMesssage - from ._models_py3 import GroupIdInformation - from ._models_py3 import GroupIdInformationProperties - from ._models_py3 import IotDpsPropertiesDescription - from ._models_py3 import IotDpsSkuDefinition - from ._models_py3 import IotDpsSkuDefinitionListResult - from ._models_py3 import IotDpsSkuInfo - from ._models_py3 import IotHubDefinitionDescription - from ._models_py3 import IpFilterRule - from ._models_py3 import NameAvailabilityInfo - 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 ProvisioningServiceDescription - from ._models_py3 import ProvisioningServiceDescriptionListResult - from ._models_py3 import Resource - from ._models_py3 import SharedAccessSignatureAuthorizationRuleAccessRightsDescription - from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult - from ._models_py3 import TagsResource - from ._models_py3 import VerificationCodeRequest - from ._models_py3 import VerificationCodeResponse - from ._models_py3 import VerificationCodeResponseProperties -except (SyntaxError, ImportError): - from ._models import AsyncOperationResult # type: ignore - from ._models import CertificateBodyDescription # type: ignore - from ._models import CertificateListDescription # type: ignore - from ._models import CertificateProperties # type: ignore - from ._models import CertificateResponse # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import ErrorMesssage # type: ignore - from ._models import GroupIdInformation # type: ignore - from ._models import GroupIdInformationProperties # type: ignore - from ._models import IotDpsPropertiesDescription # type: ignore - from ._models import IotDpsSkuDefinition # type: ignore - from ._models import IotDpsSkuDefinitionListResult # type: ignore - from ._models import IotDpsSkuInfo # type: ignore - from ._models import IotHubDefinitionDescription # type: ignore - from ._models import IpFilterRule # type: ignore - from ._models import NameAvailabilityInfo # 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 ProvisioningServiceDescription # type: ignore - from ._models import ProvisioningServiceDescriptionListResult # type: ignore - from ._models import Resource # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleAccessRightsDescription # type: ignore - from ._models import SharedAccessSignatureAuthorizationRuleListResult # type: ignore - from ._models import TagsResource # type: ignore - from ._models import VerificationCodeRequest # type: ignore - from ._models import VerificationCodeResponse # type: ignore - from ._models import VerificationCodeResponseProperties # type: ignore +from ._models_py3 import AsyncOperationResult +from ._models_py3 import CertificateBodyDescription +from ._models_py3 import CertificateListDescription +from ._models_py3 import CertificateProperties +from ._models_py3 import CertificateResponse +from ._models_py3 import ErrorDetails +from ._models_py3 import ErrorMesssage +from ._models_py3 import GroupIdInformation +from ._models_py3 import GroupIdInformationProperties +from ._models_py3 import IotDpsPropertiesDescription +from ._models_py3 import IotDpsSkuDefinition +from ._models_py3 import IotDpsSkuDefinitionListResult +from ._models_py3 import IotDpsSkuInfo +from ._models_py3 import IotHubDefinitionDescription +from ._models_py3 import IpFilterRule +from ._models_py3 import NameAvailabilityInfo +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 ProvisioningServiceDescription +from ._models_py3 import ProvisioningServiceDescriptionListResult +from ._models_py3 import Resource +from ._models_py3 import SharedAccessSignatureAuthorizationRuleAccessRightsDescription +from ._models_py3 import SharedAccessSignatureAuthorizationRuleListResult +from ._models_py3 import SystemData +from ._models_py3 import TagsResource +from ._models_py3 import VerificationCodeRequest +from ._models_py3 import VerificationCodeResponse +from ._models_py3 import VerificationCodeResponseProperties + from ._iot_dps_client_enums import ( AccessRightsDescription, AllocationPolicy, CertificatePurpose, + CreatedByType, IotDpsSku, IpFilterActionType, IpFilterTargetType, @@ -121,6 +88,7 @@ 'Resource', 'SharedAccessSignatureAuthorizationRuleAccessRightsDescription', 'SharedAccessSignatureAuthorizationRuleListResult', + 'SystemData', 'TagsResource', 'VerificationCodeRequest', 'VerificationCodeResponse', @@ -128,6 +96,7 @@ 'AccessRightsDescription', 'AllocationPolicy', 'CertificatePurpose', + 'CreatedByType', 'IotDpsSku', 'IpFilterActionType', 'IpFilterTargetType', diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_client_enums.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_client_enums.py index 474e215eeb84..e7c33853f1ea 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_client_enums.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_iot_dps_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 AccessRightsDescription(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AccessRightsDescription(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Rights that this key has. """ @@ -37,7 +22,7 @@ class AccessRightsDescription(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum REGISTRATION_STATUS_READ = "RegistrationStatusRead" REGISTRATION_STATUS_WRITE = "RegistrationStatusWrite" -class AllocationPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AllocationPolicy(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Allocation policy to be used by this provisioning service. """ @@ -45,25 +30,34 @@ class AllocationPolicy(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): GEO_LATENCY = "GeoLatency" STATIC = "Static" -class CertificatePurpose(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CertificatePurpose(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): CLIENT_AUTHENTICATION = "clientAuthentication" SERVER_AUTHENTICATION = "serverAuthentication" -class IotDpsSku(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" + +class IotDpsSku(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Sku name. """ S1 = "S1" -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 IpFilterTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class IpFilterTargetType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Target for requests captured by this rule. """ @@ -71,14 +65,14 @@ class IpFilterTargetType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): SERVICE_API = "serviceApi" DEVICE_API = "deviceApi" -class NameUnavailabilityReason(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class NameUnavailabilityReason(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """specifies the reason a name is unavailable """ INVALID = "Invalid" ALREADY_EXISTS = "AlreadyExists" -class PrivateLinkServiceConnectionStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class PrivateLinkServiceConnectionStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status of a private endpoint connection """ @@ -87,14 +81,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 State(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class State(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Current state of the provisioning service. """ diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models.py deleted file mode 100644 index 5930c54f5312..000000000000 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models.py +++ /dev/null @@ -1,1191 +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 AsyncOperationResult(msrest.serialization.Model): - """Result of a long running operation. - - :param status: current status of a long running operation. - :type status: str - :param error: Error message containing code, description and details. - :type error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMesssage - """ - - _attribute_map = { - 'status': {'key': 'status', 'type': 'str'}, - 'error': {'key': 'error', 'type': 'ErrorMesssage'}, - } - - def __init__( - self, - **kwargs - ): - super(AsyncOperationResult, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.error = kwargs.get('error', 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 CertificateListDescription(msrest.serialization.Model): - """The JSON-serialized array of Certificate objects. - - :param value: The array of Certificate objects. - :type value: list[~azure.mgmt.iothubprovisioningservices.models.CertificateResponse] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[CertificateResponse]'}, - } - - 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 certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :vartype certificate: bytearray - :ivar created: The certificate's creation 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}, - 'certificate': {'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'}, - 'certificate': {'key': 'certificate', 'type': 'bytearray'}, - '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.certificate = None - self.created = None - self.updated = None - - -class CertificateResponse(msrest.serialization.Model): - """The X509 Certificate. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param properties: properties of a certificate. - :type properties: ~azure.mgmt.iothubprovisioningservices.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(CertificateResponse, self).__init__(**kwargs) - self.properties = kwargs.get('properties', None) - self.id = None - self.name = None - self.etag = None - self.type = 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 ErrorMesssage(msrest.serialization.Model): - """Error response containing message and code. - - :param code: standard error code. - :type code: str - :param message: standard error description. - :type message: str - :param details: detailed summary of error. - :type details: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorMesssage, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - self.details = kwargs.get('details', None) - - -class GroupIdInformation(msrest.serialization.Model): - """The group information for creating a private endpoint on a provisioning service. - - 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.iothubprovisioningservices.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 IotDpsPropertiesDescription(msrest.serialization.Model): - """the service specific properties of a provisioning service, including keys, linked iot hubs, current state, and system generated properties such as hostname and idScope. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param state: Current state of the provisioning service. Possible values include: "Activating", - "Active", "Deleting", "Deleted", "ActivationFailed", "DeletionFailed", "Transitioning", - "Suspending", "Suspended", "Resuming", "FailingOver", "FailoverFailed". - :type state: str or ~azure.mgmt.iothubprovisioningservices.models.State - :param public_network_access: Whether requests from Public Network are allowed. Possible values - include: "Enabled", "Disabled". - :type public_network_access: str or - ~azure.mgmt.iothubprovisioningservices.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothubprovisioningservices.models.IpFilterRule] - :param private_endpoint_connections: Private endpoint connections created on this IotHub. - :type private_endpoint_connections: - list[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :param provisioning_state: The ARM provisioning state of the provisioning service. - :type provisioning_state: str - :param iot_hubs: List of IoT hubs associated with this provisioning service. - :type iot_hubs: list[~azure.mgmt.iothubprovisioningservices.models.IotHubDefinitionDescription] - :param allocation_policy: Allocation policy to be used by this provisioning service. Possible - values include: "Hashed", "GeoLatency", "Static". - :type allocation_policy: str or ~azure.mgmt.iothubprovisioningservices.models.AllocationPolicy - :ivar service_operations_host_name: Service endpoint for provisioning service. - :vartype service_operations_host_name: str - :ivar device_provisioning_host_name: Device endpoint for this provisioning service. - :vartype device_provisioning_host_name: str - :ivar id_scope: Unique identifier of this provisioning service. - :vartype id_scope: str - :param authorization_policies: List of authorization keys for a provisioning service. - :type authorization_policies: - list[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] - """ - - _validation = { - 'service_operations_host_name': {'readonly': True}, - 'device_provisioning_host_name': {'readonly': True}, - 'id_scope': {'readonly': True}, - } - - _attribute_map = { - 'state': {'key': 'state', 'type': 'str'}, - 'public_network_access': {'key': 'publicNetworkAccess', 'type': 'str'}, - 'ip_filter_rules': {'key': 'ipFilterRules', 'type': '[IpFilterRule]'}, - 'private_endpoint_connections': {'key': 'privateEndpointConnections', 'type': '[PrivateEndpointConnection]'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'iot_hubs': {'key': 'iotHubs', 'type': '[IotHubDefinitionDescription]'}, - 'allocation_policy': {'key': 'allocationPolicy', 'type': 'str'}, - 'service_operations_host_name': {'key': 'serviceOperationsHostName', 'type': 'str'}, - 'device_provisioning_host_name': {'key': 'deviceProvisioningHostName', 'type': 'str'}, - 'id_scope': {'key': 'idScope', 'type': 'str'}, - 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]'}, - } - - def __init__( - self, - **kwargs - ): - super(IotDpsPropertiesDescription, self).__init__(**kwargs) - self.state = kwargs.get('state', None) - self.public_network_access = kwargs.get('public_network_access', None) - self.ip_filter_rules = kwargs.get('ip_filter_rules', None) - self.private_endpoint_connections = kwargs.get('private_endpoint_connections', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.iot_hubs = kwargs.get('iot_hubs', None) - self.allocation_policy = kwargs.get('allocation_policy', None) - self.service_operations_host_name = None - self.device_provisioning_host_name = None - self.id_scope = None - self.authorization_policies = kwargs.get('authorization_policies', None) - - -class IotDpsSkuDefinition(msrest.serialization.Model): - """Available SKUs of tier and units. - - :param name: Sku name. Possible values include: "S1". - :type name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotDpsSkuDefinition, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - - -class IotDpsSkuDefinitionListResult(msrest.serialization.Model): - """List of available SKUs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: The list of SKUs. - :type value: list[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] - :ivar next_link: The next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[IotDpsSkuDefinition]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotDpsSkuDefinitionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class IotDpsSkuInfo(msrest.serialization.Model): - """List of possible provisioning service SKUs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: Sku name. Possible values include: "S1". - :type name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku - :ivar tier: Pricing tier name of the provisioning service. - :vartype tier: str - :param capacity: The number of units to provision. - :type capacity: long - """ - - _validation = { - '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(IotDpsSkuInfo, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.tier = None - self.capacity = kwargs.get('capacity', None) - - -class IotHubDefinitionDescription(msrest.serialization.Model): - """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. - - :param apply_allocation_policy: flag for applying allocationPolicy or not for a given iot hub. - :type apply_allocation_policy: bool - :param allocation_weight: weight to apply for a given iot h. - :type allocation_weight: int - :ivar name: Host name of the IoT hub. - :vartype name: str - :param connection_string: Required. Connection string of the IoT hub. - :type connection_string: str - :param location: Required. ARM region of the IoT hub. - :type location: str - """ - - _validation = { - 'name': {'readonly': True}, - 'connection_string': {'required': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'apply_allocation_policy': {'key': 'applyAllocationPolicy', 'type': 'bool'}, - 'allocation_weight': {'key': 'allocationWeight', 'type': 'int'}, - 'name': {'key': 'name', 'type': 'str'}, - 'connection_string': {'key': 'connectionString', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IotHubDefinitionDescription, self).__init__(**kwargs) - self.apply_allocation_policy = kwargs.get('apply_allocation_policy', None) - self.allocation_weight = kwargs.get('allocation_weight', None) - self.name = None - self.connection_string = kwargs['connection_string'] - self.location = kwargs['location'] - - -class IpFilterRule(msrest.serialization.Model): - """The IP filter rules for a provisioning Service. - - 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.iothubprovisioningservices.models.IpFilterActionType - :param ip_mask: Required. A string that contains the IP address range in CIDR notation for the - rule. - :type ip_mask: str - :param target: Target for requests captured by this rule. Possible values include: "all", - "serviceApi", "deviceApi". - :type target: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterTargetType - """ - - _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'}, - 'target': {'key': 'target', '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'] - self.target = kwargs.get('target', None) - - -class NameAvailabilityInfo(msrest.serialization.Model): - """Description of name availability. - - :param name_available: specifies if a name is available or not. - :type name_available: bool - :param reason: specifies the reason a name is unavailable. Possible values include: "Invalid", - "AlreadyExists". - :type reason: str or ~azure.mgmt.iothubprovisioningservices.models.NameUnavailabilityReason - :param message: message containing a detailed reason name is unavailable. - :type message: str - """ - - _attribute_map = { - 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, - 'reason': {'key': 'reason', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NameAvailabilityInfo, self).__init__(**kwargs) - self.name_available = kwargs.get('name_available', None) - self.reason = kwargs.get('reason', None) - self.message = kwargs.get('message', None) - - -class Operation(msrest.serialization.Model): - """Provisioning Service 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.iothubprovisioningservices.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: ProvisioningServices. - :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 for operation results call. - - All required parameters must be populated in order to send to Azure. - - :param name: Required. The name of the Provisioning Service 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 provisioning service 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: Provisioning service operations supported by the Microsoft.Devices resource - provider. - :vartype value: list[~azure.mgmt.iothubprovisioningservices.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 a provisioning service. - - 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.iothubprovisioningservices.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.iothubprovisioningservices.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.iothubprovisioningservices.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 a provisioning service. - - :param value: The list of available private link resources for a provisioning service. - :type value: list[~azure.mgmt.iothubprovisioningservices.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.iothubprovisioningservices.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 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 ProvisioningServiceDescription(Resource): - """The description of the provisioning service. - - 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: Required. Service specific properties for a provisioning service. - :type properties: ~azure.mgmt.iothubprovisioningservices.models.IotDpsPropertiesDescription - :param sku: Required. Sku info for a provisioning Service. - :type sku: ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuInfo - """ - - _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}, - 'properties': {'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': 'IotDpsPropertiesDescription'}, - 'sku': {'key': 'sku', 'type': 'IotDpsSkuInfo'}, - } - - def __init__( - self, - **kwargs - ): - super(ProvisioningServiceDescription, self).__init__(**kwargs) - self.etag = kwargs.get('etag', None) - self.properties = kwargs['properties'] - self.sku = kwargs['sku'] - - -class ProvisioningServiceDescriptionListResult(msrest.serialization.Model): - """List of provisioning service descriptions. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param value: List of provisioning service descriptions. - :type value: list[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :ivar next_link: the next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProvisioningServiceDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProvisioningServiceDescriptionListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = None - - -class SharedAccessSignatureAuthorizationRuleAccessRightsDescription(msrest.serialization.Model): - """Description of the shared access key. - - All required parameters must be populated in order to send to Azure. - - :param key_name: Required. Name of the key. - :type key_name: str - :param primary_key: Primary SAS key value. - :type primary_key: str - :param secondary_key: Secondary SAS key value. - :type secondary_key: str - :param rights: Required. Rights that this key has. Possible values include: "ServiceConfig", - "EnrollmentRead", "EnrollmentWrite", "DeviceConnect", "RegistrationStatusRead", - "RegistrationStatusWrite". - :type rights: str or ~azure.mgmt.iothubprovisioningservices.models.AccessRightsDescription - """ - - _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(SharedAccessSignatureAuthorizationRuleAccessRightsDescription, 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): - """List of shared access keys. - - 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.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] - :ivar next_link: The next link. - :vartype next_link: str - """ - - _validation = { - 'next_link': {'readonly': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]'}, - '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 TagsResource(msrest.serialization.Model): - """A container holding only the Tags for a resource, allowing the user to update the tags on a Provisioning Service 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 VerificationCodeRequest(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(VerificationCodeRequest, self).__init__(**kwargs) - self.certificate = kwargs.get('certificate', None) - - -class VerificationCodeResponse(msrest.serialization.Model): - """Description of the response of the verification code. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: Name of certificate. - :vartype name: str - :ivar etag: Request etag. - :vartype etag: str - :ivar id: The resource identifier. - :vartype id: str - :ivar type: The resource type. - :vartype type: str - :param properties: - :type properties: - ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponseProperties - """ - - _validation = { - 'name': {'readonly': True}, - 'etag': {'readonly': True}, - 'id': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'etag': {'key': 'etag', 'type': 'str'}, - 'id': {'key': 'id', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'VerificationCodeResponseProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(VerificationCodeResponse, self).__init__(**kwargs) - self.name = None - self.etag = None - self.id = None - self.type = None - self.properties = kwargs.get('properties', None) - - -class VerificationCodeResponseProperties(msrest.serialization.Model): - """VerificationCodeResponseProperties. - - :param verification_code: Verification code. - :type verification_code: str - :param subject: Certificate subject. - :type subject: str - :param expiry: Code expiry. - :type expiry: str - :param thumbprint: Certificate thumbprint. - :type thumbprint: str - :param is_verified: Indicate if the certificate is verified by owner of private key. - :type is_verified: bool - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file - content. - :type certificate: bytearray - :param created: Certificate created time. - :type created: str - :param updated: Certificate updated time. - :type updated: str - """ - - _attribute_map = { - 'verification_code': {'key': 'verificationCode', 'type': 'str'}, - 'subject': {'key': 'subject', 'type': 'str'}, - 'expiry': {'key': 'expiry', 'type': 'str'}, - 'thumbprint': {'key': 'thumbprint', 'type': 'str'}, - 'is_verified': {'key': 'isVerified', 'type': 'bool'}, - 'certificate': {'key': 'certificate', 'type': 'bytearray'}, - 'created': {'key': 'created', 'type': 'str'}, - 'updated': {'key': 'updated', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(VerificationCodeResponseProperties, self).__init__(**kwargs) - self.verification_code = kwargs.get('verification_code', None) - self.subject = kwargs.get('subject', None) - self.expiry = kwargs.get('expiry', None) - self.thumbprint = kwargs.get('thumbprint', None) - self.is_verified = kwargs.get('is_verified', None) - self.certificate = kwargs.get('certificate', None) - self.created = kwargs.get('created', None) - self.updated = kwargs.get('updated', None) diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py index 9a6b001cec85..22b9183ec996 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/models/_models_py3.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime from typing import Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError @@ -17,10 +18,10 @@ class AsyncOperationResult(msrest.serialization.Model): """Result of a long running operation. - :param status: current status of a long running operation. - :type status: str - :param error: Error message containing code, description and details. - :type error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMesssage + :ivar status: current status of a long running operation. + :vartype status: str + :ivar error: Error message containing code, description and details. + :vartype error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMesssage """ _attribute_map = { @@ -35,6 +36,12 @@ def __init__( error: Optional["ErrorMesssage"] = None, **kwargs ): + """ + :keyword status: current status of a long running operation. + :paramtype status: str + :keyword error: Error message containing code, description and details. + :paramtype error: ~azure.mgmt.iothubprovisioningservices.models.ErrorMesssage + """ super(AsyncOperationResult, self).__init__(**kwargs) self.status = status self.error = error @@ -43,12 +50,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 = { @@ -63,6 +70,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 @@ -71,8 +86,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.iothubprovisioningservices.models.CertificateResponse] + :ivar value: The array of Certificate objects. + :vartype value: list[~azure.mgmt.iothubprovisioningservices.models.CertificateResponse] """ _attribute_map = { @@ -85,6 +100,10 @@ def __init__( value: Optional[List["CertificateResponse"]] = None, **kwargs ): + """ + :keyword value: The array of Certificate objects. + :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.CertificateResponse] + """ super(CertificateListDescription, self).__init__(**kwargs) self.value = value @@ -135,6 +154,8 @@ def __init__( self, **kwargs ): + """ + """ super(CertificateProperties, self).__init__(**kwargs) self.subject = None self.expiry = None @@ -150,8 +171,8 @@ class CertificateResponse(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param properties: properties of a certificate. - :type properties: ~azure.mgmt.iothubprovisioningservices.models.CertificateProperties + :ivar properties: properties of a certificate. + :vartype properties: ~azure.mgmt.iothubprovisioningservices.models.CertificateProperties :ivar id: The resource identifier. :vartype id: str :ivar name: The name of the certificate. @@ -160,6 +181,8 @@ class CertificateResponse(msrest.serialization.Model): :vartype etag: str :ivar type: The resource type. :vartype type: str + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.iothubprovisioningservices.models.SystemData """ _validation = { @@ -167,6 +190,7 @@ class CertificateResponse(msrest.serialization.Model): 'name': {'readonly': True}, 'etag': {'readonly': True}, 'type': {'readonly': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -175,6 +199,7 @@ class CertificateResponse(msrest.serialization.Model): 'name': {'key': 'name', 'type': 'str'}, 'etag': {'key': 'etag', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -183,12 +208,17 @@ def __init__( properties: Optional["CertificateProperties"] = None, **kwargs ): + """ + :keyword properties: properties of a certificate. + :paramtype properties: ~azure.mgmt.iothubprovisioningservices.models.CertificateProperties + """ super(CertificateResponse, self).__init__(**kwargs) self.properties = properties self.id = None self.name = None self.etag = None self.type = None + self.system_data = None class ErrorDetails(msrest.serialization.Model): @@ -224,6 +254,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetails, self).__init__(**kwargs) self.code = None self.http_status_code = None @@ -234,12 +266,12 @@ def __init__( class ErrorMesssage(msrest.serialization.Model): """Error response containing message and code. - :param code: standard error code. - :type code: str - :param message: standard error description. - :type message: str - :param details: detailed summary of error. - :type details: str + :ivar code: standard error code. + :vartype code: str + :ivar message: standard error description. + :vartype message: str + :ivar details: detailed summary of error. + :vartype details: str """ _attribute_map = { @@ -256,6 +288,14 @@ def __init__( details: Optional[str] = None, **kwargs ): + """ + :keyword code: standard error code. + :paramtype code: str + :keyword message: standard error description. + :paramtype message: str + :keyword details: detailed summary of error. + :paramtype details: str + """ super(ErrorMesssage, self).__init__(**kwargs) self.code = code self.message = message @@ -275,8 +315,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.iothubprovisioningservices.models.GroupIdInformationProperties + :ivar properties: Required. The properties for a group information object. + :vartype properties: ~azure.mgmt.iothubprovisioningservices.models.GroupIdInformationProperties """ _validation = { @@ -299,6 +339,11 @@ def __init__( properties: "GroupIdInformationProperties", **kwargs ): + """ + :keyword properties: Required. The properties for a group information object. + :paramtype properties: + ~azure.mgmt.iothubprovisioningservices.models.GroupIdInformationProperties + """ super(GroupIdInformation, self).__init__(**kwargs) self.id = None self.name = None @@ -309,12 +354,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 = { @@ -331,6 +376,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 @@ -342,35 +395,41 @@ class IotDpsPropertiesDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param state: Current state of the provisioning service. Possible values include: "Activating", + :ivar state: Current state of the provisioning service. Possible values include: "Activating", "Active", "Deleting", "Deleted", "ActivationFailed", "DeletionFailed", "Transitioning", "Suspending", "Suspended", "Resuming", "FailingOver", "FailoverFailed". - :type state: str or ~azure.mgmt.iothubprovisioningservices.models.State - :param public_network_access: Whether requests from Public Network are allowed. Possible values + :vartype state: str or ~azure.mgmt.iothubprovisioningservices.models.State + :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.iothubprovisioningservices.models.PublicNetworkAccess - :param ip_filter_rules: The IP filter rules. - :type ip_filter_rules: list[~azure.mgmt.iothubprovisioningservices.models.IpFilterRule] - :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.iothubprovisioningservices.models.IpFilterRule] + :ivar private_endpoint_connections: Private endpoint connections created on this IotHub. + :vartype private_endpoint_connections: list[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] - :param provisioning_state: The ARM provisioning state of the provisioning service. - :type provisioning_state: str - :param iot_hubs: List of IoT hubs associated with this provisioning service. - :type iot_hubs: list[~azure.mgmt.iothubprovisioningservices.models.IotHubDefinitionDescription] - :param allocation_policy: Allocation policy to be used by this provisioning service. Possible + :ivar provisioning_state: The ARM provisioning state of the provisioning service. + :vartype provisioning_state: str + :ivar iot_hubs: List of IoT hubs associated with this provisioning service. + :vartype iot_hubs: + list[~azure.mgmt.iothubprovisioningservices.models.IotHubDefinitionDescription] + :ivar allocation_policy: Allocation policy to be used by this provisioning service. Possible values include: "Hashed", "GeoLatency", "Static". - :type allocation_policy: str or ~azure.mgmt.iothubprovisioningservices.models.AllocationPolicy + :vartype allocation_policy: str or + ~azure.mgmt.iothubprovisioningservices.models.AllocationPolicy :ivar service_operations_host_name: Service endpoint for provisioning service. :vartype service_operations_host_name: str :ivar device_provisioning_host_name: Device endpoint for this provisioning service. :vartype device_provisioning_host_name: str :ivar id_scope: Unique identifier of this provisioning service. :vartype id_scope: str - :param authorization_policies: List of authorization keys for a provisioning service. - :type authorization_policies: + :ivar authorization_policies: List of authorization keys for a provisioning service. + :vartype authorization_policies: list[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] + :ivar enable_data_residency: Optional. + Indicates if the DPS instance has Data Residency enabled, removing the cross geo-pair disaster + recovery. + :vartype enable_data_residency: bool """ _validation = { @@ -391,6 +450,7 @@ class IotDpsPropertiesDescription(msrest.serialization.Model): 'device_provisioning_host_name': {'key': 'deviceProvisioningHostName', 'type': 'str'}, 'id_scope': {'key': 'idScope', 'type': 'str'}, 'authorization_policies': {'key': 'authorizationPolicies', 'type': '[SharedAccessSignatureAuthorizationRuleAccessRightsDescription]'}, + 'enable_data_residency': {'key': 'enableDataResidency', 'type': 'bool'}, } def __init__( @@ -404,8 +464,40 @@ def __init__( iot_hubs: Optional[List["IotHubDefinitionDescription"]] = None, allocation_policy: Optional[Union[str, "AllocationPolicy"]] = None, authorization_policies: Optional[List["SharedAccessSignatureAuthorizationRuleAccessRightsDescription"]] = None, + enable_data_residency: Optional[bool] = None, **kwargs ): + """ + :keyword state: Current state of the provisioning service. Possible values include: + "Activating", "Active", "Deleting", "Deleted", "ActivationFailed", "DeletionFailed", + "Transitioning", "Suspending", "Suspended", "Resuming", "FailingOver", "FailoverFailed". + :paramtype state: str or ~azure.mgmt.iothubprovisioningservices.models.State + :keyword public_network_access: Whether requests from Public Network are allowed. Possible + values include: "Enabled", "Disabled". + :paramtype public_network_access: str or + ~azure.mgmt.iothubprovisioningservices.models.PublicNetworkAccess + :keyword ip_filter_rules: The IP filter rules. + :paramtype ip_filter_rules: list[~azure.mgmt.iothubprovisioningservices.models.IpFilterRule] + :keyword private_endpoint_connections: Private endpoint connections created on this IotHub. + :paramtype private_endpoint_connections: + list[~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnection] + :keyword provisioning_state: The ARM provisioning state of the provisioning service. + :paramtype provisioning_state: str + :keyword iot_hubs: List of IoT hubs associated with this provisioning service. + :paramtype iot_hubs: + list[~azure.mgmt.iothubprovisioningservices.models.IotHubDefinitionDescription] + :keyword allocation_policy: Allocation policy to be used by this provisioning service. Possible + values include: "Hashed", "GeoLatency", "Static". + :paramtype allocation_policy: str or + ~azure.mgmt.iothubprovisioningservices.models.AllocationPolicy + :keyword authorization_policies: List of authorization keys for a provisioning service. + :paramtype authorization_policies: + list[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] + :keyword enable_data_residency: Optional. + Indicates if the DPS instance has Data Residency enabled, removing the cross geo-pair disaster + recovery. + :paramtype enable_data_residency: bool + """ super(IotDpsPropertiesDescription, self).__init__(**kwargs) self.state = state self.public_network_access = public_network_access @@ -418,13 +510,14 @@ def __init__( self.device_provisioning_host_name = None self.id_scope = None self.authorization_policies = authorization_policies + self.enable_data_residency = enable_data_residency class IotDpsSkuDefinition(msrest.serialization.Model): """Available SKUs of tier and units. - :param name: Sku name. Possible values include: "S1". - :type name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku + :ivar name: Sku name. Possible values include: "S1". + :vartype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku """ _attribute_map = { @@ -437,6 +530,10 @@ def __init__( name: Optional[Union[str, "IotDpsSku"]] = None, **kwargs ): + """ + :keyword name: Sku name. Possible values include: "S1". + :paramtype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku + """ super(IotDpsSkuDefinition, self).__init__(**kwargs) self.name = name @@ -446,8 +543,8 @@ class IotDpsSkuDefinitionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: The list of SKUs. - :type value: list[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] + :ivar value: The list of SKUs. + :vartype value: list[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] :ivar next_link: The next link. :vartype next_link: str """ @@ -467,6 +564,10 @@ def __init__( value: Optional[List["IotDpsSkuDefinition"]] = None, **kwargs ): + """ + :keyword value: The list of SKUs. + :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinition] + """ super(IotDpsSkuDefinitionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -477,12 +578,12 @@ class IotDpsSkuInfo(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: Sku name. Possible values include: "S1". - :type name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku + :ivar name: Sku name. Possible values include: "S1". + :vartype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku :ivar tier: Pricing tier name of the provisioning service. :vartype tier: str - :param capacity: The number of units to provision. - :type capacity: long + :ivar capacity: The number of units to provision. + :vartype capacity: long """ _validation = { @@ -502,6 +603,12 @@ def __init__( capacity: Optional[int] = None, **kwargs ): + """ + :keyword name: Sku name. Possible values include: "S1". + :paramtype name: str or ~azure.mgmt.iothubprovisioningservices.models.IotDpsSku + :keyword capacity: The number of units to provision. + :paramtype capacity: long + """ super(IotDpsSkuInfo, self).__init__(**kwargs) self.name = name self.tier = None @@ -515,16 +622,16 @@ class IotHubDefinitionDescription(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param apply_allocation_policy: flag for applying allocationPolicy or not for a given iot hub. - :type apply_allocation_policy: bool - :param allocation_weight: weight to apply for a given iot h. - :type allocation_weight: int + :ivar apply_allocation_policy: flag for applying allocationPolicy or not for a given iot hub. + :vartype apply_allocation_policy: bool + :ivar allocation_weight: weight to apply for a given iot h. + :vartype allocation_weight: int :ivar name: Host name of the IoT hub. :vartype name: str - :param connection_string: Required. Connection string of the IoT hub. - :type connection_string: str - :param location: Required. ARM region of the IoT hub. - :type location: str + :ivar connection_string: Required. Connection string of the IoT hub. + :vartype connection_string: str + :ivar location: Required. ARM region of the IoT hub. + :vartype location: str """ _validation = { @@ -550,6 +657,17 @@ def __init__( allocation_weight: Optional[int] = None, **kwargs ): + """ + :keyword apply_allocation_policy: flag for applying allocationPolicy or not for a given iot + hub. + :paramtype apply_allocation_policy: bool + :keyword allocation_weight: weight to apply for a given iot h. + :paramtype allocation_weight: int + :keyword connection_string: Required. Connection string of the IoT hub. + :paramtype connection_string: str + :keyword location: Required. ARM region of the IoT hub. + :paramtype location: str + """ super(IotHubDefinitionDescription, self).__init__(**kwargs) self.apply_allocation_policy = apply_allocation_policy self.allocation_weight = allocation_weight @@ -563,17 +681,17 @@ 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.iothubprovisioningservices.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.iothubprovisioningservices.models.IpFilterActionType + :ivar ip_mask: Required. A string that contains the IP address range in CIDR notation for the rule. - :type ip_mask: str - :param target: Target for requests captured by this rule. Possible values include: "all", + :vartype ip_mask: str + :ivar target: Target for requests captured by this rule. Possible values include: "all", "serviceApi", "deviceApi". - :type target: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterTargetType + :vartype target: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterTargetType """ _validation = { @@ -598,6 +716,19 @@ def __init__( target: Optional[Union[str, "IpFilterTargetType"]] = None, **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.iothubprovisioningservices.models.IpFilterActionType + :keyword ip_mask: Required. A string that contains the IP address range in CIDR notation for + the rule. + :paramtype ip_mask: str + :keyword target: Target for requests captured by this rule. Possible values include: "all", + "serviceApi", "deviceApi". + :paramtype target: str or ~azure.mgmt.iothubprovisioningservices.models.IpFilterTargetType + """ super(IpFilterRule, self).__init__(**kwargs) self.filter_name = filter_name self.action = action @@ -608,13 +739,13 @@ def __init__( class NameAvailabilityInfo(msrest.serialization.Model): """Description of name availability. - :param name_available: specifies if a name is available or not. - :type name_available: bool - :param reason: specifies the reason a name is unavailable. Possible values include: "Invalid", + :ivar name_available: specifies if a name is available or not. + :vartype name_available: bool + :ivar reason: specifies the reason a name is unavailable. Possible values include: "Invalid", "AlreadyExists". - :type reason: str or ~azure.mgmt.iothubprovisioningservices.models.NameUnavailabilityReason - :param message: message containing a detailed reason name is unavailable. - :type message: str + :vartype reason: str or ~azure.mgmt.iothubprovisioningservices.models.NameUnavailabilityReason + :ivar message: message containing a detailed reason name is unavailable. + :vartype message: str """ _attribute_map = { @@ -631,6 +762,16 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword name_available: specifies if a name is available or not. + :paramtype name_available: bool + :keyword reason: specifies the reason a name is unavailable. Possible values include: + "Invalid", "AlreadyExists". + :paramtype reason: str or + ~azure.mgmt.iothubprovisioningservices.models.NameUnavailabilityReason + :keyword message: message containing a detailed reason name is unavailable. + :paramtype message: str + """ super(NameAvailabilityInfo, self).__init__(**kwargs) self.name_available = name_available self.reason = reason @@ -644,8 +785,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.iothubprovisioningservices.models.OperationDisplay + :ivar display: The object that represents the operation. + :vartype display: ~azure.mgmt.iothubprovisioningservices.models.OperationDisplay """ _validation = { @@ -663,6 +804,10 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword display: The object that represents the operation. + :paramtype display: ~azure.mgmt.iothubprovisioningservices.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -697,6 +842,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = None self.resource = None @@ -708,8 +855,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 Provisioning Service to check. - :type name: str + :ivar name: Required. The name of the Provisioning Service to check. + :vartype name: str """ _validation = { @@ -726,6 +873,10 @@ def __init__( name: str, **kwargs ): + """ + :keyword name: Required. The name of the Provisioning Service to check. + :paramtype name: str + """ super(OperationInputs, self).__init__(**kwargs) self.name = name @@ -756,6 +907,8 @@ def __init__( self, **kwargs ): + """ + """ super(OperationListResult, self).__init__(**kwargs) self.value = None self.next_link = None @@ -782,6 +935,8 @@ def __init__( self, **kwargs ): + """ + """ super(PrivateEndpoint, self).__init__(**kwargs) self.id = None @@ -799,9 +954,11 @@ 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.iothubprovisioningservices.models.PrivateEndpointConnectionProperties + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.iothubprovisioningservices.models.SystemData """ _validation = { @@ -809,6 +966,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): 'name': {'readonly': True, 'pattern': r'^(?![0-9]+$)(?!-)[a-zA-Z0-9-]{2,49}[a-zA-Z0-9]$'}, 'type': {'readonly': True}, 'properties': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -816,6 +974,7 @@ class PrivateEndpointConnection(msrest.serialization.Model): 'name': {'key': 'name', 'type': 'str'}, 'type': {'key': 'type', 'type': 'str'}, 'properties': {'key': 'properties', 'type': 'PrivateEndpointConnectionProperties'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -824,11 +983,17 @@ def __init__( properties: "PrivateEndpointConnectionProperties", **kwargs ): + """ + :keyword properties: Required. The properties of a private endpoint connection. + :paramtype properties: + ~azure.mgmt.iothubprovisioningservices.models.PrivateEndpointConnectionProperties + """ super(PrivateEndpointConnection, self).__init__(**kwargs) self.id = None self.name = None self.type = None self.properties = properties + self.system_data = None class PrivateEndpointConnectionProperties(msrest.serialization.Model): @@ -836,11 +1001,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.iothubprovisioningservices.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.iothubprovisioningservices.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.iothubprovisioningservices.models.PrivateLinkServiceConnectionState """ @@ -860,6 +1025,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.iothubprovisioningservices.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.iothubprovisioningservices.models.PrivateLinkServiceConnectionState + """ super(PrivateEndpointConnectionProperties, self).__init__(**kwargs) self.private_endpoint = private_endpoint self.private_link_service_connection_state = private_link_service_connection_state @@ -868,8 +1041,8 @@ def __init__( class PrivateLinkResources(msrest.serialization.Model): """The available private link resources for a provisioning service. - :param value: The list of available private link resources for a provisioning service. - :type value: list[~azure.mgmt.iothubprovisioningservices.models.GroupIdInformation] + :ivar value: The list of available private link resources for a provisioning service. + :vartype value: list[~azure.mgmt.iothubprovisioningservices.models.GroupIdInformation] """ _attribute_map = { @@ -882,6 +1055,10 @@ def __init__( value: Optional[List["GroupIdInformation"]] = None, **kwargs ): + """ + :keyword value: The list of available private link resources for a provisioning service. + :paramtype value: list[~azure.mgmt.iothubprovisioningservices.models.GroupIdInformation] + """ super(PrivateLinkResources, self).__init__(**kwargs) self.value = value @@ -891,15 +1068,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.iothubprovisioningservices.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 = { @@ -921,6 +1098,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.iothubprovisioningservices.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 @@ -940,10 +1128,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 = { @@ -968,6 +1156,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 @@ -989,17 +1183,19 @@ class ProvisioningServiceDescription(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: Required. Service specific properties for a provisioning service. - :type properties: ~azure.mgmt.iothubprovisioningservices.models.IotDpsPropertiesDescription - :param sku: Required. Sku info for a provisioning Service. - :type sku: ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuInfo + :vartype etag: str + :ivar properties: Required. Service specific properties for a provisioning service. + :vartype properties: ~azure.mgmt.iothubprovisioningservices.models.IotDpsPropertiesDescription + :ivar sku: Required. Sku info for a provisioning Service. + :vartype sku: ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuInfo + :ivar system_data: Metadata pertaining to creation and last modification of the resource. + :vartype system_data: ~azure.mgmt.iothubprovisioningservices.models.SystemData """ _validation = { @@ -1009,6 +1205,7 @@ class ProvisioningServiceDescription(Resource): 'location': {'required': True}, 'properties': {'required': True}, 'sku': {'required': True}, + 'system_data': {'readonly': True}, } _attribute_map = { @@ -1020,6 +1217,7 @@ class ProvisioningServiceDescription(Resource): 'etag': {'key': 'etag', 'type': 'str'}, 'properties': {'key': 'properties', 'type': 'IotDpsPropertiesDescription'}, 'sku': {'key': 'sku', 'type': 'IotDpsSkuInfo'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, } def __init__( @@ -1032,10 +1230,25 @@ def __init__( etag: Optional[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] + :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: Required. Service specific properties for a provisioning service. + :paramtype properties: + ~azure.mgmt.iothubprovisioningservices.models.IotDpsPropertiesDescription + :keyword sku: Required. Sku info for a provisioning Service. + :paramtype sku: ~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuInfo + """ super(ProvisioningServiceDescription, self).__init__(location=location, tags=tags, **kwargs) self.etag = etag self.properties = properties self.sku = sku + self.system_data = None class ProvisioningServiceDescriptionListResult(msrest.serialization.Model): @@ -1043,8 +1256,9 @@ class ProvisioningServiceDescriptionListResult(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param value: List of provisioning service descriptions. - :type value: list[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :ivar value: List of provisioning service descriptions. + :vartype value: + list[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] :ivar next_link: the next link. :vartype next_link: str """ @@ -1064,6 +1278,11 @@ def __init__( value: Optional[List["ProvisioningServiceDescription"]] = None, **kwargs ): + """ + :keyword value: List of provisioning service descriptions. + :paramtype value: + list[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + """ super(ProvisioningServiceDescriptionListResult, self).__init__(**kwargs) self.value = value self.next_link = None @@ -1074,16 +1293,16 @@ class SharedAccessSignatureAuthorizationRuleAccessRightsDescription(msrest.seria All required parameters must be populated in order to send to Azure. - :param key_name: Required. Name of the key. - :type key_name: str - :param primary_key: Primary SAS key value. - :type primary_key: str - :param secondary_key: Secondary SAS key value. - :type secondary_key: str - :param rights: Required. Rights that this key has. Possible values include: "ServiceConfig", + :ivar key_name: Required. Name of the key. + :vartype key_name: str + :ivar primary_key: Primary SAS key value. + :vartype primary_key: str + :ivar secondary_key: Secondary SAS key value. + :vartype secondary_key: str + :ivar rights: Required. Rights that this key has. Possible values include: "ServiceConfig", "EnrollmentRead", "EnrollmentWrite", "DeviceConnect", "RegistrationStatusRead", "RegistrationStatusWrite". - :type rights: str or ~azure.mgmt.iothubprovisioningservices.models.AccessRightsDescription + :vartype rights: str or ~azure.mgmt.iothubprovisioningservices.models.AccessRightsDescription """ _validation = { @@ -1107,6 +1326,18 @@ def __init__( secondary_key: Optional[str] = None, **kwargs ): + """ + :keyword key_name: Required. Name of the key. + :paramtype key_name: str + :keyword primary_key: Primary SAS key value. + :paramtype primary_key: str + :keyword secondary_key: Secondary SAS key value. + :paramtype secondary_key: str + :keyword rights: Required. Rights that this key has. Possible values include: "ServiceConfig", + "EnrollmentRead", "EnrollmentWrite", "DeviceConnect", "RegistrationStatusRead", + "RegistrationStatusWrite". + :paramtype rights: str or ~azure.mgmt.iothubprovisioningservices.models.AccessRightsDescription + """ super(SharedAccessSignatureAuthorizationRuleAccessRightsDescription, self).__init__(**kwargs) self.key_name = key_name self.primary_key = primary_key @@ -1119,8 +1350,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.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] :ivar next_link: The next link. :vartype next_link: str @@ -1141,16 +1372,87 @@ def __init__( value: Optional[List["SharedAccessSignatureAuthorizationRuleAccessRightsDescription"]] = None, **kwargs ): + """ + :keyword value: The list of shared access policies. + :paramtype value: + list[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription] + """ super(SharedAccessSignatureAuthorizationRuleListResult, self).__init__(**kwargs) self.value = value self.next_link = None +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.iothubprovisioningservices.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or + ~azure.mgmt.iothubprovisioningservices.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.iothubprovisioningservices.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or + ~azure.mgmt.iothubprovisioningservices.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class TagsResource(msrest.serialization.Model): """A container holding only the Tags for a resource, allowing the user to update the tags on a Provisioning Service 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 = { @@ -1163,6 +1465,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 @@ -1170,9 +1476,9 @@ def __init__( class VerificationCodeRequest(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 = { @@ -1185,6 +1491,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(VerificationCodeRequest, self).__init__(**kwargs) self.certificate = certificate @@ -1202,8 +1513,8 @@ class VerificationCodeResponse(msrest.serialization.Model): :vartype id: str :ivar type: The resource type. :vartype type: str - :param properties: - :type properties: + :ivar properties: + :vartype properties: ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponseProperties """ @@ -1228,6 +1539,11 @@ def __init__( properties: Optional["VerificationCodeResponseProperties"] = None, **kwargs ): + """ + :keyword properties: + :paramtype properties: + ~azure.mgmt.iothubprovisioningservices.models.VerificationCodeResponseProperties + """ super(VerificationCodeResponse, self).__init__(**kwargs) self.name = None self.etag = None @@ -1239,23 +1555,23 @@ def __init__( class VerificationCodeResponseProperties(msrest.serialization.Model): """VerificationCodeResponseProperties. - :param verification_code: Verification code. - :type verification_code: str - :param subject: Certificate subject. - :type subject: str - :param expiry: Code expiry. - :type expiry: str - :param thumbprint: Certificate thumbprint. - :type thumbprint: str - :param is_verified: Indicate if the certificate is verified by owner of private key. - :type is_verified: bool - :param certificate: base-64 representation of X509 certificate .cer file or just .pem file + :ivar verification_code: Verification code. + :vartype verification_code: str + :ivar subject: Certificate subject. + :vartype subject: str + :ivar expiry: Code expiry. + :vartype expiry: str + :ivar thumbprint: Certificate thumbprint. + :vartype thumbprint: str + :ivar is_verified: Indicate if the certificate is verified by owner of private key. + :vartype is_verified: bool + :ivar certificate: base-64 representation of X509 certificate .cer file or just .pem file content. - :type certificate: bytearray - :param created: Certificate created time. - :type created: str - :param updated: Certificate updated time. - :type updated: str + :vartype certificate: bytearray + :ivar created: Certificate created time. + :vartype created: str + :ivar updated: Certificate updated time. + :vartype updated: str """ _attribute_map = { @@ -1282,6 +1598,25 @@ def __init__( updated: Optional[str] = None, **kwargs ): + """ + :keyword verification_code: Verification code. + :paramtype verification_code: str + :keyword subject: Certificate subject. + :paramtype subject: str + :keyword expiry: Code expiry. + :paramtype expiry: str + :keyword thumbprint: Certificate thumbprint. + :paramtype thumbprint: str + :keyword is_verified: Indicate if the certificate is verified by owner of private key. + :paramtype is_verified: bool + :keyword certificate: base-64 representation of X509 certificate .cer file or just .pem file + content. + :paramtype certificate: bytearray + :keyword created: Certificate created time. + :paramtype created: str + :keyword updated: Certificate updated time. + :paramtype updated: str + """ super(VerificationCodeResponseProperties, self).__init__(**kwargs) self.verification_code = verification_code self.subject = subject diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py index 301fa50f3ae4..46ef3da4a6d6 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_dps_certificate_operations.py @@ -6,22 +6,350 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- import datetime -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_get_request( + certificate_name: str, + subscription_id: str, + resource_group_name: str, + provisioning_service_name: str, + *, + if_match: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}') + path_format_arguments = { + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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') + 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, + provisioning_service_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-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str', max_length=256, min_length=0), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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, + provisioning_service_name: str, + certificate_name: str, + *, + if_match: str, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytearray] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if certificate_name1 is not None: + query_parameters['certificate.name'] = _SERIALIZER.query("certificate_name1", certificate_name1, 'str') + if certificate_raw_bytes is not None: + query_parameters['certificate.rawBytes'] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') + if certificate_is_verified is not None: + query_parameters['certificate.isVerified'] = _SERIALIZER.query("certificate_is_verified", certificate_is_verified, 'bool') + if certificate_purpose is not None: + query_parameters['certificate.purpose'] = _SERIALIZER.query("certificate_purpose", certificate_purpose, 'str') + if certificate_created is not None: + query_parameters['certificate.created'] = _SERIALIZER.query("certificate_created", certificate_created, 'iso-8601') + if certificate_last_updated is not None: + query_parameters['certificate.lastUpdated'] = _SERIALIZER.query("certificate_last_updated", certificate_last_updated, 'iso-8601') + if certificate_has_private_key is not None: + query_parameters['certificate.hasPrivateKey'] = _SERIALIZER.query("certificate_has_private_key", certificate_has_private_key, 'bool') + if certificate_nonce is not None: + query_parameters['certificate.nonce'] = _SERIALIZER.query("certificate_nonce", certificate_nonce, 'str') + 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_list_request( + subscription_id: str, + resource_group_name: str, + provisioning_service_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + 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_generate_verification_code_request( + certificate_name: str, + subscription_id: str, + resource_group_name: str, + provisioning_service_name: str, + *, + if_match: str, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytearray] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode') + path_format_arguments = { + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if certificate_name1 is not None: + query_parameters['certificate.name'] = _SERIALIZER.query("certificate_name1", certificate_name1, 'str') + if certificate_raw_bytes is not None: + query_parameters['certificate.rawBytes'] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') + if certificate_is_verified is not None: + query_parameters['certificate.isVerified'] = _SERIALIZER.query("certificate_is_verified", certificate_is_verified, 'bool') + if certificate_purpose is not None: + query_parameters['certificate.purpose'] = _SERIALIZER.query("certificate_purpose", certificate_purpose, 'str') + if certificate_created is not None: + query_parameters['certificate.created'] = _SERIALIZER.query("certificate_created", certificate_created, 'iso-8601') + if certificate_last_updated is not None: + query_parameters['certificate.lastUpdated'] = _SERIALIZER.query("certificate_last_updated", certificate_last_updated, 'iso-8601') + if certificate_has_private_key is not None: + query_parameters['certificate.hasPrivateKey'] = _SERIALIZER.query("certificate_has_private_key", certificate_has_private_key, 'bool') + if certificate_nonce is not None: + query_parameters['certificate.nonce'] = _SERIALIZER.query("certificate_nonce", certificate_nonce, 'str') + 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_certificate_request( + certificate_name: str, + subscription_id: str, + resource_group_name: str, + provisioning_service_name: str, + *, + if_match: str, + json: JSONType = None, + content: Any = None, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytearray] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify') + path_format_arguments = { + "certificateName": _SERIALIZER.url("certificate_name", certificate_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + if certificate_name1 is not None: + query_parameters['certificate.name'] = _SERIALIZER.query("certificate_name1", certificate_name1, 'str') + if certificate_raw_bytes is not None: + query_parameters['certificate.rawBytes'] = _SERIALIZER.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') + if certificate_is_verified is not None: + query_parameters['certificate.isVerified'] = _SERIALIZER.query("certificate_is_verified", certificate_is_verified, 'bool') + if certificate_purpose is not None: + query_parameters['certificate.purpose'] = _SERIALIZER.query("certificate_purpose", certificate_purpose, 'str') + if certificate_created is not None: + query_parameters['certificate.created'] = _SERIALIZER.query("certificate_created", certificate_created, 'iso-8601') + if certificate_last_updated is not None: + query_parameters['certificate.lastUpdated'] = _SERIALIZER.query("certificate_last_updated", certificate_last_updated, 'iso-8601') + if certificate_has_private_key is not None: + query_parameters['certificate.hasPrivateKey'] = _SERIALIZER.query("certificate_has_private_key", certificate_has_private_key, 'bool') + if certificate_nonce is not None: + query_parameters['certificate.nonce'] = _SERIALIZER.query("certificate_nonce", certificate_nonce, 'str') + 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 DpsCertificateOperations(object): """DpsCertificateOperations operations. @@ -45,15 +373,15 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - certificate_name, # type: str - resource_group_name, # type: str - provisioning_service_name, # type: str - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateResponse" + certificate_name: str, + resource_group_name: str, + provisioning_service_name: str, + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateResponse": """Get the certificate from the provisioning service. :param certificate_name: Name of the certificate to retrieve. @@ -75,36 +403,25 @@ 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 = { - 'certificateName': self._serialize.url("certificate_name", certificate_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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + if_match=if_match, + 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('CertificateResponse', pipeline_response) @@ -113,18 +430,20 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - provisioning_service_name, # type: str - certificate_name, # type: str - certificate_description, # type: "_models.CertificateBodyDescription" - if_match=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateResponse" + resource_group_name: str, + provisioning_service_name: str, + certificate_name: str, + certificate_description: "_models.CertificateBodyDescription", + if_match: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateResponse": """Upload the certificate to the provisioning service. Add new certificate or update an existing certificate. @@ -136,7 +455,8 @@ def create_or_update( :param certificate_name: The name of the certificate create or update. :type certificate_name: str :param certificate_description: The certificate body. - :type certificate_description: ~azure.mgmt.iothubprovisioningservices.models.CertificateBodyDescription + :type certificate_description: + ~azure.mgmt.iothubprovisioningservices.models.CertificateBodyDescription :param if_match: ETag of the certificate. This is required to update an existing certificate, and ignored while creating a brand new certificate. :type if_match: str @@ -150,41 +470,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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str', max_length=256, min_length=0), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # 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, + provisioning_service_name=provisioning_service_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]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorDetails, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('CertificateResponse', pipeline_response) @@ -193,25 +502,27 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - if_match, # type: str - provisioning_service_name, # type: str - certificate_name, # type: str - certificate_name1=None, # type: Optional[str] - certificate_raw_bytes=None, # type: Optional[bytearray] - certificate_is_verified=None, # type: Optional[bool] - certificate_purpose=None, # type: Optional[Union[str, "_models.CertificatePurpose"]] - certificate_created=None, # type: Optional[datetime.datetime] - certificate_last_updated=None, # type: Optional[datetime.datetime] - certificate_has_private_key=None, # type: Optional[bool] - certificate_nonce=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + if_match: str, + provisioning_service_name: str, + certificate_name: str, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytearray] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + **kwargs: Any + ) -> None: """Delete the Provisioning Service Certificate. Deletes the specified certificate associated with the Provisioning Service. @@ -233,7 +544,8 @@ def delete( private key. :type certificate_is_verified: bool :param certificate_purpose: A description that mentions the purpose of the certificate. - :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose :param certificate_created: Time the certificate is created. :type certificate_created: ~datetime.datetime :param certificate_last_updated: Time the certificate is last updated. @@ -252,51 +564,33 @@ 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - 'certificateName': self._serialize.url("certificate_name", certificate_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if certificate_name1 is not None: - query_parameters['certificate.name'] = self._serialize.query("certificate_name1", certificate_name1, 'str') - if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = self._serialize.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') - if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = self._serialize.query("certificate_is_verified", certificate_is_verified, 'bool') - if certificate_purpose is not None: - query_parameters['certificate.purpose'] = self._serialize.query("certificate_purpose", certificate_purpose, 'str') - if certificate_created is not None: - query_parameters['certificate.created'] = self._serialize.query("certificate_created", certificate_created, 'iso-8601') - if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = self._serialize.query("certificate_last_updated", certificate_last_updated, 'iso-8601') - if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificate_has_private_key", certificate_has_private_key, 'bool') - if certificate_nonce is not None: - query_parameters['certificate.nonce'] = self._serialize.query("certificate_nonce", certificate_nonce, 'str') - 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 = self._client.delete(url, query_parameters, header_parameters) + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + certificate_name=certificate_name, + if_match=if_match, + certificate_name1=certificate_name1, + certificate_raw_bytes=certificate_raw_bytes, + certificate_is_verified=certificate_is_verified, + certificate_purpose=certificate_purpose, + certificate_created=certificate_created, + certificate_last_updated=certificate_last_updated, + certificate_has_private_key=certificate_has_private_key, + certificate_nonce=certificate_nonce, + template_url=self.delete.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, 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: @@ -304,13 +598,14 @@ def delete( delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}'} # type: ignore + + @distributed_trace def list( self, - resource_group_name, # type: str - provisioning_service_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateListDescription" + resource_group_name: str, + provisioning_service_name: str, + **kwargs: Any + ) -> "_models.CertificateListDescription": """Get all the certificates tied to the provisioning service. :param resource_group_name: Name of resource group. @@ -327,33 +622,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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(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, + provisioning_service_name=provisioning_service_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('CertificateListDescription', pipeline_response) @@ -362,25 +647,27 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates'} # type: ignore + + @distributed_trace def generate_verification_code( self, - certificate_name, # type: str - if_match, # type: str - resource_group_name, # type: str - provisioning_service_name, # type: str - certificate_name1=None, # type: Optional[str] - certificate_raw_bytes=None, # type: Optional[bytearray] - certificate_is_verified=None, # type: Optional[bool] - certificate_purpose=None, # type: Optional[Union[str, "_models.CertificatePurpose"]] - certificate_created=None, # type: Optional[datetime.datetime] - certificate_last_updated=None, # type: Optional[datetime.datetime] - certificate_has_private_key=None, # type: Optional[bool] - certificate_nonce=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.VerificationCodeResponse" + certificate_name: str, + if_match: str, + resource_group_name: str, + provisioning_service_name: str, + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytearray] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + **kwargs: Any + ) -> "_models.VerificationCodeResponse": """Generate verification code for Proof of Possession. :param certificate_name: The mandatory logical name of the certificate, that the provisioning @@ -401,7 +688,8 @@ def generate_verification_code( private key. :type certificate_is_verified: bool :param certificate_purpose: Description mentioning the purpose of the certificate. - :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose :param certificate_created: Certificate creation time. :type certificate_created: ~datetime.datetime :param certificate_last_updated: Certificate last updated time. @@ -420,51 +708,33 @@ 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 = { - 'certificateName': self._serialize.url("certificate_name", certificate_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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if certificate_name1 is not None: - query_parameters['certificate.name'] = self._serialize.query("certificate_name1", certificate_name1, 'str') - if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = self._serialize.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') - if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = self._serialize.query("certificate_is_verified", certificate_is_verified, 'bool') - if certificate_purpose is not None: - query_parameters['certificate.purpose'] = self._serialize.query("certificate_purpose", certificate_purpose, 'str') - if certificate_created is not None: - query_parameters['certificate.created'] = self._serialize.query("certificate_created", certificate_created, 'iso-8601') - if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = self._serialize.query("certificate_last_updated", certificate_last_updated, 'iso-8601') - if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificate_has_private_key", certificate_has_private_key, 'bool') - if certificate_nonce is not None: - query_parameters['certificate.nonce'] = self._serialize.query("certificate_nonce", certificate_nonce, 'str') - 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 = self._client.post(url, query_parameters, header_parameters) + + + request = build_generate_verification_code_request( + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + if_match=if_match, + certificate_name1=certificate_name1, + certificate_raw_bytes=certificate_raw_bytes, + certificate_is_verified=certificate_is_verified, + certificate_purpose=certificate_purpose, + certificate_created=certificate_created, + certificate_last_updated=certificate_last_updated, + certificate_has_private_key=certificate_has_private_key, + certificate_nonce=certificate_nonce, + template_url=self.generate_verification_code.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('VerificationCodeResponse', pipeline_response) @@ -473,26 +743,28 @@ def generate_verification_code( return cls(pipeline_response, deserialized, {}) return deserialized + generate_verification_code.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/generateVerificationCode'} # type: ignore + + @distributed_trace def verify_certificate( self, - certificate_name, # type: str - if_match, # type: str - resource_group_name, # type: str - provisioning_service_name, # type: str - request, # type: "_models.VerificationCodeRequest" - certificate_name1=None, # type: Optional[str] - certificate_raw_bytes=None, # type: Optional[bytearray] - certificate_is_verified=None, # type: Optional[bool] - certificate_purpose=None, # type: Optional[Union[str, "_models.CertificatePurpose"]] - certificate_created=None, # type: Optional[datetime.datetime] - certificate_last_updated=None, # type: Optional[datetime.datetime] - certificate_has_private_key=None, # type: Optional[bool] - certificate_nonce=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.CertificateResponse" + certificate_name: str, + if_match: str, + resource_group_name: str, + provisioning_service_name: str, + request: "_models.VerificationCodeRequest", + certificate_name1: Optional[str] = None, + certificate_raw_bytes: Optional[bytearray] = None, + certificate_is_verified: Optional[bool] = None, + certificate_purpose: Optional[Union[str, "_models.CertificatePurpose"]] = None, + certificate_created: Optional[datetime.datetime] = None, + certificate_last_updated: Optional[datetime.datetime] = None, + certificate_has_private_key: Optional[bool] = None, + certificate_nonce: Optional[str] = None, + **kwargs: Any + ) -> "_models.CertificateResponse": """Verify certificate's private key possession. Verifies the certificate's private key possession by providing the leaf cert issued by the @@ -517,7 +789,8 @@ def verify_certificate( private key. :type certificate_is_verified: bool :param certificate_purpose: Describe the purpose of the certificate. - :type certificate_purpose: str or ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose + :type certificate_purpose: str or + ~azure.mgmt.iothubprovisioningservices.models.CertificatePurpose :param certificate_created: Certificate creation time. :type certificate_created: ~datetime.datetime :param certificate_last_updated: Certificate last updated time. @@ -536,56 +809,38 @@ def verify_certificate( 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_certificate.metadata['url'] # type: ignore - path_format_arguments = { - 'certificateName': self._serialize.url("certificate_name", certificate_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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - if certificate_name1 is not None: - query_parameters['certificate.name'] = self._serialize.query("certificate_name1", certificate_name1, 'str') - if certificate_raw_bytes is not None: - query_parameters['certificate.rawBytes'] = self._serialize.query("certificate_raw_bytes", certificate_raw_bytes, 'bytearray') - if certificate_is_verified is not None: - query_parameters['certificate.isVerified'] = self._serialize.query("certificate_is_verified", certificate_is_verified, 'bool') - if certificate_purpose is not None: - query_parameters['certificate.purpose'] = self._serialize.query("certificate_purpose", certificate_purpose, 'str') - if certificate_created is not None: - query_parameters['certificate.created'] = self._serialize.query("certificate_created", certificate_created, 'iso-8601') - if certificate_last_updated is not None: - query_parameters['certificate.lastUpdated'] = self._serialize.query("certificate_last_updated", certificate_last_updated, 'iso-8601') - if certificate_has_private_key is not None: - query_parameters['certificate.hasPrivateKey'] = self._serialize.query("certificate_has_private_key", certificate_has_private_key, 'bool') - if certificate_nonce is not None: - query_parameters['certificate.nonce'] = self._serialize.query("certificate_nonce", certificate_nonce, 'str') - 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(request, 'VerificationCodeRequest') - 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(request, 'VerificationCodeRequest') + + request = build_verify_certificate_request( + certificate_name=certificate_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + content_type=content_type, + if_match=if_match, + json=_json, + certificate_name1=certificate_name1, + certificate_raw_bytes=certificate_raw_bytes, + certificate_is_verified=certificate_is_verified, + certificate_purpose=certificate_purpose, + certificate_created=certificate_created, + certificate_last_updated=certificate_last_updated, + certificate_has_private_key=certificate_has_private_key, + certificate_nonce=certificate_nonce, + template_url=self.verify_certificate.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('CertificateResponse', pipeline_response) @@ -594,4 +849,6 @@ def verify_certificate( return cls(pipeline_response, deserialized, {}) return deserialized + verify_certificate.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/certificates/{certificateName}/verify'} # type: ignore + diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py index 715172d43336..49de021e3d5f 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_iot_dps_resource_operations.py @@ -5,25 +5,664 @@ # 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, List, 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, 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_get_request( + provisioning_service_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + path_format_arguments = { + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_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] + 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, + provisioning_service_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_update_request_initial( + subscription_id: str, + resource_group_name: str, + provisioning_service_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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( + provisioning_service_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}') + path_format_arguments = { + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_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] + 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-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/provisioningServices') + 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-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices') + 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_operation_result_request( + operation_id: str, + subscription_id: str, + resource_group_name: str, + provisioning_service_name: str, + *, + asyncinfo: str = "true", + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}') + path_format_arguments = { + "operationId": _SERIALIZER.url("operation_id", operation_id, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['asyncinfo'] = _SERIALIZER.query("asyncinfo", asyncinfo, 'str') + 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_valid_skus_request( + provisioning_service_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus') + path_format_arguments = { + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_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] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_check_provisioning_service_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-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability') + 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( + provisioning_service_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/listkeys') + path_format_arguments = { + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_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] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_keys_for_key_name_request( + provisioning_service_name: str, + key_name: str, + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys') + path_format_arguments = { + "provisioningServiceName": _SERIALIZER.url("provisioning_service_name", provisioning_service_name, 'str'), + "keyName": _SERIALIZER.url("key_name", key_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] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="POST", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_private_link_resources_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{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_private_link_resources_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + group_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{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 + ) + + +def build_list_private_endpoint_connections_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{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_private_endpoint_connection_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{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_create_or_update_private_endpoint_connection_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-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{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_private_endpoint_connection_request_initial( + subscription_id: str, + resource_group_name: str, + resource_name: str, + private_endpoint_connection_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-10-15" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{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 IotDpsResourceOperations(object): """IotDpsResourceOperations operations. @@ -47,13 +686,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - provisioning_service_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ProvisioningServiceDescription" + provisioning_service_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.ProvisioningServiceDescription": """Get the non-security related metadata of the provisioning service. Get the metadata of the provisioning service without SAS keys. @@ -72,33 +711,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 = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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('ProvisioningServiceDescription', pipeline_response) @@ -107,54 +736,44 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - provisioning_service_name, # type: str - iot_dps_description, # type: "_models.ProvisioningServiceDescription" - **kwargs # type: Any - ): - # type: (...) -> "_models.ProvisioningServiceDescription" + resource_group_name: str, + provisioning_service_name: str, + iot_dps_description: "_models.ProvisioningServiceDescription", + **kwargs: Any + ) -> "_models.ProvisioningServiceDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(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_dps_description, 'ProvisioningServiceDescription') + + request = build_create_or_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_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_dps_description, 'ProvisioningServiceDescription') - 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('ProvisioningServiceDescription', pipeline_response) @@ -166,16 +785,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/provisioningServices/{provisioningServiceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - provisioning_service_name, # type: str - iot_dps_description, # type: "_models.ProvisioningServiceDescription" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ProvisioningServiceDescription"] + resource_group_name: str, + provisioning_service_name: str, + iot_dps_description: "_models.ProvisioningServiceDescription", + **kwargs: Any + ) -> LROPoller["_models.ProvisioningServiceDescription"]: """Create or update the metadata of the provisioning service. Create or update the metadata of the provisioning service. The usual pattern to modify a @@ -187,18 +808,24 @@ def begin_create_or_update( :param provisioning_service_name: Name of provisioning service to create or update. :type provisioning_service_name: str :param iot_dps_description: Description of the provisioning service to create or update. - :type iot_dps_description: ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription + :type iot_dps_description: + ~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription :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 ProvisioningServiceDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :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 ProvisioningServiceDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :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.ProvisioningServiceDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -210,27 +837,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, iot_dps_description=iot_dps_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('ProvisioningServiceDescription', 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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: @@ -242,47 +863,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/provisioningServices/{provisioningServiceName}'} # type: ignore def _update_initial( self, - resource_group_name, # type: str - provisioning_service_name, # type: str - provisioning_service_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> "_models.ProvisioningServiceDescription" + resource_group_name: str, + provisioning_service_name: str, + provisioning_service_tags: "_models.TagsResource", + **kwargs: Any + ) -> "_models.ProvisioningServiceDescription": cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescription"] 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(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(provisioning_service_tags, 'TagsResource') + + request = build_update_request_initial( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_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(provisioning_service_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 @@ -296,16 +907,18 @@ def _update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + + @distributed_trace def begin_update( self, - resource_group_name, # type: str - provisioning_service_name, # type: str - provisioning_service_tags, # type: "_models.TagsResource" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.ProvisioningServiceDescription"] + resource_group_name: str, + provisioning_service_name: str, + provisioning_service_tags: "_models.TagsResource", + **kwargs: Any + ) -> LROPoller["_models.ProvisioningServiceDescription"]: """Update an existing provisioning service's tags. Update an existing provisioning service's tags. to update other fields use the CreateOrUpdate @@ -320,15 +933,20 @@ def begin_update( :type provisioning_service_tags: ~azure.mgmt.iothubprovisioningservices.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 ProvisioningServiceDescription or the result of cls(response) - :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] - :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 ProvisioningServiceDescription or the + result of cls(response) + :rtype: + ~azure.core.polling.LROPoller[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescription] + :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.ProvisioningServiceDescription"] lro_delay = kwargs.pop( 'polling_interval', @@ -340,27 +958,21 @@ def begin_update( resource_group_name=resource_group_name, provisioning_service_name=provisioning_service_name, provisioning_service_tags=provisioning_service_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('ProvisioningServiceDescription', 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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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: @@ -372,61 +984,51 @@ 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/provisioningServices/{provisioningServiceName}'} # type: ignore def _delete_initial( self, - provisioning_service_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + provisioning_service_name: str, + resource_group_name: str, + **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" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - provisioning_service_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + provisioning_service_name: str, + resource_group_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Delete the Provisioning Service. Deletes the Provisioning Service. @@ -437,15 +1039,17 @@ def begin_delete( :type resource_group_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. + :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] + 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', @@ -459,21 +1063,14 @@ 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): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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: @@ -485,20 +1082,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/provisioningServices/{provisioningServiceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProvisioningServiceDescriptionListResult"] + **kwargs: Any + ) -> Iterable["_models.ProvisioningServiceDescriptionListResult"]: """Get all the provisioning services in a subscription. List all the provisioning services for a given subscription id. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] + :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] @@ -506,34 +1106,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('ProvisioningServiceDescriptionListResult', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -546,30 +1141,33 @@ 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/provisioningServices'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ProvisioningServiceDescriptionListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ProvisioningServiceDescriptionListResult"]: """Get a list of all provisioning services in the given resource group. :param resource_group_name: Resource group identifier. :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 ProvisioningServiceDescriptionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] + :return: An iterator like instance of either ProvisioningServiceDescriptionListResult or the + result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.ProvisioningServiceDescriptionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProvisioningServiceDescriptionListResult"] @@ -577,35 +1175,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('ProvisioningServiceDescriptionListResult', pipeline_response) + deserialized = self._deserialize("ProvisioningServiceDescriptionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -618,26 +1212,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_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices'} # type: ignore + @distributed_trace def get_operation_result( self, - operation_id, # type: str - resource_group_name, # type: str - provisioning_service_name, # type: str - asyncinfo="true", # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AsyncOperationResult" + operation_id: str, + resource_group_name: str, + provisioning_service_name: str, + asyncinfo: str = "true", + **kwargs: Any + ) -> "_models.AsyncOperationResult": """Gets the status of a long running operation, such as create, update or delete a provisioning service. @@ -662,35 +1257,25 @@ def get_operation_result( 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_operation_result.metadata['url'] # type: ignore - path_format_arguments = { - 'operationId': self._serialize.url("operation_id", operation_id, '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'), - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['asyncinfo'] = self._serialize.query("asyncinfo", asyncinfo, 'str') - 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_operation_result_request( + operation_id=operation_id, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provisioning_service_name=provisioning_service_name, + asyncinfo=asyncinfo, + template_url=self.get_operation_result.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('AsyncOperationResult', pipeline_response) @@ -699,15 +1284,17 @@ def get_operation_result( return cls(pipeline_response, deserialized, {}) return deserialized + get_operation_result.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/operationresults/{operationId}'} # type: ignore + + @distributed_trace def list_valid_skus( self, - provisioning_service_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.IotDpsSkuDefinitionListResult"] + provisioning_service_name: str, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.IotDpsSkuDefinitionListResult"]: """Get the list of valid SKUs for a provisioning service. Gets the list of valid SKUs and tiers for a provisioning service. @@ -717,8 +1304,10 @@ def list_valid_skus( :param resource_group_name: Name of resource group. :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 IotDpsSkuDefinitionListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinitionListResult] + :return: An iterator like instance of either IotDpsSkuDefinitionListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.IotDpsSkuDefinitionListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.IotDpsSkuDefinitionListResult"] @@ -726,36 +1315,33 @@ def list_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.list_valid_skus.metadata['url'] # type: ignore - path_format_arguments = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_valid_skus_request( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_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_list_valid_skus_request( + provisioning_service_name=provisioning_service_name, + 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('IotDpsSkuDefinitionListResult', pipeline_response) + deserialized = self._deserialize("IotDpsSkuDefinitionListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -768,23 +1354,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_valid_skus.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/skus'} # type: ignore + @distributed_trace def check_provisioning_service_name_availability( self, - arguments, # type: "_models.OperationInputs" - **kwargs # type: Any - ): - # type: (...) -> "_models.NameAvailabilityInfo" + arguments: "_models.OperationInputs", + **kwargs: Any + ) -> "_models.NameAvailabilityInfo": """Check if a provisioning service name is available. Check if a provisioning service name is available. This will validate if the name is @@ -803,36 +1390,26 @@ def check_provisioning_service_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_provisioning_service_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(arguments, 'OperationInputs') + + request = build_check_provisioning_service_name_availability_request( + subscription_id=self._config.subscription_id, + content_type=content_type, + json=_json, + template_url=self.check_provisioning_service_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(arguments, '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('NameAvailabilityInfo', pipeline_response) @@ -841,15 +1418,17 @@ def check_provisioning_service_name_availability( return cls(pipeline_response, deserialized, {}) return deserialized + check_provisioning_service_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Devices/checkProvisioningServiceNameAvailability'} # type: ignore + + @distributed_trace def list_keys( self, - provisioning_service_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"] + provisioning_service_name: str, + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.SharedAccessSignatureAuthorizationRuleListResult"]: """Get the security metadata for a provisioning service. List the primary and secondary keys for a provisioning service. @@ -860,8 +1439,10 @@ def list_keys( :param resource_group_name: resource group name. :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 SharedAccessSignatureAuthorizationRuleListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleListResult] + :return: An iterator like instance of either SharedAccessSignatureAuthorizationRuleListResult + or the result of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleListResult"] @@ -869,36 +1450,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 = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_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') - - request = self._client.post(url, query_parameters, header_parameters) + + request = build_list_keys_request( + provisioning_service_name=provisioning_service_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_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( + provisioning_service_name=provisioning_service_name, + 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('SharedAccessSignatureAuthorizationRuleListResult', pipeline_response) + deserialized = self._deserialize("SharedAccessSignatureAuthorizationRuleListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -911,25 +1489,26 @@ 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/provisioningServices/{provisioningServiceName}/listkeys'} # type: ignore + @distributed_trace def list_keys_for_key_name( self, - provisioning_service_name, # type: str - key_name, # type: str - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription" + provisioning_service_name: str, + key_name: str, + resource_group_name: str, + **kwargs: Any + ) -> "_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription": """Get a shared access policy by name from a provisioning service. List primary and secondary keys for a specific key name. @@ -942,8 +1521,10 @@ def list_keys_for_key_name( service. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription, or the result of cls(response) - :rtype: ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription + :return: SharedAccessSignatureAuthorizationRuleAccessRightsDescription, or the result of + cls(response) + :rtype: + ~azure.mgmt.iothubprovisioningservices.models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SharedAccessSignatureAuthorizationRuleAccessRightsDescription"] @@ -951,34 +1532,24 @@ def list_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.list_keys_for_key_name.metadata['url'] # type: ignore - path_format_arguments = { - 'provisioningServiceName': self._serialize.url("provisioning_service_name", provisioning_service_name, 'str'), - 'keyName': self._serialize.url("key_name", key_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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_keys_for_key_name_request( + provisioning_service_name=provisioning_service_name, + key_name=key_name, + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_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('SharedAccessSignatureAuthorizationRuleAccessRightsDescription', pipeline_response) @@ -987,15 +1558,17 @@ def list_keys_for_key_name( return cls(pipeline_response, deserialized, {}) return deserialized + list_keys_for_key_name.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{provisioningServiceName}/keys/{keyName}/listkeys'} # type: ignore + + @distributed_trace def list_private_link_resources( 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 provisioning service. @@ -1015,33 +1588,23 @@ def list_private_link_resources( 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_private_link_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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_private_link_resources_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_private_link_resources.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('PrivateLinkResources', pipeline_response) @@ -1050,16 +1613,18 @@ def list_private_link_resources( return cls(pipeline_response, deserialized, {}) return deserialized + list_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources'} # type: ignore + + @distributed_trace def get_private_link_resources( 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 provisioning service. @@ -1081,34 +1646,24 @@ def get_private_link_resources( 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_private_link_resources.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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_private_link_resources_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_private_link_resources.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) @@ -1117,15 +1672,17 @@ def get_private_link_resources( return cls(pipeline_response, deserialized, {}) return deserialized + get_private_link_resources.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateLinkResources/{groupId}'} # type: ignore + + @distributed_trace def list_private_endpoint_connections( 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. @@ -1145,33 +1702,23 @@ def list_private_endpoint_connections( 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_private_endpoint_connections.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[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_private_endpoint_connections_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.list_private_endpoint_connections.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) @@ -1180,16 +1727,18 @@ def list_private_endpoint_connections( return cls(pipeline_response, deserialized, {}) return deserialized + list_private_endpoint_connections.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections'} # type: ignore + + @distributed_trace def get_private_endpoint_connection( 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. @@ -1211,34 +1760,24 @@ def get_private_endpoint_connection( 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_private_endpoint_connection.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._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_private_endpoint_connection_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_private_endpoint_connection.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) @@ -1247,56 +1786,46 @@ def get_private_endpoint_connection( return cls(pipeline_response, deserialized, {}) return deserialized + get_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + def _create_or_update_private_endpoint_connection_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._create_or_update_private_endpoint_connection_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_create_or_update_private_endpoint_connection_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._create_or_update_private_endpoint_connection_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) @@ -1308,17 +1837,19 @@ def _create_or_update_private_endpoint_connection_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_create_or_update_private_endpoint_connection( 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"]: """Create or update private endpoint connection. Create or update the status of a private endpoint connection with the specified name. @@ -1331,18 +1862,24 @@ def begin_create_or_update_private_endpoint_connection( :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.iothubprovisioningservices.models.PrivateEndpointConnection + :type private_endpoint_connection: + ~azure.mgmt.iothubprovisioningservices.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.iothubprovisioningservices.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.iothubprovisioningservices.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', @@ -1355,28 +1892,21 @@ def begin_create_or_update_private_endpoint_connection( 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: @@ -1388,50 +1918,39 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore def _delete_private_endpoint_connection_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_private_endpoint_connection_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_private_endpoint_connection_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_private_endpoint_connection_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: @@ -1444,16 +1963,18 @@ def _delete_private_endpoint_connection_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _delete_private_endpoint_connection_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore + + @distributed_trace def begin_delete_private_endpoint_connection( 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. @@ -1467,15 +1988,19 @@ def begin_delete_private_endpoint_connection( :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.iothubprovisioningservices.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.iothubprovisioningservices.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', @@ -1490,25 +2015,17 @@ def begin_delete_private_endpoint_connection( 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: @@ -1520,4 +2037,5 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete_private_endpoint_connection.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Devices/provisioningServices/{resourceName}/privateEndpointConnections/{privateEndpointConnectionName}'} # type: ignore diff --git a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_operations.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_operations.py index 30ea78a1286e..41c645e0e4b8 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/operations/_operations.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/azure/mgmt/iothubprovisioningservices/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-10-15" + 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 Microsoft.Devices 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.iothubprovisioningservices.models.OperationListResult] + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.iothubprovisioningservices.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 = "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 +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-iothubprovisioningservices/setup.py b/sdk/iothub/azure-mgmt-iothubprovisioningservices/setup.py index dd3283386896..be2ec485c645 100644 --- a/sdk/iothub/azure-mgmt-iothubprovisioningservices/setup.py +++ b/sdk/iothub/azure-mgmt-iothubprovisioningservices/setup.py @@ -68,7 +68,7 @@ install_requires=[ 'msrest>=0.6.21', 'azure-common~=1.1', - 'azure-mgmt-core>=1.2.0,<2.0.0', + 'azure-mgmt-core>=1.3.0,<2.0.0', ], python_requires=">=3.6", ) diff --git a/shared_requirements.txt b/shared_requirements.txt index 4dc3bde1094f..b64019111f4c 100644 --- a/shared_requirements.txt +++ b/shared_requirements.txt @@ -268,6 +268,8 @@ opentelemetry-sdk<2.0.0,>=1.5.0,!=1.10a0 #override azure-mgmt-trafficmanager azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-containerregistry msrest>=0.6.21 #override azure-mgmt-containerregistry azure-mgmt-core>=1.3.0,<2.0.0 +#override azure-mgmt-iothubprovisioningservices msrest>=0.6.21 +#override azure-mgmt-iothubprovisioningservices azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-iothub msrest>=0.6.21 #override azure-mgmt-iothub azure-mgmt-core>=1.3.0,<2.0.0 #override azure-mgmt-resource msrest>=0.6.21