From a88ac1631c305f2b94442f26cf9e43d73ae62c4b Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Jan 2022 07:28:16 +0000 Subject: [PATCH] CodeGen from PR 16949 in Azure/azure-rest-api-specs Track2 modify readme.go.md 6 (#16949) * Track2 modify readme.go.md 6 * mariadb derective description --- .../azure-mgmt-maintenance/_meta.json | 10 +- .../azure/mgmt/maintenance/__init__.py | 9 +- .../azure/mgmt/maintenance/_configuration.py | 19 +- .../_maintenance_management_client.py | 138 ++- .../azure/mgmt/maintenance/_metadata.json | 21 +- .../azure/mgmt/maintenance/_patch.py | 31 + .../azure/mgmt/maintenance/_vendor.py | 27 + .../azure/mgmt/maintenance/_version.py | 2 +- .../azure/mgmt/maintenance/aio/__init__.py | 5 + .../mgmt/maintenance/aio/_configuration.py | 6 +- .../aio/_maintenance_management_client.py | 124 +-- .../azure/mgmt/maintenance/aio/_patch.py | 31 + ...ly_update_for_resource_group_operations.py | 55 +- .../operations/_apply_updates_operations.py | 212 ++-- .../_configuration_assignments_operations.py | 401 ++++---- ...ignments_within_subscription_operations.py | 58 +- ...gurations_for_resource_group_operations.py | 61 +- .../_maintenance_configurations_operations.py | 206 ++-- .../maintenance/aio/operations/_operations.py | 50 +- ...c_maintenance_configurations_operations.py | 89 +- .../aio/operations/_updates_operations.py | 131 +-- .../azure/mgmt/maintenance/models/__init__.py | 60 +- .../_maintenance_management_client_enums.py | 33 +- .../azure/mgmt/maintenance/models/_models.py | 672 ------------- .../mgmt/maintenance/models/_models_py3.py | 454 ++++++--- ...ly_update_for_resource_group_operations.py | 106 +- .../operations/_apply_updates_operations.py | 491 ++++++---- .../_configuration_assignments_operations.py | 907 ++++++++++++------ ...ignments_within_subscription_operations.py | 105 +- ...gurations_for_resource_group_operations.py | 112 ++- .../_maintenance_configurations_operations.py | 452 ++++++--- .../maintenance/operations/_operations.py | 88 +- ...c_maintenance_configurations_operations.py | 176 ++-- .../operations/_updates_operations.py | 248 +++-- 34 files changed, 3011 insertions(+), 2579 deletions(-) create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_patch.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_patch.py delete mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models.py diff --git a/sdk/maintenance/azure-mgmt-maintenance/_meta.json b/sdk/maintenance/azure-mgmt-maintenance/_meta.json index d9b69f081ccf..3a050e262fcf 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/_meta.json +++ b/sdk/maintenance/azure-mgmt-maintenance/_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": "f4c77149bdbc236d428576d806690a954e4bb0aa", + "commit": "e8c6db17dc13a00155936dcaeacf4da0a1fabf77", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/maintenance/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/maintenance/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/maintenance/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py index 5102b6845a6d..568ed0cad22c 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MaintenanceManagementClient'] -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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py index 46bb9c58c518..0b6e98f43319 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MaintenanceManagementClientConfiguration(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(MaintenanceManagementClientConfiguration, 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(MaintenanceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py index 93d214cc8816..2f94242a6112 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_maintenance_management_client.py @@ -6,113 +6,109 @@ # 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 MaintenanceManagementClientConfiguration +from .operations import ApplyUpdateForResourceGroupOperations, ApplyUpdatesOperations, ConfigurationAssignmentsOperations, ConfigurationAssignmentsWithinSubscriptionOperations, MaintenanceConfigurationsForResourceGroupOperations, MaintenanceConfigurationsOperations, Operations, PublicMaintenanceConfigurationsOperations, UpdatesOperations + 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 MaintenanceManagementClientConfiguration -from .operations import PublicMaintenanceConfigurationsOperations -from .operations import ApplyUpdatesOperations -from .operations import ConfigurationAssignmentsOperations -from .operations import MaintenanceConfigurationsOperations -from .operations import MaintenanceConfigurationsForResourceGroupOperations -from .operations import ApplyUpdateForResourceGroupOperations -from .operations import ConfigurationAssignmentsWithinSubscriptionOperations -from .operations import Operations -from .operations import UpdatesOperations -from . import models - -class MaintenanceManagementClient(object): +class MaintenanceManagementClient: """Azure Maintenance Management Client. :ivar public_maintenance_configurations: PublicMaintenanceConfigurationsOperations operations - :vartype public_maintenance_configurations: azure.mgmt.maintenance.operations.PublicMaintenanceConfigurationsOperations + :vartype public_maintenance_configurations: + azure.mgmt.maintenance.operations.PublicMaintenanceConfigurationsOperations :ivar apply_updates: ApplyUpdatesOperations operations :vartype apply_updates: azure.mgmt.maintenance.operations.ApplyUpdatesOperations :ivar configuration_assignments: ConfigurationAssignmentsOperations operations - :vartype configuration_assignments: azure.mgmt.maintenance.operations.ConfigurationAssignmentsOperations + :vartype configuration_assignments: + azure.mgmt.maintenance.operations.ConfigurationAssignmentsOperations :ivar maintenance_configurations: MaintenanceConfigurationsOperations operations - :vartype maintenance_configurations: azure.mgmt.maintenance.operations.MaintenanceConfigurationsOperations - :ivar maintenance_configurations_for_resource_group: MaintenanceConfigurationsForResourceGroupOperations operations - :vartype maintenance_configurations_for_resource_group: azure.mgmt.maintenance.operations.MaintenanceConfigurationsForResourceGroupOperations + :vartype maintenance_configurations: + azure.mgmt.maintenance.operations.MaintenanceConfigurationsOperations + :ivar maintenance_configurations_for_resource_group: + MaintenanceConfigurationsForResourceGroupOperations operations + :vartype maintenance_configurations_for_resource_group: + azure.mgmt.maintenance.operations.MaintenanceConfigurationsForResourceGroupOperations :ivar apply_update_for_resource_group: ApplyUpdateForResourceGroupOperations operations - :vartype apply_update_for_resource_group: azure.mgmt.maintenance.operations.ApplyUpdateForResourceGroupOperations - :ivar configuration_assignments_within_subscription: ConfigurationAssignmentsWithinSubscriptionOperations operations - :vartype configuration_assignments_within_subscription: azure.mgmt.maintenance.operations.ConfigurationAssignmentsWithinSubscriptionOperations + :vartype apply_update_for_resource_group: + azure.mgmt.maintenance.operations.ApplyUpdateForResourceGroupOperations + :ivar configuration_assignments_within_subscription: + ConfigurationAssignmentsWithinSubscriptionOperations operations + :vartype configuration_assignments_within_subscription: + azure.mgmt.maintenance.operations.ConfigurationAssignmentsWithinSubscriptionOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.maintenance.operations.Operations :ivar updates: UpdatesOperations operations :vartype updates: azure.mgmt.maintenance.operations.UpdatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = MaintenanceManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MaintenanceManagementClientConfiguration(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.public_maintenance_configurations = PublicMaintenanceConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.apply_updates = ApplyUpdatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_assignments = ConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_configurations = MaintenanceConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) - self.apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.updates = UpdatesOperations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + self._serialize.client_side_validation = False + self.public_maintenance_configurations = PublicMaintenanceConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.apply_updates = ApplyUpdatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_assignments = ConfigurationAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_configurations = MaintenanceConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.updates = UpdatesOperations(self._client, self._config, self._serialize, self._deserialize) + + + 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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_metadata.json b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_metadata.json index f2d6f2b65a0b..897f5838766f 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_metadata.json +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_metadata.json @@ -5,13 +5,13 @@ "name": "MaintenanceManagementClient", "filename": "_maintenance_management_client", "description": "Azure Maintenance Management Client.", - "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": false, "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\": [\"MaintenanceManagementClientConfiguration\"]}}, \"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\": [\"MaintenanceManagementClientConfiguration\"]}}, \"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\": [\"MaintenanceManagementClientConfiguration\"]}}, \"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\": [\"MaintenanceManagementClientConfiguration\"]}}, \"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": { "public_maintenance_configurations": "PublicMaintenanceConfigurationsOperations", diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_patch.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py index b82e03a368ff..e5754a47ce68 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "2.1.0b1" +VERSION = "1.0.0b1" diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py index c23a09cf9909..8ef86008c257 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/__init__.py @@ -8,3 +8,8 @@ from ._maintenance_management_client import MaintenanceManagementClient __all__ = ['MaintenanceManagementClient'] + +# `._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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py index 8924dc7256c1..2e62e3650ee1 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(MaintenanceManagementClientConfiguration, 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(MaintenanceManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py index e7f311484ac9..afdddb5bc7da 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_maintenance_management_client.py @@ -6,109 +6,109 @@ # 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 MaintenanceManagementClientConfiguration +from .operations import ApplyUpdateForResourceGroupOperations, ApplyUpdatesOperations, ConfigurationAssignmentsOperations, ConfigurationAssignmentsWithinSubscriptionOperations, MaintenanceConfigurationsForResourceGroupOperations, MaintenanceConfigurationsOperations, Operations, PublicMaintenanceConfigurationsOperations, UpdatesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MaintenanceManagementClientConfiguration -from .operations import PublicMaintenanceConfigurationsOperations -from .operations import ApplyUpdatesOperations -from .operations import ConfigurationAssignmentsOperations -from .operations import MaintenanceConfigurationsOperations -from .operations import MaintenanceConfigurationsForResourceGroupOperations -from .operations import ApplyUpdateForResourceGroupOperations -from .operations import ConfigurationAssignmentsWithinSubscriptionOperations -from .operations import Operations -from .operations import UpdatesOperations -from .. import models - - -class MaintenanceManagementClient(object): +class MaintenanceManagementClient: """Azure Maintenance Management Client. :ivar public_maintenance_configurations: PublicMaintenanceConfigurationsOperations operations - :vartype public_maintenance_configurations: azure.mgmt.maintenance.aio.operations.PublicMaintenanceConfigurationsOperations + :vartype public_maintenance_configurations: + azure.mgmt.maintenance.aio.operations.PublicMaintenanceConfigurationsOperations :ivar apply_updates: ApplyUpdatesOperations operations :vartype apply_updates: azure.mgmt.maintenance.aio.operations.ApplyUpdatesOperations :ivar configuration_assignments: ConfigurationAssignmentsOperations operations - :vartype configuration_assignments: azure.mgmt.maintenance.aio.operations.ConfigurationAssignmentsOperations + :vartype configuration_assignments: + azure.mgmt.maintenance.aio.operations.ConfigurationAssignmentsOperations :ivar maintenance_configurations: MaintenanceConfigurationsOperations operations - :vartype maintenance_configurations: azure.mgmt.maintenance.aio.operations.MaintenanceConfigurationsOperations - :ivar maintenance_configurations_for_resource_group: MaintenanceConfigurationsForResourceGroupOperations operations - :vartype maintenance_configurations_for_resource_group: azure.mgmt.maintenance.aio.operations.MaintenanceConfigurationsForResourceGroupOperations + :vartype maintenance_configurations: + azure.mgmt.maintenance.aio.operations.MaintenanceConfigurationsOperations + :ivar maintenance_configurations_for_resource_group: + MaintenanceConfigurationsForResourceGroupOperations operations + :vartype maintenance_configurations_for_resource_group: + azure.mgmt.maintenance.aio.operations.MaintenanceConfigurationsForResourceGroupOperations :ivar apply_update_for_resource_group: ApplyUpdateForResourceGroupOperations operations - :vartype apply_update_for_resource_group: azure.mgmt.maintenance.aio.operations.ApplyUpdateForResourceGroupOperations - :ivar configuration_assignments_within_subscription: ConfigurationAssignmentsWithinSubscriptionOperations operations - :vartype configuration_assignments_within_subscription: azure.mgmt.maintenance.aio.operations.ConfigurationAssignmentsWithinSubscriptionOperations + :vartype apply_update_for_resource_group: + azure.mgmt.maintenance.aio.operations.ApplyUpdateForResourceGroupOperations + :ivar configuration_assignments_within_subscription: + ConfigurationAssignmentsWithinSubscriptionOperations operations + :vartype configuration_assignments_within_subscription: + azure.mgmt.maintenance.aio.operations.ConfigurationAssignmentsWithinSubscriptionOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.maintenance.aio.operations.Operations :ivar updates: UpdatesOperations operations :vartype updates: azure.mgmt.maintenance.aio.operations.UpdatesOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials that uniquely identify a Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ 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 = MaintenanceManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = MaintenanceManagementClientConfiguration(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.public_maintenance_configurations = PublicMaintenanceConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.apply_updates = ApplyUpdatesOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_assignments = ConfigurationAssignmentsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_configurations = MaintenanceConfigurationsOperations(self._client, self._config, self._serialize, self._deserialize) + self.maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations(self._client, self._config, self._serialize, self._deserialize) + self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.updates = UpdatesOperations(self._client, self._config, self._serialize, self._deserialize) + - self.public_maintenance_configurations = PublicMaintenanceConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.apply_updates = ApplyUpdatesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_assignments = ConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_configurations = MaintenanceConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) - self.apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) - self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - self.updates = UpdatesOperations( - 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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_patch.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/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/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_operations.py index 99db08a29257..dea235582fa8 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_update_for_resource_group_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._apply_update_for_resource_group_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, resource_group_name: str, @@ -62,35 +68,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - '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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.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_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('ListApplyUpdate', pipeline_response) + deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,12 +105,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py index e09a6cb1cd96..45c5e75951e9 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_apply_updates_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._apply_updates_operations import build_create_or_update_parent_request, build_create_or_update_request, build_get_parent_request, build_get_request, 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_async async def get_parent( self, resource_group_name: str, @@ -80,38 +86,28 @@ async def get_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'applyUpdateName': self._serialize.url("apply_update_name", apply_update_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + apply_update_name=apply_update_name, + template_url=self.get_parent.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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -120,8 +116,11 @@ async def get_parent( return cls(pipeline_response, deserialized, {}) return deserialized + get_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -155,36 +154,26 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'applyUpdateName': self._serialize.url("apply_update_name", apply_update_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + apply_update_name=apply_update_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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -193,8 +182,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}'} # type: ignore + + @distributed_trace_async async def create_or_update_parent( self, resource_group_name: str, @@ -231,37 +223,27 @@ async def create_or_update_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.create_or_update_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.create_or_update_parent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -270,8 +252,11 @@ async def create_or_update_parent( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -302,35 +287,25 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - 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'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -339,8 +314,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -359,34 +337,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListApplyUpdate', pipeline_response) + deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -399,12 +372,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_operations.py index a9204b392c7a..5feda6120cc5 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_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._configuration_assignments_operations import build_create_or_update_parent_request, build_create_or_update_request, build_delete_parent_request, build_delete_request, build_get_parent_request, build_get_request, build_list_parent_request, 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_async async def get_parent( self, resource_group_name: str, @@ -80,38 +86,28 @@ async def get_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + template_url=self.get_parent.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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -120,8 +116,11 @@ async def get_parent( return cls(pipeline_response, deserialized, {}) return deserialized + get_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace_async async def create_or_update_parent( self, resource_group_name: str, @@ -164,43 +163,33 @@ async def create_or_update_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(configuration_assignment, 'ConfigurationAssignment') + + request = build_create_or_update_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update_parent.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(configuration_assignment, 'ConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -209,8 +198,11 @@ async def create_or_update_parent( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete_parent( self, resource_group_name: str, @@ -250,38 +242,28 @@ async def delete_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + template_url=self.delete_parent.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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -292,8 +274,11 @@ async def delete_parent( return cls(pipeline_response, deserialized, {}) return deserialized + delete_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace_async async def get( self, resource_group_name: str, @@ -327,36 +312,26 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -365,8 +340,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -403,41 +381,31 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(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(configuration_assignment, 'ConfigurationAssignment') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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(configuration_assignment, 'ConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -446,8 +414,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -481,36 +452,26 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + template_url=self.delete.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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -521,8 +482,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace def list_parent( self, resource_group_name: str, @@ -550,8 +514,10 @@ def list_parent( :param resource_name: Resource identifier. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] + :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListConfigurationAssignmentsResult"] @@ -559,40 +525,41 @@ def list_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list_parent.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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListConfigurationAssignmentsResult', pipeline_response) + deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -605,17 +572,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments'} # type: ignore + @distributed_trace def list( self, resource_group_name: str, @@ -637,8 +606,10 @@ def list( :param resource_name: Resource identifier. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] + :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListConfigurationAssignmentsResult"] @@ -646,38 +617,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list.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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListConfigurationAssignmentsResult', pipeline_response) + deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -690,12 +660,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_operations.py index 6d2a47bd487f..c9584a735399 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_configuration_assignments_within_subscription_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._configuration_assignments_within_subscription_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 @@ -50,8 +56,10 @@ def list( Get configuration assignment within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] + :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListConfigurationAssignmentsResult"] @@ -59,34 +67,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListConfigurationAssignmentsResult', pipeline_response) + deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -99,12 +102,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_operations.py index 988fb6485e6b..078992c111f4 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_for_resource_group_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._maintenance_configurations_for_resource_group_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, resource_group_name: str, @@ -53,8 +59,10 @@ def list( :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 ListMaintenanceConfigurationsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] + :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListMaintenanceConfigurationsResult"] @@ -62,35 +70,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - '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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.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_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('ListMaintenanceConfigurationsResult', pipeline_response) + deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,12 +107,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_operations.py index a5601c015e65..609be714a5e6 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_maintenance_configurations_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._maintenance_configurations_operations import build_create_or_update_request, build_delete_request, build_get_request, build_list_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -65,33 +71,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -100,8 +96,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace_async async def create_or_update( self, resource_group_name: str, @@ -129,38 +128,28 @@ async def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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(configuration, 'MaintenanceConfiguration') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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(configuration, 'MaintenanceConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -169,8 +158,11 @@ async def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace_async async def delete( self, resource_group_name: str, @@ -195,33 +187,23 @@ async def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -232,8 +214,11 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -261,38 +246,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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(configuration, 'MaintenanceConfiguration') - # 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.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(configuration, 'MaintenanceConfiguration') - 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -301,8 +276,11 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace def list( self, **kwargs: Any @@ -312,8 +290,10 @@ def list( Get Configuration records within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] + :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListMaintenanceConfigurationsResult"] @@ -321,34 +301,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListMaintenanceConfigurationsResult', pipeline_response) + deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -361,12 +336,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_operations.py index d8f49852b715..4db87012c04a 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/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 @@ -50,8 +56,10 @@ def list( List the available operations supported by the Microsoft.Maintenance resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.OperationsListResult] + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] @@ -59,30 +67,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -95,12 +100,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_operations.py index 773f494ca2ec..d7d1e8254598 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_public_maintenance_configurations_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._public_maintenance_configurations_operations import build_get_request, 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 @@ -50,8 +56,10 @@ def list( Get Public Maintenance Configuration records. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] + :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result + of cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListMaintenanceConfigurationsResult"] @@ -59,34 +67,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListMaintenanceConfigurationsResult', pipeline_response) + deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -99,17 +102,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations'} # type: ignore + @distributed_trace_async async def get( self, resource_name: str, @@ -131,32 +136,22 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -165,4 +160,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}'} # type: ignore + diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_operations.py index 069000ddeb4c..72cf9bd20be2 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_updates_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._updates_operations import build_list_parent_request, 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_parent( self, resource_group_name: str, @@ -69,7 +75,8 @@ def list_parent( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListUpdatesResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListUpdatesResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListUpdatesResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUpdatesResult"] @@ -77,40 +84,41 @@ def list_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list_parent.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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListUpdatesResult', pipeline_response) + deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -123,17 +131,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates'} # type: ignore + @distributed_trace def list( self, resource_group_name: str, @@ -156,7 +166,8 @@ def list( :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ListUpdatesResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListUpdatesResult] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListUpdatesResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUpdatesResult"] @@ -164,38 +175,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list.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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('ListUpdatesResult', pipeline_response) + deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -208,12 +218,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py index 80b417cf81b2..aafccb16a669 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/__init__.py @@ -6,46 +6,26 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ApplyUpdate - from ._models_py3 import ConfigurationAssignment - from ._models_py3 import ErrorDetails - from ._models_py3 import InputLinuxParameters - from ._models_py3 import InputPatchConfiguration - from ._models_py3 import InputWindowsParameters - from ._models_py3 import ListApplyUpdate - from ._models_py3 import ListConfigurationAssignmentsResult - from ._models_py3 import ListMaintenanceConfigurationsResult - from ._models_py3 import ListUpdatesResult - from ._models_py3 import MaintenanceConfiguration - from ._models_py3 import MaintenanceError - from ._models_py3 import Operation - from ._models_py3 import OperationInfo - from ._models_py3 import OperationsListResult - from ._models_py3 import Resource - from ._models_py3 import SystemData - from ._models_py3 import TaskProperties - from ._models_py3 import Update -except (SyntaxError, ImportError): - from ._models import ApplyUpdate # type: ignore - from ._models import ConfigurationAssignment # type: ignore - from ._models import ErrorDetails # type: ignore - from ._models import InputLinuxParameters # type: ignore - from ._models import InputPatchConfiguration # type: ignore - from ._models import InputWindowsParameters # type: ignore - from ._models import ListApplyUpdate # type: ignore - from ._models import ListConfigurationAssignmentsResult # type: ignore - from ._models import ListMaintenanceConfigurationsResult # type: ignore - from ._models import ListUpdatesResult # type: ignore - from ._models import MaintenanceConfiguration # type: ignore - from ._models import MaintenanceError # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationInfo # type: ignore - from ._models import OperationsListResult # type: ignore - from ._models import Resource # type: ignore - from ._models import SystemData # type: ignore - from ._models import TaskProperties # type: ignore - from ._models import Update # type: ignore +from ._models_py3 import ApplyUpdate +from ._models_py3 import ConfigurationAssignment +from ._models_py3 import ErrorDetails +from ._models_py3 import InputLinuxParameters +from ._models_py3 import InputPatchConfiguration +from ._models_py3 import InputWindowsParameters +from ._models_py3 import ListApplyUpdate +from ._models_py3 import ListConfigurationAssignmentsResult +from ._models_py3 import ListMaintenanceConfigurationsResult +from ._models_py3 import ListUpdatesResult +from ._models_py3 import MaintenanceConfiguration +from ._models_py3 import MaintenanceError +from ._models_py3 import Operation +from ._models_py3 import OperationInfo +from ._models_py3 import OperationsListResult +from ._models_py3 import Resource +from ._models_py3 import SystemData +from ._models_py3 import TaskProperties +from ._models_py3 import Update + from ._maintenance_management_client_enums import ( CreatedByType, diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_client_enums.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_client_enums.py index a3c6d553c252..3d50de23d52a 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_client_enums.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_maintenance_management_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 CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ @@ -35,7 +20,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ImpactType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ImpactType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The impact type """ @@ -48,7 +33,7 @@ class ImpactType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Pending updates can redeploy resource. REDEPLOY = "Redeploy" -class MaintenanceScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets maintenanceScope of the configuration """ @@ -66,7 +51,7 @@ class MaintenanceScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: This maintenance scope controls installation of SQL managed instance platform update. SQL_MANAGED_INSTANCE = "SQLManagedInstance" -class RebootOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class RebootOptions(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Possible reboot preference as defined by the user based on which it would be decided to reboot the machine or not after the patch operation is completed. """ @@ -75,14 +60,14 @@ class RebootOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NEVER = "Never" ALWAYS = "Always" -class TaskScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TaskScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Global Task execute once when schedule trigger. Resource task execute for each VM. """ GLOBAL_ENUM = "Global" RESOURCE = "Resource" -class UpdateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UpdateStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The status """ @@ -97,7 +82,7 @@ class UpdateStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Updates installation failed and should be retried later. RETRY_LATER = "RetryLater" -class Visibility(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Visibility(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Gets or sets the visibility of the configuration. The default value is 'Custom' """ diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models.py deleted file mode 100644 index 5cf192010dcc..000000000000 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models.py +++ /dev/null @@ -1,672 +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 Resource(msrest.serialization.Model): - """Definition of a Resource. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.maintenance.models.SystemData - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - self.system_data = None - - -class ApplyUpdate(Resource): - """Apply Update request. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.maintenance.models.SystemData - :param status: The status. Possible values include: "Pending", "InProgress", "Completed", - "RetryNow", "RetryLater". - :type status: str or ~azure.mgmt.maintenance.models.UpdateStatus - :param resource_id: The resourceId. - :type resource_id: str - :param last_update_time: Last Update time. - :type last_update_time: ~datetime.datetime - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'status': {'key': 'properties.status', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - 'last_update_time': {'key': 'properties.lastUpdateTime', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(ApplyUpdate, self).__init__(**kwargs) - self.status = kwargs.get('status', None) - self.resource_id = kwargs.get('resource_id', None) - self.last_update_time = kwargs.get('last_update_time', None) - - -class ConfigurationAssignment(Resource): - """Configuration Assignment. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.maintenance.models.SystemData - :param location: Location of the resource. - :type location: str - :param maintenance_configuration_id: The maintenance configuration Id. - :type maintenance_configuration_id: str - :param resource_id: The unique resourceId. - :type resource_id: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'maintenance_configuration_id': {'key': 'properties.maintenanceConfigurationId', 'type': 'str'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ConfigurationAssignment, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.maintenance_configuration_id = kwargs.get('maintenance_configuration_id', None) - self.resource_id = kwargs.get('resource_id', None) - - -class ErrorDetails(msrest.serialization.Model): - """An error response details received from the Azure Maintenance service. - - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error - code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str - """ - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetails, self).__init__(**kwargs) - self.code = kwargs.get('code', None) - self.message = kwargs.get('message', None) - - -class InputLinuxParameters(msrest.serialization.Model): - """Input properties for patching a Linux machine. - - :param package_name_masks_to_exclude: Package names to be excluded for patching. - :type package_name_masks_to_exclude: list[str] - :param package_name_masks_to_include: Package names to be included for patching. - :type package_name_masks_to_include: list[str] - :param classifications_to_include: Classification category of patches to be patched. - :type classifications_to_include: list[str] - """ - - _attribute_map = { - 'package_name_masks_to_exclude': {'key': 'packageNameMasksToExclude', 'type': '[str]'}, - 'package_name_masks_to_include': {'key': 'packageNameMasksToInclude', 'type': '[str]'}, - 'classifications_to_include': {'key': 'classificationsToInclude', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(InputLinuxParameters, self).__init__(**kwargs) - self.package_name_masks_to_exclude = kwargs.get('package_name_masks_to_exclude', None) - self.package_name_masks_to_include = kwargs.get('package_name_masks_to_include', None) - self.classifications_to_include = kwargs.get('classifications_to_include', None) - - -class InputPatchConfiguration(msrest.serialization.Model): - """Input configuration for a patch run. - - :param reboot_setting: Possible reboot preference as defined by the user based on which it - would be decided to reboot the machine or not after the patch operation is completed. Possible - values include: "IfRequired", "Never", "Always". Default value: "IfRequired". - :type reboot_setting: str or ~azure.mgmt.maintenance.models.RebootOptions - :param windows_parameters: Input parameters specific to patching a Windows machine. For Linux - machines, do not pass this property. - :type windows_parameters: ~azure.mgmt.maintenance.models.InputWindowsParameters - :param linux_parameters: Input parameters specific to patching Linux machine. For Windows - machines, do not pass this property. - :type linux_parameters: ~azure.mgmt.maintenance.models.InputLinuxParameters - :param pre_tasks: List of pre tasks. e.g. [{'source' :'runbook', 'taskScope': 'Global', - 'parameters': { 'arg1': 'value1'}}]. - :type pre_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] - :param post_tasks: List of post tasks. e.g. [{'source' :'runbook', 'taskScope': 'Resource', - 'parameters': { 'arg1': 'value1'}}]. - :type post_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] - """ - - _attribute_map = { - 'reboot_setting': {'key': 'rebootSetting', 'type': 'str'}, - 'windows_parameters': {'key': 'windowsParameters', 'type': 'InputWindowsParameters'}, - 'linux_parameters': {'key': 'linuxParameters', 'type': 'InputLinuxParameters'}, - 'pre_tasks': {'key': 'tasks.preTasks', 'type': '[TaskProperties]'}, - 'post_tasks': {'key': 'tasks.postTasks', 'type': '[TaskProperties]'}, - } - - def __init__( - self, - **kwargs - ): - super(InputPatchConfiguration, self).__init__(**kwargs) - self.reboot_setting = kwargs.get('reboot_setting', "IfRequired") - self.windows_parameters = kwargs.get('windows_parameters', None) - self.linux_parameters = kwargs.get('linux_parameters', None) - self.pre_tasks = kwargs.get('pre_tasks', None) - self.post_tasks = kwargs.get('post_tasks', None) - - -class InputWindowsParameters(msrest.serialization.Model): - """Input properties for patching a Windows machine. - - :param kb_numbers_to_exclude: Windows KBID to be excluded for patching. - :type kb_numbers_to_exclude: list[str] - :param kb_numbers_to_include: Windows KBID to be included for patching. - :type kb_numbers_to_include: list[str] - :param classifications_to_include: Classification category of patches to be patched. - :type classifications_to_include: list[str] - :param exclude_kbs_requiring_reboot: Exclude patches which need reboot. - :type exclude_kbs_requiring_reboot: bool - """ - - _attribute_map = { - 'kb_numbers_to_exclude': {'key': 'kbNumbersToExclude', 'type': '[str]'}, - 'kb_numbers_to_include': {'key': 'kbNumbersToInclude', 'type': '[str]'}, - 'classifications_to_include': {'key': 'classificationsToInclude', 'type': '[str]'}, - 'exclude_kbs_requiring_reboot': {'key': 'excludeKbsRequiringReboot', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(InputWindowsParameters, self).__init__(**kwargs) - self.kb_numbers_to_exclude = kwargs.get('kb_numbers_to_exclude', None) - self.kb_numbers_to_include = kwargs.get('kb_numbers_to_include', None) - self.classifications_to_include = kwargs.get('classifications_to_include', None) - self.exclude_kbs_requiring_reboot = kwargs.get('exclude_kbs_requiring_reboot', None) - - -class ListApplyUpdate(msrest.serialization.Model): - """Response for ApplyUpdate list. - - :param value: The list of apply updates. - :type value: list[~azure.mgmt.maintenance.models.ApplyUpdate] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ApplyUpdate]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListApplyUpdate, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ListConfigurationAssignmentsResult(msrest.serialization.Model): - """Response for ConfigurationAssignments list. - - :param value: The list of configuration Assignments. - :type value: list[~azure.mgmt.maintenance.models.ConfigurationAssignment] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ConfigurationAssignment]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListConfigurationAssignmentsResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ListMaintenanceConfigurationsResult(msrest.serialization.Model): - """Response for MaintenanceConfigurations list. - - :param value: The list of maintenance Configurations. - :type value: list[~azure.mgmt.maintenance.models.MaintenanceConfiguration] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[MaintenanceConfiguration]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListMaintenanceConfigurationsResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class ListUpdatesResult(msrest.serialization.Model): - """Response for Updates list. - - :param value: The pending updates. - :type value: list[~azure.mgmt.maintenance.models.Update] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Update]'}, - } - - def __init__( - self, - **kwargs - ): - super(ListUpdatesResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class MaintenanceConfiguration(Resource): - """Maintenance configuration record type. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified identifier of the resource. - :vartype id: str - :ivar name: Name of the resource. - :vartype name: str - :ivar type: Type of the resource. - :vartype type: str - :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy - information. - :vartype system_data: ~azure.mgmt.maintenance.models.SystemData - :param location: Gets or sets location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets tags of the resource. - :type tags: dict[str, str] - :param namespace: Gets or sets namespace of the resource. - :type namespace: str - :param extension_properties: Gets or sets extensionProperties of the maintenanceConfiguration. - :type extension_properties: dict[str, str] - :param maintenance_scope: Gets or sets maintenanceScope of the configuration. Possible values - include: "Host", "OSImage", "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". - :type maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope - :param visibility: Gets or sets the visibility of the configuration. The default value is - 'Custom'. Possible values include: "Custom", "Public". - :type visibility: str or ~azure.mgmt.maintenance.models.Visibility - :param install_patches: The input parameters to be passed to the patch run operation. - :type install_patches: ~azure.mgmt.maintenance.models.InputPatchConfiguration - :param start_date_time: Effective start date of the maintenance window in YYYY-MM-DD hh:mm - format. The start date can be set to either the current date or future date. The window will be - created in the time zone provided and adjusted to daylight savings according to that time zone. - :type start_date_time: str - :param expiration_date_time: Effective expiration date of the maintenance window in YYYY-MM-DD - hh:mm format. The window will be created in the time zone provided and adjusted to daylight - savings according to that time zone. Expiration date must be set to a future date. If not - provided, it will be set to the maximum datetime 9999-12-31 23:59:59. - :type expiration_date_time: str - :param duration: Duration of the maintenance window in HH:mm format. If not provided, default - value will be used based on maintenance scope provided. Example: 05:00. - :type duration: str - :param time_zone: Name of the timezone. List of timezones can be obtained by executing - [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. Example: Pacific Standard Time, UTC, - W. Europe Standard Time, Korea Standard Time, Cen. Australia Standard Time. - :type time_zone: str - :param recur_every: Rate at which a Maintenance window is expected to recur. The rate can be - expressed as daily, weekly, or monthly schedules. Daily schedule are formatted as recurEvery: - [Frequency as integer]['Day(s)']. If no frequency is provided, the default frequency is 1. - Daily schedule examples are recurEvery: Day, recurEvery: 3Days. Weekly schedule are formatted - as recurEvery: [Frequency as integer]['Week(s)'] [Optional comma separated list of weekdays - Monday-Sunday]. Weekly schedule examples are recurEvery: 3Weeks, recurEvery: Week - Saturday,Sunday. Monthly schedules are formatted as [Frequency as integer]['Month(s)'] [Comma - separated list of month days] or [Frequency as integer]['Month(s)'] [Week of Month (First, - Second, Third, Fourth, Last)] [Weekday Monday-Sunday] [Optional Offset(No. of days)]. Offset - value must be between -6 to 6 inclusive. Monthly schedule examples are recurEvery: Month, - recurEvery: 2Months, recurEvery: Month day23,day24, recurEvery: Month Last Sunday, recurEvery: - Month Fourth Monday, recurEvery: Month Last Sunday Offset-3, recurEvery: Month Third Sunday - Offset6. - :type recur_every: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'system_data': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'location': {'key': 'location', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'namespace': {'key': 'properties.namespace', 'type': 'str'}, - 'extension_properties': {'key': 'properties.extensionProperties', 'type': '{str}'}, - 'maintenance_scope': {'key': 'properties.maintenanceScope', 'type': 'str'}, - 'visibility': {'key': 'properties.visibility', 'type': 'str'}, - 'install_patches': {'key': 'properties.installPatches', 'type': 'InputPatchConfiguration'}, - 'start_date_time': {'key': 'properties.maintenanceWindow.startDateTime', 'type': 'str'}, - 'expiration_date_time': {'key': 'properties.maintenanceWindow.expirationDateTime', 'type': 'str'}, - 'duration': {'key': 'properties.maintenanceWindow.duration', 'type': 'str'}, - 'time_zone': {'key': 'properties.maintenanceWindow.timeZone', 'type': 'str'}, - 'recur_every': {'key': 'properties.maintenanceWindow.recurEvery', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(MaintenanceConfiguration, self).__init__(**kwargs) - self.location = kwargs.get('location', None) - self.tags = kwargs.get('tags', None) - self.namespace = kwargs.get('namespace', None) - self.extension_properties = kwargs.get('extension_properties', None) - self.maintenance_scope = kwargs.get('maintenance_scope', None) - self.visibility = kwargs.get('visibility', None) - self.install_patches = kwargs.get('install_patches', None) - self.start_date_time = kwargs.get('start_date_time', None) - self.expiration_date_time = kwargs.get('expiration_date_time', None) - self.duration = kwargs.get('duration', None) - self.time_zone = kwargs.get('time_zone', None) - self.recur_every = kwargs.get('recur_every', None) - - -class MaintenanceError(msrest.serialization.Model): - """An error response received from the Azure Maintenance service. - - :param error: Details of the error. - :type error: ~azure.mgmt.maintenance.models.ErrorDetails - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetails'}, - } - - def __init__( - self, - **kwargs - ): - super(MaintenanceError, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class Operation(msrest.serialization.Model): - """Represents an operation returned by the GetOperations request. - - :param name: Name of the operation. - :type name: str - :param display: Display name of the operation. - :type display: ~azure.mgmt.maintenance.models.OperationInfo - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: any - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationInfo'}, - 'origin': {'key': 'origin', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'object'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - self.origin = kwargs.get('origin', None) - self.properties = kwargs.get('properties', None) - self.is_data_action = kwargs.get('is_data_action', None) - - -class OperationInfo(msrest.serialization.Model): - """Information about an operation. - - :param provider: Name of the provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the operation. - :type operation: str - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationInfo, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsListResult(msrest.serialization.Model): - """Result of the List Operations operation. - - :param value: A collection of operations. - :type value: list[~azure.mgmt.maintenance.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.maintenance.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~azure.mgmt.maintenance.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type 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, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class TaskProperties(msrest.serialization.Model): - """Task properties of the software update configuration. - - :param parameters: Gets or sets the parameters of the task. - :type parameters: dict[str, str] - :param source: Gets or sets the name of the runbook. - :type source: str - :param task_scope: Global Task execute once when schedule trigger. Resource task execute for - each VM. Possible values include: "Global", "Resource". Default value: "Global". - :type task_scope: str or ~azure.mgmt.maintenance.models.TaskScope - """ - - _attribute_map = { - 'parameters': {'key': 'parameters', 'type': '{str}'}, - 'source': {'key': 'source', 'type': 'str'}, - 'task_scope': {'key': 'taskScope', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TaskProperties, self).__init__(**kwargs) - self.parameters = kwargs.get('parameters', None) - self.source = kwargs.get('source', None) - self.task_scope = kwargs.get('task_scope', "Global") - - -class Update(msrest.serialization.Model): - """Maintenance update on a resource. - - :param maintenance_scope: The impact area. Possible values include: "Host", "OSImage", - "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". - :type maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope - :param impact_type: The impact type. Possible values include: "None", "Freeze", "Restart", - "Redeploy". - :type impact_type: str or ~azure.mgmt.maintenance.models.ImpactType - :param status: The status. Possible values include: "Pending", "InProgress", "Completed", - "RetryNow", "RetryLater". - :type status: str or ~azure.mgmt.maintenance.models.UpdateStatus - :param impact_duration_in_sec: Duration of impact in seconds. - :type impact_duration_in_sec: int - :param not_before: Time when Azure will start force updates if not self-updated by customer - before this time. - :type not_before: ~datetime.datetime - :param resource_id: The resourceId. - :type resource_id: str - """ - - _attribute_map = { - 'maintenance_scope': {'key': 'maintenanceScope', 'type': 'str'}, - 'impact_type': {'key': 'impactType', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'str'}, - 'impact_duration_in_sec': {'key': 'impactDurationInSec', 'type': 'int'}, - 'not_before': {'key': 'notBefore', 'type': 'iso-8601'}, - 'resource_id': {'key': 'properties.resourceId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Update, self).__init__(**kwargs) - self.maintenance_scope = kwargs.get('maintenance_scope', None) - self.impact_type = kwargs.get('impact_type', None) - self.status = kwargs.get('status', None) - self.impact_duration_in_sec = kwargs.get('impact_duration_in_sec', None) - self.not_before = kwargs.get('not_before', None) - self.resource_id = kwargs.get('resource_id', None) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py index 3e8d4b41f138..1280f30e8dec 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models_py3.py @@ -49,6 +49,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -70,13 +72,13 @@ class ApplyUpdate(Resource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.maintenance.models.SystemData - :param status: The status. Possible values include: "Pending", "InProgress", "Completed", + :ivar status: The status. Possible values include: "Pending", "InProgress", "Completed", "RetryNow", "RetryLater". - :type status: str or ~azure.mgmt.maintenance.models.UpdateStatus - :param resource_id: The resourceId. - :type resource_id: str - :param last_update_time: Last Update time. - :type last_update_time: ~datetime.datetime + :vartype status: str or ~azure.mgmt.maintenance.models.UpdateStatus + :ivar resource_id: The resourceId. + :vartype resource_id: str + :ivar last_update_time: Last Update time. + :vartype last_update_time: ~datetime.datetime """ _validation = { @@ -104,6 +106,15 @@ def __init__( last_update_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword status: The status. Possible values include: "Pending", "InProgress", "Completed", + "RetryNow", "RetryLater". + :paramtype status: str or ~azure.mgmt.maintenance.models.UpdateStatus + :keyword resource_id: The resourceId. + :paramtype resource_id: str + :keyword last_update_time: Last Update time. + :paramtype last_update_time: ~datetime.datetime + """ super(ApplyUpdate, self).__init__(**kwargs) self.status = status self.resource_id = resource_id @@ -124,12 +135,12 @@ class ConfigurationAssignment(Resource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.maintenance.models.SystemData - :param location: Location of the resource. - :type location: str - :param maintenance_configuration_id: The maintenance configuration Id. - :type maintenance_configuration_id: str - :param resource_id: The unique resourceId. - :type resource_id: str + :ivar location: Location of the resource. + :vartype location: str + :ivar maintenance_configuration_id: The maintenance configuration Id. + :vartype maintenance_configuration_id: str + :ivar resource_id: The unique resourceId. + :vartype resource_id: str """ _validation = { @@ -157,6 +168,14 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword location: Location of the resource. + :paramtype location: str + :keyword maintenance_configuration_id: The maintenance configuration Id. + :paramtype maintenance_configuration_id: str + :keyword resource_id: The unique resourceId. + :paramtype resource_id: str + """ super(ConfigurationAssignment, self).__init__(**kwargs) self.location = location self.maintenance_configuration_id = maintenance_configuration_id @@ -166,11 +185,11 @@ def __init__( class ErrorDetails(msrest.serialization.Model): """An error response details received from the Azure Maintenance service. - :param code: Service-defined error code. This code serves as a sub-status for the HTTP error + :ivar code: Service-defined error code. This code serves as a sub-status for the HTTP error code specified in the response. - :type code: str - :param message: Human-readable representation of the error. - :type message: str + :vartype code: str + :ivar message: Human-readable representation of the error. + :vartype message: str """ _attribute_map = { @@ -185,6 +204,13 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: Service-defined error code. This code serves as a sub-status for the HTTP error + code specified in the response. + :paramtype code: str + :keyword message: Human-readable representation of the error. + :paramtype message: str + """ super(ErrorDetails, self).__init__(**kwargs) self.code = code self.message = message @@ -193,12 +219,12 @@ def __init__( class InputLinuxParameters(msrest.serialization.Model): """Input properties for patching a Linux machine. - :param package_name_masks_to_exclude: Package names to be excluded for patching. - :type package_name_masks_to_exclude: list[str] - :param package_name_masks_to_include: Package names to be included for patching. - :type package_name_masks_to_include: list[str] - :param classifications_to_include: Classification category of patches to be patched. - :type classifications_to_include: list[str] + :ivar package_name_masks_to_exclude: Package names to be excluded for patching. + :vartype package_name_masks_to_exclude: list[str] + :ivar package_name_masks_to_include: Package names to be included for patching. + :vartype package_name_masks_to_include: list[str] + :ivar classifications_to_include: Classification category of patches to be patched. + :vartype classifications_to_include: list[str] """ _attribute_map = { @@ -215,6 +241,14 @@ def __init__( classifications_to_include: Optional[List[str]] = None, **kwargs ): + """ + :keyword package_name_masks_to_exclude: Package names to be excluded for patching. + :paramtype package_name_masks_to_exclude: list[str] + :keyword package_name_masks_to_include: Package names to be included for patching. + :paramtype package_name_masks_to_include: list[str] + :keyword classifications_to_include: Classification category of patches to be patched. + :paramtype classifications_to_include: list[str] + """ super(InputLinuxParameters, self).__init__(**kwargs) self.package_name_masks_to_exclude = package_name_masks_to_exclude self.package_name_masks_to_include = package_name_masks_to_include @@ -224,22 +258,22 @@ def __init__( class InputPatchConfiguration(msrest.serialization.Model): """Input configuration for a patch run. - :param reboot_setting: Possible reboot preference as defined by the user based on which it - would be decided to reboot the machine or not after the patch operation is completed. Possible - values include: "IfRequired", "Never", "Always". Default value: "IfRequired". - :type reboot_setting: str or ~azure.mgmt.maintenance.models.RebootOptions - :param windows_parameters: Input parameters specific to patching a Windows machine. For Linux + :ivar reboot_setting: Possible reboot preference as defined by the user based on which it would + be decided to reboot the machine or not after the patch operation is completed. Possible values + include: "IfRequired", "Never", "Always". Default value: "IfRequired". + :vartype reboot_setting: str or ~azure.mgmt.maintenance.models.RebootOptions + :ivar windows_parameters: Input parameters specific to patching a Windows machine. For Linux machines, do not pass this property. - :type windows_parameters: ~azure.mgmt.maintenance.models.InputWindowsParameters - :param linux_parameters: Input parameters specific to patching Linux machine. For Windows + :vartype windows_parameters: ~azure.mgmt.maintenance.models.InputWindowsParameters + :ivar linux_parameters: Input parameters specific to patching Linux machine. For Windows machines, do not pass this property. - :type linux_parameters: ~azure.mgmt.maintenance.models.InputLinuxParameters - :param pre_tasks: List of pre tasks. e.g. [{'source' :'runbook', 'taskScope': 'Global', + :vartype linux_parameters: ~azure.mgmt.maintenance.models.InputLinuxParameters + :ivar pre_tasks: List of pre tasks. e.g. [{'source' :'runbook', 'taskScope': 'Global', 'parameters': { 'arg1': 'value1'}}]. - :type pre_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] - :param post_tasks: List of post tasks. e.g. [{'source' :'runbook', 'taskScope': 'Resource', + :vartype pre_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] + :ivar post_tasks: List of post tasks. e.g. [{'source' :'runbook', 'taskScope': 'Resource', 'parameters': { 'arg1': 'value1'}}]. - :type post_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] + :vartype post_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] """ _attribute_map = { @@ -260,6 +294,24 @@ def __init__( post_tasks: Optional[List["TaskProperties"]] = None, **kwargs ): + """ + :keyword reboot_setting: Possible reboot preference as defined by the user based on which it + would be decided to reboot the machine or not after the patch operation is completed. Possible + values include: "IfRequired", "Never", "Always". Default value: "IfRequired". + :paramtype reboot_setting: str or ~azure.mgmt.maintenance.models.RebootOptions + :keyword windows_parameters: Input parameters specific to patching a Windows machine. For Linux + machines, do not pass this property. + :paramtype windows_parameters: ~azure.mgmt.maintenance.models.InputWindowsParameters + :keyword linux_parameters: Input parameters specific to patching Linux machine. For Windows + machines, do not pass this property. + :paramtype linux_parameters: ~azure.mgmt.maintenance.models.InputLinuxParameters + :keyword pre_tasks: List of pre tasks. e.g. [{'source' :'runbook', 'taskScope': 'Global', + 'parameters': { 'arg1': 'value1'}}]. + :paramtype pre_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] + :keyword post_tasks: List of post tasks. e.g. [{'source' :'runbook', 'taskScope': 'Resource', + 'parameters': { 'arg1': 'value1'}}]. + :paramtype post_tasks: list[~azure.mgmt.maintenance.models.TaskProperties] + """ super(InputPatchConfiguration, self).__init__(**kwargs) self.reboot_setting = reboot_setting self.windows_parameters = windows_parameters @@ -271,14 +323,14 @@ def __init__( class InputWindowsParameters(msrest.serialization.Model): """Input properties for patching a Windows machine. - :param kb_numbers_to_exclude: Windows KBID to be excluded for patching. - :type kb_numbers_to_exclude: list[str] - :param kb_numbers_to_include: Windows KBID to be included for patching. - :type kb_numbers_to_include: list[str] - :param classifications_to_include: Classification category of patches to be patched. - :type classifications_to_include: list[str] - :param exclude_kbs_requiring_reboot: Exclude patches which need reboot. - :type exclude_kbs_requiring_reboot: bool + :ivar kb_numbers_to_exclude: Windows KBID to be excluded for patching. + :vartype kb_numbers_to_exclude: list[str] + :ivar kb_numbers_to_include: Windows KBID to be included for patching. + :vartype kb_numbers_to_include: list[str] + :ivar classifications_to_include: Classification category of patches to be patched. + :vartype classifications_to_include: list[str] + :ivar exclude_kbs_requiring_reboot: Exclude patches which need reboot. + :vartype exclude_kbs_requiring_reboot: bool """ _attribute_map = { @@ -297,6 +349,16 @@ def __init__( exclude_kbs_requiring_reboot: Optional[bool] = None, **kwargs ): + """ + :keyword kb_numbers_to_exclude: Windows KBID to be excluded for patching. + :paramtype kb_numbers_to_exclude: list[str] + :keyword kb_numbers_to_include: Windows KBID to be included for patching. + :paramtype kb_numbers_to_include: list[str] + :keyword classifications_to_include: Classification category of patches to be patched. + :paramtype classifications_to_include: list[str] + :keyword exclude_kbs_requiring_reboot: Exclude patches which need reboot. + :paramtype exclude_kbs_requiring_reboot: bool + """ super(InputWindowsParameters, self).__init__(**kwargs) self.kb_numbers_to_exclude = kb_numbers_to_exclude self.kb_numbers_to_include = kb_numbers_to_include @@ -307,8 +369,8 @@ def __init__( class ListApplyUpdate(msrest.serialization.Model): """Response for ApplyUpdate list. - :param value: The list of apply updates. - :type value: list[~azure.mgmt.maintenance.models.ApplyUpdate] + :ivar value: The list of apply updates. + :vartype value: list[~azure.mgmt.maintenance.models.ApplyUpdate] """ _attribute_map = { @@ -321,6 +383,10 @@ def __init__( value: Optional[List["ApplyUpdate"]] = None, **kwargs ): + """ + :keyword value: The list of apply updates. + :paramtype value: list[~azure.mgmt.maintenance.models.ApplyUpdate] + """ super(ListApplyUpdate, self).__init__(**kwargs) self.value = value @@ -328,8 +394,8 @@ def __init__( class ListConfigurationAssignmentsResult(msrest.serialization.Model): """Response for ConfigurationAssignments list. - :param value: The list of configuration Assignments. - :type value: list[~azure.mgmt.maintenance.models.ConfigurationAssignment] + :ivar value: The list of configuration Assignments. + :vartype value: list[~azure.mgmt.maintenance.models.ConfigurationAssignment] """ _attribute_map = { @@ -342,6 +408,10 @@ def __init__( value: Optional[List["ConfigurationAssignment"]] = None, **kwargs ): + """ + :keyword value: The list of configuration Assignments. + :paramtype value: list[~azure.mgmt.maintenance.models.ConfigurationAssignment] + """ super(ListConfigurationAssignmentsResult, self).__init__(**kwargs) self.value = value @@ -349,8 +419,8 @@ def __init__( class ListMaintenanceConfigurationsResult(msrest.serialization.Model): """Response for MaintenanceConfigurations list. - :param value: The list of maintenance Configurations. - :type value: list[~azure.mgmt.maintenance.models.MaintenanceConfiguration] + :ivar value: The list of maintenance Configurations. + :vartype value: list[~azure.mgmt.maintenance.models.MaintenanceConfiguration] """ _attribute_map = { @@ -363,6 +433,10 @@ def __init__( value: Optional[List["MaintenanceConfiguration"]] = None, **kwargs ): + """ + :keyword value: The list of maintenance Configurations. + :paramtype value: list[~azure.mgmt.maintenance.models.MaintenanceConfiguration] + """ super(ListMaintenanceConfigurationsResult, self).__init__(**kwargs) self.value = value @@ -370,8 +444,8 @@ def __init__( class ListUpdatesResult(msrest.serialization.Model): """Response for Updates list. - :param value: The pending updates. - :type value: list[~azure.mgmt.maintenance.models.Update] + :ivar value: The pending updates. + :vartype value: list[~azure.mgmt.maintenance.models.Update] """ _attribute_map = { @@ -384,6 +458,10 @@ def __init__( value: Optional[List["Update"]] = None, **kwargs ): + """ + :keyword value: The pending updates. + :paramtype value: list[~azure.mgmt.maintenance.models.Update] + """ super(ListUpdatesResult, self).__init__(**kwargs) self.value = value @@ -402,39 +480,39 @@ class MaintenanceConfiguration(Resource): :ivar system_data: Azure Resource Manager metadata containing createdBy and modifiedBy information. :vartype system_data: ~azure.mgmt.maintenance.models.SystemData - :param location: Gets or sets location of the resource. - :type location: str - :param tags: A set of tags. Gets or sets tags of the resource. - :type tags: dict[str, str] - :param namespace: Gets or sets namespace of the resource. - :type namespace: str - :param extension_properties: Gets or sets extensionProperties of the maintenanceConfiguration. - :type extension_properties: dict[str, str] - :param maintenance_scope: Gets or sets maintenanceScope of the configuration. Possible values + :ivar location: Gets or sets location of the resource. + :vartype location: str + :ivar tags: A set of tags. Gets or sets tags of the resource. + :vartype tags: dict[str, str] + :ivar namespace: Gets or sets namespace of the resource. + :vartype namespace: str + :ivar extension_properties: Gets or sets extensionProperties of the maintenanceConfiguration. + :vartype extension_properties: dict[str, str] + :ivar maintenance_scope: Gets or sets maintenanceScope of the configuration. Possible values include: "Host", "OSImage", "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". - :type maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope - :param visibility: Gets or sets the visibility of the configuration. The default value is + :vartype maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope + :ivar visibility: Gets or sets the visibility of the configuration. The default value is 'Custom'. Possible values include: "Custom", "Public". - :type visibility: str or ~azure.mgmt.maintenance.models.Visibility - :param install_patches: The input parameters to be passed to the patch run operation. - :type install_patches: ~azure.mgmt.maintenance.models.InputPatchConfiguration - :param start_date_time: Effective start date of the maintenance window in YYYY-MM-DD hh:mm + :vartype visibility: str or ~azure.mgmt.maintenance.models.Visibility + :ivar install_patches: The input parameters to be passed to the patch run operation. + :vartype install_patches: ~azure.mgmt.maintenance.models.InputPatchConfiguration + :ivar start_date_time: Effective start date of the maintenance window in YYYY-MM-DD hh:mm format. The start date can be set to either the current date or future date. The window will be created in the time zone provided and adjusted to daylight savings according to that time zone. - :type start_date_time: str - :param expiration_date_time: Effective expiration date of the maintenance window in YYYY-MM-DD + :vartype start_date_time: str + :ivar expiration_date_time: Effective expiration date of the maintenance window in YYYY-MM-DD hh:mm format. The window will be created in the time zone provided and adjusted to daylight savings according to that time zone. Expiration date must be set to a future date. If not provided, it will be set to the maximum datetime 9999-12-31 23:59:59. - :type expiration_date_time: str - :param duration: Duration of the maintenance window in HH:mm format. If not provided, default + :vartype expiration_date_time: str + :ivar duration: Duration of the maintenance window in HH:mm format. If not provided, default value will be used based on maintenance scope provided. Example: 05:00. - :type duration: str - :param time_zone: Name of the timezone. List of timezones can be obtained by executing + :vartype duration: str + :ivar time_zone: Name of the timezone. List of timezones can be obtained by executing [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. Example: Pacific Standard Time, UTC, W. Europe Standard Time, Korea Standard Time, Cen. Australia Standard Time. - :type time_zone: str - :param recur_every: Rate at which a Maintenance window is expected to recur. The rate can be + :vartype time_zone: str + :ivar recur_every: Rate at which a Maintenance window is expected to recur. The rate can be expressed as daily, weekly, or monthly schedules. Daily schedule are formatted as recurEvery: [Frequency as integer]['Day(s)']. If no frequency is provided, the default frequency is 1. Daily schedule examples are recurEvery: Day, recurEvery: 3Days. Weekly schedule are formatted @@ -447,7 +525,7 @@ class MaintenanceConfiguration(Resource): recurEvery: 2Months, recurEvery: Month day23,day24, recurEvery: Month Last Sunday, recurEvery: Month Fourth Monday, recurEvery: Month Last Sunday Offset-3, recurEvery: Month Third Sunday Offset6. - :type recur_every: str + :vartype recur_every: str """ _validation = { @@ -493,6 +571,55 @@ def __init__( recur_every: Optional[str] = None, **kwargs ): + """ + :keyword location: Gets or sets location of the resource. + :paramtype location: str + :keyword tags: A set of tags. Gets or sets tags of the resource. + :paramtype tags: dict[str, str] + :keyword namespace: Gets or sets namespace of the resource. + :paramtype namespace: str + :keyword extension_properties: Gets or sets extensionProperties of the + maintenanceConfiguration. + :paramtype extension_properties: dict[str, str] + :keyword maintenance_scope: Gets or sets maintenanceScope of the configuration. Possible values + include: "Host", "OSImage", "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". + :paramtype maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope + :keyword visibility: Gets or sets the visibility of the configuration. The default value is + 'Custom'. Possible values include: "Custom", "Public". + :paramtype visibility: str or ~azure.mgmt.maintenance.models.Visibility + :keyword install_patches: The input parameters to be passed to the patch run operation. + :paramtype install_patches: ~azure.mgmt.maintenance.models.InputPatchConfiguration + :keyword start_date_time: Effective start date of the maintenance window in YYYY-MM-DD hh:mm + format. The start date can be set to either the current date or future date. The window will be + created in the time zone provided and adjusted to daylight savings according to that time zone. + :paramtype start_date_time: str + :keyword expiration_date_time: Effective expiration date of the maintenance window in + YYYY-MM-DD hh:mm format. The window will be created in the time zone provided and adjusted to + daylight savings according to that time zone. Expiration date must be set to a future date. If + not provided, it will be set to the maximum datetime 9999-12-31 23:59:59. + :paramtype expiration_date_time: str + :keyword duration: Duration of the maintenance window in HH:mm format. If not provided, default + value will be used based on maintenance scope provided. Example: 05:00. + :paramtype duration: str + :keyword time_zone: Name of the timezone. List of timezones can be obtained by executing + [System.TimeZoneInfo]::GetSystemTimeZones() in PowerShell. Example: Pacific Standard Time, UTC, + W. Europe Standard Time, Korea Standard Time, Cen. Australia Standard Time. + :paramtype time_zone: str + :keyword recur_every: Rate at which a Maintenance window is expected to recur. The rate can be + expressed as daily, weekly, or monthly schedules. Daily schedule are formatted as recurEvery: + [Frequency as integer]['Day(s)']. If no frequency is provided, the default frequency is 1. + Daily schedule examples are recurEvery: Day, recurEvery: 3Days. Weekly schedule are formatted + as recurEvery: [Frequency as integer]['Week(s)'] [Optional comma separated list of weekdays + Monday-Sunday]. Weekly schedule examples are recurEvery: 3Weeks, recurEvery: Week + Saturday,Sunday. Monthly schedules are formatted as [Frequency as integer]['Month(s)'] [Comma + separated list of month days] or [Frequency as integer]['Month(s)'] [Week of Month (First, + Second, Third, Fourth, Last)] [Weekday Monday-Sunday] [Optional Offset(No. of days)]. Offset + value must be between -6 to 6 inclusive. Monthly schedule examples are recurEvery: Month, + recurEvery: 2Months, recurEvery: Month day23,day24, recurEvery: Month Last Sunday, recurEvery: + Month Fourth Monday, recurEvery: Month Last Sunday Offset-3, recurEvery: Month Third Sunday + Offset6. + :paramtype recur_every: str + """ super(MaintenanceConfiguration, self).__init__(**kwargs) self.location = location self.tags = tags @@ -511,8 +638,8 @@ def __init__( class MaintenanceError(msrest.serialization.Model): """An error response received from the Azure Maintenance service. - :param error: Details of the error. - :type error: ~azure.mgmt.maintenance.models.ErrorDetails + :ivar error: Details of the error. + :vartype error: ~azure.mgmt.maintenance.models.ErrorDetails """ _attribute_map = { @@ -525,6 +652,10 @@ def __init__( error: Optional["ErrorDetails"] = None, **kwargs ): + """ + :keyword error: Details of the error. + :paramtype error: ~azure.mgmt.maintenance.models.ErrorDetails + """ super(MaintenanceError, self).__init__(**kwargs) self.error = error @@ -532,16 +663,16 @@ def __init__( class Operation(msrest.serialization.Model): """Represents an operation returned by the GetOperations request. - :param name: Name of the operation. - :type name: str - :param display: Display name of the operation. - :type display: ~azure.mgmt.maintenance.models.OperationInfo - :param origin: Origin of the operation. - :type origin: str - :param properties: Properties of the operation. - :type properties: any - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Display name of the operation. + :vartype display: ~azure.mgmt.maintenance.models.OperationInfo + :ivar origin: Origin of the operation. + :vartype origin: str + :ivar properties: Properties of the operation. + :vartype properties: any + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool """ _attribute_map = { @@ -562,6 +693,18 @@ def __init__( is_data_action: Optional[bool] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Display name of the operation. + :paramtype display: ~azure.mgmt.maintenance.models.OperationInfo + :keyword origin: Origin of the operation. + :paramtype origin: str + :keyword properties: Properties of the operation. + :paramtype properties: any + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -573,14 +716,14 @@ def __init__( class OperationInfo(msrest.serialization.Model): """Information about an operation. - :param provider: Name of the provider. - :type provider: str - :param resource: Name of the resource type. - :type resource: str - :param operation: Name of the operation. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Name of the provider. + :vartype provider: str + :ivar resource: Name of the resource type. + :vartype resource: str + :ivar operation: Name of the operation. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -599,6 +742,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Name of the provider. + :paramtype provider: str + :keyword resource: Name of the resource type. + :paramtype resource: str + :keyword operation: Name of the operation. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationInfo, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -609,8 +762,8 @@ def __init__( class OperationsListResult(msrest.serialization.Model): """Result of the List Operations operation. - :param value: A collection of operations. - :type value: list[~azure.mgmt.maintenance.models.Operation] + :ivar value: A collection of operations. + :vartype value: list[~azure.mgmt.maintenance.models.Operation] """ _attribute_map = { @@ -623,6 +776,10 @@ def __init__( value: Optional[List["Operation"]] = None, **kwargs ): + """ + :keyword value: A collection of operations. + :paramtype value: list[~azure.mgmt.maintenance.models.Operation] + """ super(OperationsListResult, self).__init__(**kwargs) self.value = value @@ -630,20 +787,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~azure.mgmt.maintenance.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :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.maintenance.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". - :type last_modified_by_type: str or ~azure.mgmt.maintenance.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~azure.mgmt.maintenance.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -666,6 +823,22 @@ def __init__( 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.maintenance.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.maintenance.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 @@ -678,13 +851,13 @@ def __init__( class TaskProperties(msrest.serialization.Model): """Task properties of the software update configuration. - :param parameters: Gets or sets the parameters of the task. - :type parameters: dict[str, str] - :param source: Gets or sets the name of the runbook. - :type source: str - :param task_scope: Global Task execute once when schedule trigger. Resource task execute for + :ivar parameters: Gets or sets the parameters of the task. + :vartype parameters: dict[str, str] + :ivar source: Gets or sets the name of the runbook. + :vartype source: str + :ivar task_scope: Global Task execute once when schedule trigger. Resource task execute for each VM. Possible values include: "Global", "Resource". Default value: "Global". - :type task_scope: str or ~azure.mgmt.maintenance.models.TaskScope + :vartype task_scope: str or ~azure.mgmt.maintenance.models.TaskScope """ _attribute_map = { @@ -701,6 +874,15 @@ def __init__( task_scope: Optional[Union[str, "TaskScope"]] = "Global", **kwargs ): + """ + :keyword parameters: Gets or sets the parameters of the task. + :paramtype parameters: dict[str, str] + :keyword source: Gets or sets the name of the runbook. + :paramtype source: str + :keyword task_scope: Global Task execute once when schedule trigger. Resource task execute for + each VM. Possible values include: "Global", "Resource". Default value: "Global". + :paramtype task_scope: str or ~azure.mgmt.maintenance.models.TaskScope + """ super(TaskProperties, self).__init__(**kwargs) self.parameters = parameters self.source = source @@ -710,22 +892,22 @@ def __init__( class Update(msrest.serialization.Model): """Maintenance update on a resource. - :param maintenance_scope: The impact area. Possible values include: "Host", "OSImage", + :ivar maintenance_scope: The impact area. Possible values include: "Host", "OSImage", "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". - :type maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope - :param impact_type: The impact type. Possible values include: "None", "Freeze", "Restart", + :vartype maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope + :ivar impact_type: The impact type. Possible values include: "None", "Freeze", "Restart", "Redeploy". - :type impact_type: str or ~azure.mgmt.maintenance.models.ImpactType - :param status: The status. Possible values include: "Pending", "InProgress", "Completed", + :vartype impact_type: str or ~azure.mgmt.maintenance.models.ImpactType + :ivar status: The status. Possible values include: "Pending", "InProgress", "Completed", "RetryNow", "RetryLater". - :type status: str or ~azure.mgmt.maintenance.models.UpdateStatus - :param impact_duration_in_sec: Duration of impact in seconds. - :type impact_duration_in_sec: int - :param not_before: Time when Azure will start force updates if not self-updated by customer + :vartype status: str or ~azure.mgmt.maintenance.models.UpdateStatus + :ivar impact_duration_in_sec: Duration of impact in seconds. + :vartype impact_duration_in_sec: int + :ivar not_before: Time when Azure will start force updates if not self-updated by customer before this time. - :type not_before: ~datetime.datetime - :param resource_id: The resourceId. - :type resource_id: str + :vartype not_before: ~datetime.datetime + :ivar resource_id: The resourceId. + :vartype resource_id: str """ _attribute_map = { @@ -748,6 +930,24 @@ def __init__( resource_id: Optional[str] = None, **kwargs ): + """ + :keyword maintenance_scope: The impact area. Possible values include: "Host", "OSImage", + "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". + :paramtype maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope + :keyword impact_type: The impact type. Possible values include: "None", "Freeze", "Restart", + "Redeploy". + :paramtype impact_type: str or ~azure.mgmt.maintenance.models.ImpactType + :keyword status: The status. Possible values include: "Pending", "InProgress", "Completed", + "RetryNow", "RetryLater". + :paramtype status: str or ~azure.mgmt.maintenance.models.UpdateStatus + :keyword impact_duration_in_sec: Duration of impact in seconds. + :paramtype impact_duration_in_sec: int + :keyword not_before: Time when Azure will start force updates if not self-updated by customer + before this time. + :paramtype not_before: ~datetime.datetime + :keyword resource_id: The resourceId. + :paramtype resource_id: str + """ super(Update, self).__init__(**kwargs) self.maintenance_scope = maintenance_scope self.impact_type = impact_type diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py index 55b8fe73a94c..3bd27f6f01cb 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_update_for_resource_group_operations.py @@ -5,23 +5,58 @@ # 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates') + 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 + ) class ApplyUpdateForResourceGroupOperations(object): """ApplyUpdateForResourceGroupOperations operations. @@ -45,12 +80,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListApplyUpdate"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ListApplyUpdate"]: """Get Configuration records within a subscription and resource group. Get Configuration records within a subscription and resource group. @@ -67,35 +102,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - '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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.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_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('ListApplyUpdate', pipeline_response) + deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,12 +139,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py index d56ffb0730f6..8fd9068daa95 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_apply_updates_operations.py @@ -5,23 +5,224 @@ # 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_parent_request( + subscription_id: str, + resource_group_name: str, + resource_parent_type: str, + resource_parent_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + apply_update_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, 'str'), + "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "applyUpdateName": _SERIALIZER.url("apply_update_name", apply_update_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + apply_update_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "applyUpdateName": _SERIALIZER.url("apply_update_name", apply_update_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_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_parent_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, 'str'), + "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, '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="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ApplyUpdatesOperations(object): """ApplyUpdatesOperations operations. @@ -45,18 +246,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_parent( self, - resource_group_name, # type: str - resource_parent_type, # type: str - resource_parent_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - apply_update_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplyUpdate" + resource_group_name: str, + resource_parent_type: str, + resource_parent_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + apply_update_name: str, + **kwargs: Any + ) -> "_models.ApplyUpdate": """Track Updates to resource with parent. Track maintenance updates to resource with parent. @@ -85,38 +286,28 @@ def get_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'applyUpdateName': self._serialize.url("apply_update_name", apply_update_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + apply_update_name=apply_update_name, + template_url=self.get_parent.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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -125,18 +316,20 @@ def get_parent( return cls(pipeline_response, deserialized, {}) return deserialized + get_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - apply_update_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplyUpdate" + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + apply_update_name: str, + **kwargs: Any + ) -> "_models.ApplyUpdate": """Track Updates to resource. Track maintenance updates to resource. @@ -161,36 +354,26 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'applyUpdateName': self._serialize.url("apply_update_name", apply_update_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + apply_update_name=apply_update_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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -199,19 +382,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}'} # type: ignore + + @distributed_trace def create_or_update_parent( self, - resource_group_name, # type: str - provider_name, # type: str - resource_parent_type, # type: str - resource_parent_name, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplyUpdate" + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplyUpdate": """Apply Updates to resource with parent. Apply maintenance updates to resource with parent. @@ -238,37 +423,27 @@ def create_or_update_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.create_or_update_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.create_or_update_parent.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -277,17 +452,19 @@ def create_or_update_parent( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ApplyUpdate" + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> "_models.ApplyUpdate": """Apply Updates to resource. Apply maintenance updates to resource. @@ -310,35 +487,25 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - 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'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.create_or_update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.put(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ApplyUpdate', pipeline_response) @@ -347,13 +514,15 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListApplyUpdate"] + **kwargs: Any + ) -> Iterable["_models.ListApplyUpdate"]: """Get Configuration records within a subscription. Get Configuration records within a subscription. @@ -368,34 +537,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListApplyUpdate', pipeline_response) + deserialized = self._deserialize("ListApplyUpdate", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -408,12 +572,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py index 15e8936ad5d4..df23dccb4c4b 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_operations.py @@ -5,23 +5,384 @@ # 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, _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_parent_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, 'str'), + "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "configurationAssignmentName": _SERIALIZER.url("configuration_assignment_name", configuration_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_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_parent_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, 'str'), + "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "configurationAssignmentName": _SERIALIZER.url("configuration_assignment_name", configuration_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[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_parent_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, 'str'), + "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "configurationAssignmentName": _SERIALIZER.url("configuration_assignment_name", configuration_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_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_get_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "configurationAssignmentName": _SERIALIZER.url("configuration_assignment_name", configuration_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "configurationAssignmentName": _SERIALIZER.url("configuration_assignment_name", configuration_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + "configurationAssignmentName": _SERIALIZER.url("configuration_assignment_name", configuration_assignment_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_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_parent_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, 'str'), + "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, '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 + ) class ConfigurationAssignmentsOperations(object): """ConfigurationAssignmentsOperations operations. @@ -45,18 +406,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_parent( self, - resource_group_name, # type: str - provider_name, # type: str - resource_parent_type, # type: str - resource_parent_name, # type: str - resource_type, # type: str - resource_name, # type: str - configuration_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ConfigurationAssignment" + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any + ) -> "_models.ConfigurationAssignment": """Get configuration assignment. Get configuration for resource. @@ -85,38 +446,28 @@ def get_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + template_url=self.get_parent.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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -125,21 +476,23 @@ def get_parent( return cls(pipeline_response, deserialized, {}) return deserialized + get_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace def create_or_update_parent( self, - resource_group_name, # type: str - provider_name, # type: str - resource_parent_type, # type: str - resource_parent_name, # type: str - resource_type, # type: str - resource_name, # type: str - configuration_assignment_name, # type: str - configuration_assignment, # type: "_models.ConfigurationAssignment" - **kwargs # type: Any - ): - # type: (...) -> "_models.ConfigurationAssignment" + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + configuration_assignment: "_models.ConfigurationAssignment", + **kwargs: Any + ) -> "_models.ConfigurationAssignment": """Create configuration assignment. Register configuration for resource. @@ -170,43 +523,33 @@ def create_or_update_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, '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') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(configuration_assignment, 'ConfigurationAssignment') + + request = build_create_or_update_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update_parent.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(configuration_assignment, 'ConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -215,20 +558,22 @@ def create_or_update_parent( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace def delete_parent( self, - resource_group_name, # type: str - provider_name, # type: str - resource_parent_type, # type: str - resource_parent_name, # type: str - resource_type, # type: str - resource_name, # type: str - configuration_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ConfigurationAssignment"] + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any + ) -> Optional["_models.ConfigurationAssignment"]: """Unregister configuration for resource. Unregister configuration for resource. @@ -257,38 +602,28 @@ def delete_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + template_url=self.delete_parent.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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -299,18 +634,20 @@ def delete_parent( return cls(pipeline_response, deserialized, {}) return deserialized + delete_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace def get( self, - resource_group_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - configuration_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.ConfigurationAssignment" + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any + ) -> "_models.ConfigurationAssignment": """Get configuration assignment. Get configuration for resource. @@ -335,36 +672,26 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_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.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -373,19 +700,21 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - configuration_assignment_name, # type: str - configuration_assignment, # type: "_models.ConfigurationAssignment" - **kwargs # type: Any - ): - # type: (...) -> "_models.ConfigurationAssignment" + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + configuration_assignment: "_models.ConfigurationAssignment", + **kwargs: Any + ) -> "_models.ConfigurationAssignment": """Create configuration assignment. Register configuration for resource. @@ -412,41 +741,31 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(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(configuration_assignment, 'ConfigurationAssignment') + + request = build_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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(configuration_assignment, 'ConfigurationAssignment') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('ConfigurationAssignment', pipeline_response) @@ -455,18 +774,20 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - configuration_assignment_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.ConfigurationAssignment"] + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any + ) -> Optional["_models.ConfigurationAssignment"]: """Unregister configuration for resource. Unregister configuration for resource. @@ -491,36 +812,26 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - 'configurationAssignmentName': self._serialize.url("configuration_assignment_name", configuration_assignment_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + configuration_assignment_name=configuration_assignment_name, + template_url=self.delete.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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -531,19 +842,21 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}'} # type: ignore + + @distributed_trace def list_parent( self, - resource_group_name, # type: str - provider_name, # type: str - resource_parent_type, # type: str - resource_parent_name, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListConfigurationAssignmentsResult"] + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.ListConfigurationAssignmentsResult"]: """List configurationAssignments for resource. List configurationAssignments for resource. @@ -561,8 +874,10 @@ def list_parent( :param resource_name: Resource identifier. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] + :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListConfigurationAssignmentsResult"] @@ -570,40 +885,41 @@ def list_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list_parent.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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListConfigurationAssignmentsResult', pipeline_response) + deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -616,26 +932,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments'} # type: ignore + @distributed_trace def list( self, - resource_group_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListConfigurationAssignmentsResult"] + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.ListConfigurationAssignmentsResult"]: """List configurationAssignments for resource. List configurationAssignments for resource. @@ -649,8 +966,10 @@ def list( :param resource_name: Resource identifier. :type resource_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] + :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListConfigurationAssignmentsResult"] @@ -658,38 +977,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list.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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListConfigurationAssignmentsResult', pipeline_response) + deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -702,12 +1020,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py index 244d2249180b..e86d2725d423 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_configuration_assignments_within_subscription_operations.py @@ -5,23 +5,56 @@ # 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ConfigurationAssignmentsWithinSubscriptionOperations(object): """ConfigurationAssignmentsWithinSubscriptionOperations operations. @@ -45,18 +78,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListConfigurationAssignmentsResult"] + **kwargs: Any + ) -> Iterable["_models.ListConfigurationAssignmentsResult"]: """Get configuration assignment within a subscription. Get configuration assignment within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] + :return: An iterator like instance of either ListConfigurationAssignmentsResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListConfigurationAssignmentsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListConfigurationAssignmentsResult"] @@ -64,34 +99,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListConfigurationAssignmentsResult', pipeline_response) + deserialized = self._deserialize("ListConfigurationAssignmentsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,12 +134,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py index fa20a4dbc2b5..9a444d9d6e27 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_for_resource_group_operations.py @@ -5,23 +5,58 @@ # 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations') + 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 + ) class MaintenanceConfigurationsForResourceGroupOperations(object): """MaintenanceConfigurationsForResourceGroupOperations operations. @@ -45,12 +80,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListMaintenanceConfigurationsResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.ListMaintenanceConfigurationsResult"]: """Get Configuration records within a subscription and resource group. Get Configuration records within a subscription and resource group. @@ -58,8 +93,10 @@ def list( :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 ListMaintenanceConfigurationsResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] + :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListMaintenanceConfigurationsResult"] @@ -67,35 +104,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - '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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list.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_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('ListMaintenanceConfigurationsResult', pipeline_response) + deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -108,12 +141,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py index dac494a8357a..8226a21b541d 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_maintenance_configurations_operations.py @@ -5,23 +5,215 @@ # 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, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class MaintenanceConfigurationsOperations(object): """MaintenanceConfigurationsOperations operations. @@ -45,13 +237,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MaintenanceConfiguration" + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> "_models.MaintenanceConfiguration": """Get Configuration record. Get Configuration record. @@ -70,33 +262,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -105,16 +287,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace def create_or_update( self, - resource_group_name, # type: str - resource_name, # type: str - configuration, # type: "_models.MaintenanceConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.MaintenanceConfiguration" + resource_group_name: str, + resource_name: str, + configuration: "_models.MaintenanceConfiguration", + **kwargs: Any + ) -> "_models.MaintenanceConfiguration": """Create or Update configuration record. Create or Update configuration record. @@ -135,38 +319,28 @@ def create_or_update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create_or_update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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(configuration, 'MaintenanceConfiguration') - # 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_create_or_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.create_or_update.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(configuration, 'MaintenanceConfiguration') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -175,15 +349,17 @@ def create_or_update( return cls(pipeline_response, deserialized, {}) return deserialized + create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace def delete( self, - resource_group_name, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Optional["_models.MaintenanceConfiguration"] + resource_group_name: str, + resource_name: str, + **kwargs: Any + ) -> Optional["_models.MaintenanceConfiguration"]: """Delete Configuration record. Delete Configuration record. @@ -202,33 +378,23 @@ def delete( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.delete.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + template_url=self.delete.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, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = None @@ -239,16 +405,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized + delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - resource_name, # type: str - configuration, # type: "_models.MaintenanceConfiguration" - **kwargs # type: Any - ): - # type: (...) -> "_models.MaintenanceConfiguration" + resource_group_name: str, + resource_name: str, + configuration: "_models.MaintenanceConfiguration", + **kwargs: Any + ) -> "_models.MaintenanceConfiguration": """Patch configuration record. Patch configuration record. @@ -269,38 +437,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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(configuration, 'MaintenanceConfiguration') - # 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( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + content_type=content_type, + json=_json, + template_url=self.update.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(configuration, 'MaintenanceConfiguration') - 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 if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -309,20 +467,24 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListMaintenanceConfigurationsResult"] + **kwargs: Any + ) -> Iterable["_models.ListMaintenanceConfigurationsResult"]: """Get Configuration records within a subscription. Get Configuration records within a subscription. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] + :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListMaintenanceConfigurationsResult"] @@ -330,34 +492,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListMaintenanceConfigurationsResult', pipeline_response) + deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -370,12 +527,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_operations.py index 24a8f2f6e195..d0d3117faed3 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/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-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Maintenance/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,17 +72,18 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationsListResult"] + **kwargs: Any + ) -> Iterable["_models.OperationsListResult"]: """List available operations. List the available operations supported by the Microsoft.Maintenance resource provider. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either OperationsListResult or the result of cls(response) + :return: An iterator like instance of either OperationsListResult or the result of + cls(response) :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.OperationsListResult] :raises: ~azure.core.exceptions.HttpResponseError """ @@ -64,30 +92,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsListResult', pipeline_response) + deserialized = self._deserialize("OperationsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,12 +125,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py index 12804b37a9f7..baa48d27ac95 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_public_maintenance_configurations_operations.py @@ -5,23 +5,89 @@ # 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations') + 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_get_request( + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, '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 + ) class PublicMaintenanceConfigurationsOperations(object): """PublicMaintenanceConfigurationsOperations operations. @@ -45,18 +111,20 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListMaintenanceConfigurationsResult"] + **kwargs: Any + ) -> Iterable["_models.ListMaintenanceConfigurationsResult"]: """Get Public Maintenance Configuration records. Get Public Maintenance Configuration records. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] + :return: An iterator like instance of either ListMaintenanceConfigurationsResult or the result + of cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListMaintenanceConfigurationsResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ListMaintenanceConfigurationsResult"] @@ -64,34 +132,29 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - 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_request( + subscription_id=self._config.subscription_id, + template_url=self.list.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_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('ListMaintenanceConfigurationsResult', pipeline_response) + deserialized = self._deserialize("ListMaintenanceConfigurationsResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -104,23 +167,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations'} # type: ignore + @distributed_trace def get( self, - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.MaintenanceConfiguration" + resource_name: str, + **kwargs: Any + ) -> "_models.MaintenanceConfiguration": """Get Public Maintenance Configuration record. Get Public Maintenance Configuration record. @@ -137,32 +201,22 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_name=resource_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, response) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('MaintenanceConfiguration', pipeline_response) @@ -171,4 +225,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}'} # type: ignore + diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py index 015ee7df2f20..9ab94e3306d9 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_updates_operations.py @@ -5,23 +5,107 @@ # 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, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_parent_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceParentType": _SERIALIZER.url("resource_parent_type", resource_parent_type, 'str'), + "resourceParentName": _SERIALIZER.url("resource_parent_name", resource_parent_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-09-01-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "providerName": _SERIALIZER.url("provider_name", provider_name, 'str'), + "resourceType": _SERIALIZER.url("resource_type", resource_type, '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 + ) class UpdatesOperations(object): """UpdatesOperations operations. @@ -45,17 +129,17 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_parent( self, - resource_group_name, # type: str - provider_name, # type: str - resource_parent_type, # type: str - resource_parent_name, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListUpdatesResult"] + resource_group_name: str, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.ListUpdatesResult"]: """Get Updates to resource. Get updates to resources. @@ -82,40 +166,41 @@ def list_parent( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_parent.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceParentType': self._serialize.url("resource_parent_type", resource_parent_type, 'str'), - 'resourceParentName': self._serialize.url("resource_parent_name", resource_parent_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list_parent.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_parent_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_parent_type=resource_parent_type, + resource_parent_name=resource_parent_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListUpdatesResult', pipeline_response) + deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -128,26 +213,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_parent.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates'} # type: ignore + @distributed_trace def list( self, - resource_group_name, # type: str - provider_name, # type: str - resource_type, # type: str - resource_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.ListUpdatesResult"] + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any + ) -> Iterable["_models.ListUpdatesResult"]: """Get Updates to resource. Get updates to resources. @@ -170,38 +256,37 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'providerName': self._serialize.url("provider_name", provider_name, 'str'), - 'resourceType': self._serialize.url("resource_type", resource_type, 'str'), - 'resourceName': self._serialize.url("resource_name", resource_name, 'str'), - } - url = self._client.format_url(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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=self.list.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_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + provider_name=provider_name, + resource_type=resource_type, + resource_name=resource_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('ListUpdatesResult', pipeline_response) + deserialized = self._deserialize("ListUpdatesResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -214,12 +299,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.MaintenanceError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.MaintenanceError, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data )