From a447329a20d74644f13e237b926c8cf4a362f2c6 Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Sat, 9 Jul 2022 02:48:40 +0000 Subject: [PATCH] CodeGen from PR 19482 in Azure/azure-rest-api-specs [Hub Generated] Review request for Microsoft.Maintenance to add version preview/2022-07-01-preview (#19482) * Adds base for updating Microsoft.Maintenance from version preview/2021-09-01-preview to version 2022-07-01-preview * Updates readme * Updates API version in new specs and examples * Adding Resource as Maintenance Scope for Maintenance Configuration APIs. Co-authored-by: Paul Selvaraj --- .../azure-mgmt-maintenance/_meta.json | 10 +- .../azure/mgmt/maintenance/__init__.py | 12 +- .../azure/mgmt/maintenance/_configuration.py | 31 +- .../_maintenance_management_client.py | 142 +- .../azure/mgmt/maintenance/_metadata.json | 111 -- .../azure/mgmt/maintenance/_patch.py | 19 + .../azure/mgmt/maintenance/_vendor.py | 27 + .../azure/mgmt/maintenance/_version.py | 2 +- .../azure/mgmt/maintenance/aio/__init__.py | 10 + .../mgmt/maintenance/aio/_configuration.py | 18 +- .../aio/_maintenance_management_client.py | 130 +- .../azure/mgmt/maintenance/aio/_patch.py | 19 + .../maintenance/aio/operations/__init__.py | 5 + ...ly_update_for_resource_group_operations.py | 111 +- .../operations/_apply_updates_operations.py | 365 +++--- .../_configuration_assignments_operations.py | 635 +++++---- ...ignments_within_subscription_operations.py | 114 +- ...gurations_for_resource_group_operations.py | 117 +- .../_maintenance_configurations_operations.py | 369 +++--- .../maintenance/aio/operations/_operations.py | 106 +- .../mgmt/maintenance/aio/operations/_patch.py | 19 + ...c_maintenance_configurations_operations.py | 170 +-- .../aio/operations/_updates_operations.py | 212 +-- .../azure/mgmt/maintenance/models/__init__.py | 66 +- .../_maintenance_management_client_enums.py | 40 +- .../azure/mgmt/maintenance/models/_models.py | 672 ---------- .../mgmt/maintenance/models/_models_py3.py | 517 +++++--- .../azure/mgmt/maintenance/models/_patch.py | 19 + .../mgmt/maintenance/operations/__init__.py | 5 + ...ly_update_for_resource_group_operations.py | 166 ++- .../operations/_apply_updates_operations.py | 647 +++++++--- .../_configuration_assignments_operations.py | 1137 ++++++++++++----- ...ignments_within_subscription_operations.py | 165 ++- ...gurations_for_resource_group_operations.py | 172 ++- .../_maintenance_configurations_operations.py | 611 ++++++--- .../maintenance/operations/_operations.py | 140 +- .../mgmt/maintenance/operations/_patch.py | 19 + ...c_maintenance_configurations_operations.py | 260 ++-- .../operations/_updates_operations.py | 333 +++-- 39 files changed, 4428 insertions(+), 3295 deletions(-) delete mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_metadata.json 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 create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_patch.py delete mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_models.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_patch.py create mode 100644 sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_patch.py diff --git a/sdk/maintenance/azure-mgmt-maintenance/_meta.json b/sdk/maintenance/azure-mgmt-maintenance/_meta.json index d9b69f081ccf..e2d8abb82d63 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.16.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "f4c77149bdbc236d428576d806690a954e4bb0aa", + "commit": "6c11930fe7757c6416cb2580eeddb4e57695c707", "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 --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.16.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..41a79a493c23 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/__init__.py @@ -10,10 +10,14 @@ from ._version import VERSION __version__ = VERSION -__all__ = ['MaintenanceManagementClient'] try: - from ._patch import patch_sdk # type: ignore - patch_sdk() + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import except ImportError: - pass + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk +__all__ = ['MaintenanceManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..e11cab9cc098 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_configuration.py @@ -6,22 +6,20 @@ # 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 -class MaintenanceManagementClientConfiguration(Configuration): +class MaintenanceManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for MaintenanceManagementClient. Note that all parameters used to create this instance are saved as instance @@ -29,26 +27,31 @@ class MaintenanceManagementClientConfiguration(Configuration): :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 + :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ 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) + api_version = kwargs.pop('api_version', "2022-07-01-preview") # type: str + 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 - self.api_version = "2021-09-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-maintenance/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +71,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..8c81ce4b47ea 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,131 @@ # 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, TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.rest import HttpRequest, HttpResponse +from azure.mgmt.core import ARMPipelineClient -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 +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 import TokenCredential -class MaintenanceManagementClient(object): +class MaintenanceManagementClient: # pylint: disable=too-many-instance-attributes """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 + :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: 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._serialize.client_side_validation = False self.public_maintenance_configurations = PublicMaintenanceConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.apply_updates = ApplyUpdatesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.configuration_assignments = ConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.maintenance_configurations = MaintenanceConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.updates = UpdatesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) + - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request: 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 deleted file mode 100644 index f2d6f2b65a0b..000000000000 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_metadata.json +++ /dev/null @@ -1,111 +0,0 @@ -{ - "chosen_version": "2021-09-01-preview", - "total_api_version_list": ["2021-09-01-preview"], - "client": { - "name": "MaintenanceManagementClient", - "filename": "_maintenance_management_client", - "description": "Azure Maintenance Management Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": 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\"]}}}" - }, - "global_parameters": { - "sync": { - "credential": { - "signature": "credential, # type: \"TokenCredential\"", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials.TokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id, # type: str", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "async": { - "credential": { - "signature": "credential: \"AsyncTokenCredential\",", - "description": "Credential needed for the client to connect to Azure.", - "docstring_type": "~azure.core.credentials_async.AsyncTokenCredential", - "required": true - }, - "subscription_id": { - "signature": "subscription_id: str,", - "description": "Subscription credentials that uniquely identify a Microsoft Azure subscription. The subscription ID forms part of the URI for every service call.", - "docstring_type": "str", - "required": true - } - }, - "constant": { - }, - "call": "credential, subscription_id", - "service_client_specific": { - "sync": { - "api_version": { - "signature": "api_version=None, # type: Optional[str]", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url=None, # type: Optional[str]", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile=KnownProfiles.default, # type: KnownProfiles", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - }, - "async": { - "api_version": { - "signature": "api_version: Optional[str] = None,", - "description": "API version to use if no profile is provided, or if missing in profile.", - "docstring_type": "str", - "required": false - }, - "base_url": { - "signature": "base_url: Optional[str] = None,", - "description": "Service URL", - "docstring_type": "str", - "required": false - }, - "profile": { - "signature": "profile: KnownProfiles = KnownProfiles.default,", - "description": "A profile definition, from KnownProfiles to dict.", - "docstring_type": "azure.profiles.KnownProfiles", - "required": false - } - } - } - }, - "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\"]}}}" - }, - "operation_groups": { - "public_maintenance_configurations": "PublicMaintenanceConfigurationsOperations", - "apply_updates": "ApplyUpdatesOperations", - "configuration_assignments": "ConfigurationAssignmentsOperations", - "maintenance_configurations": "MaintenanceConfigurationsOperations", - "maintenance_configurations_for_resource_group": "MaintenanceConfigurationsForResourceGroupOperations", - "apply_update_for_resource_group": "ApplyUpdateForResourceGroupOperations", - "configuration_assignments_within_subscription": "ConfigurationAssignmentsWithinSubscriptionOperations", - "operations": "Operations", - "updates": "UpdatesOperations" - } -} \ No newline at end of file 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..0ad201a8c586 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..59d3d8094345 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 @@ -7,4 +7,14 @@ # -------------------------------------------------------------------------- from ._maintenance_management_client import MaintenanceManagementClient + +try: + from ._patch import __all__ as _patch_all + from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +except ImportError: + _patch_all = [] +from ._patch import patch_sdk as _patch_sdk __all__ = ['MaintenanceManagementClient'] +__all__.extend([p for p in _patch_all if p not in __all__]) + +_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..e9919fc19653 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 @@ -19,7 +19,7 @@ from azure.core.credentials_async import AsyncTokenCredential -class MaintenanceManagementClientConfiguration(Configuration): +class MaintenanceManagementClientConfiguration(Configuration): # pylint: disable=too-many-instance-attributes """Configuration for MaintenanceManagementClient. Note that all parameters used to create this instance are saved as instance @@ -27,8 +27,12 @@ class MaintenanceManagementClientConfiguration(Configuration): :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 + :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( @@ -37,15 +41,17 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(MaintenanceManagementClientConfiguration, self).__init__(**kwargs) + api_version = kwargs.pop('api_version', "2022-07-01-preview") # type: str + 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 - self.api_version = "2021-09-01-preview" + self.api_version = api_version self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-maintenance/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +70,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..6d02efbc88a3 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,131 @@ # 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, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from azure.core.credentials_async import AsyncTokenCredential +from azure.core.rest import AsyncHttpResponse, HttpRequest +from azure.mgmt.core import AsyncARMPipelineClient -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 +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 -class MaintenanceManagementClient(object): +class MaintenanceManagementClient: # pylint: disable=too-many-instance-attributes """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 + :keyword api_version: Api Version. Default value is "2022-07-01-preview". Note that overriding + this default value may result in unsupported behavior. + :paramtype api_version: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - 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._client, self._config, self._serialize, self._deserialize + ) self.apply_updates = ApplyUpdatesOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.configuration_assignments = ConfigurationAssignmentsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.maintenance_configurations = MaintenanceConfigurationsOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.maintenance_configurations_for_resource_group = MaintenanceConfigurationsForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.apply_update_for_resource_group = ApplyUpdateForResourceGroupOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.configuration_assignments_within_subscription = ConfigurationAssignmentsWithinSubscriptionOperations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) + self._client, self._config, self._serialize, self._deserialize + ) self.updates = UpdatesOperations( - self._client, self._config, self._serialize, self._deserialize) + 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..0ad201a8c586 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py index 9073f0a77635..777d5d4225d7 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/__init__.py @@ -16,6 +16,9 @@ from ._operations import Operations from ._updates_operations import UpdatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'PublicMaintenanceConfigurationsOperations', 'ApplyUpdatesOperations', @@ -27,3 +30,5 @@ 'Operations', 'UpdatesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ 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..19ebdd36da5e 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.utils import case_insensitive_dict 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]] class ApplyUpdateForResourceGroupOperations: - """ApplyUpdateForResourceGroupOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`apply_update_for_resource_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListApplyUpdate"]: + ) -> AsyncIterable[_models.ListApplyUpdate]: """Get Configuration records within a subscription and resource group. Get Configuration records within a subscription and resource group. @@ -57,40 +60,47 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListApplyUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplyUpdate"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplyUpdate] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -99,17 +109,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore 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..6a77a23b8811 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,45 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._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]] class ApplyUpdatesOperations: - """ApplyUpdatesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`apply_updates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get_parent( self, resource_group_name: str, @@ -51,7 +55,7 @@ async def get_parent( resource_name: str, apply_update_name: str, **kwargs: Any - ) -> "_models.ApplyUpdate": + ) -> _models.ApplyUpdate: """Track Updates to resource with parent. Track maintenance updates to resource with parent. @@ -75,43 +79,45 @@ async def get_parent( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.get_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +126,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 + 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, @@ -130,7 +139,7 @@ async def get( resource_name: str, apply_update_name: str, **kwargs: Any - ) -> "_models.ApplyUpdate": + ) -> _models.ApplyUpdate: """Track Updates to resource. Track maintenance updates to resource. @@ -150,41 +159,43 @@ async def get( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +204,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 + 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, @@ -204,7 +218,7 @@ async def create_or_update_parent( resource_type: str, resource_name: str, **kwargs: Any - ) -> "_models.ApplyUpdate": + ) -> _models.ApplyUpdate: """Apply Updates to resource with parent. Apply maintenance updates to resource with parent. @@ -226,42 +240,44 @@ async def create_or_update_parent( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.create_or_update_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +286,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 + 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, @@ -279,7 +298,7 @@ async def create_or_update( resource_type: str, resource_name: str, **kwargs: Any - ) -> "_models.ApplyUpdate": + ) -> _models.ApplyUpdate: """Apply Updates to resource. Apply maintenance updates to resource. @@ -297,40 +316,42 @@ async def create_or_update( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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,12 +360,15 @@ 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 + 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 - ) -> AsyncIterable["_models.ListApplyUpdate"]: + ) -> AsyncIterable[_models.ListApplyUpdate]: """Get Configuration records within a subscription. Get Configuration records within a subscription. @@ -354,39 +378,45 @@ def list( :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.maintenance.models.ListApplyUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplyUpdate"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplyUpdate] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -395,17 +425,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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/applyUpdates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore 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..9257f41c53f7 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,45 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._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]] class ConfigurationAssignmentsOperations: - """ConfigurationAssignmentsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`configuration_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get_parent( self, resource_group_name: str, @@ -51,7 +55,7 @@ async def get_parent( resource_name: str, configuration_assignment_name: str, **kwargs: Any - ) -> "_models.ConfigurationAssignment": + ) -> _models.ConfigurationAssignment: """Get configuration assignment. Get configuration for resource. @@ -75,43 +79,45 @@ async def get_parent( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + + 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, + api_version=api_version, + template_url=self.get_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +126,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 + 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, @@ -131,9 +140,9 @@ async def create_or_update_parent( resource_type: str, resource_name: str, configuration_assignment_name: str, - configuration_assignment: "_models.ConfigurationAssignment", + configuration_assignment: _models.ConfigurationAssignment, **kwargs: Any - ) -> "_models.ConfigurationAssignment": + ) -> _models.ConfigurationAssignment: """Create configuration assignment. Register configuration for resource. @@ -159,48 +168,49 @@ async def create_or_update_parent( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +219,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 + 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, @@ -221,7 +234,7 @@ async def delete_parent( resource_name: str, configuration_assignment_name: str, **kwargs: Any - ) -> Optional["_models.ConfigurationAssignment"]: + ) -> Optional[_models.ConfigurationAssignment]: """Unregister configuration for resource. Unregister configuration for resource. @@ -245,43 +258,45 @@ async def delete_parent( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfigurationAssignment"]] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + + + 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, + api_version=api_version, + template_url=self.delete_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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 +307,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 + 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, @@ -302,7 +320,7 @@ async def get( resource_name: str, configuration_assignment_name: str, **kwargs: Any - ) -> "_models.ConfigurationAssignment": + ) -> _models.ConfigurationAssignment: """Get configuration assignment. Get configuration for resource. @@ -322,41 +340,43 @@ async def get( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +385,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 + 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, @@ -374,9 +397,9 @@ async def create_or_update( resource_type: str, resource_name: str, configuration_assignment_name: str, - configuration_assignment: "_models.ConfigurationAssignment", + configuration_assignment: _models.ConfigurationAssignment, **kwargs: Any - ) -> "_models.ConfigurationAssignment": + ) -> _models.ConfigurationAssignment: """Create configuration assignment. Register configuration for resource. @@ -398,46 +421,47 @@ async def create_or_update( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') - - # 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +470,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 + 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, @@ -456,7 +483,7 @@ async def delete( resource_name: str, configuration_assignment_name: str, **kwargs: Any - ) -> Optional["_models.ConfigurationAssignment"]: + ) -> Optional[_models.ConfigurationAssignment]: """Unregister configuration for resource. Unregister configuration for resource. @@ -476,41 +503,43 @@ async def delete( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfigurationAssignment"]] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + + + 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, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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 +550,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 + 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, @@ -532,7 +564,7 @@ def list_parent( resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListConfigurationAssignmentsResult"]: + ) -> AsyncIterable[_models.ListConfigurationAssignmentsResult]: """List configurationAssignments for resource. List configurationAssignments for resource. @@ -550,49 +582,63 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -601,21 +647,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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 + 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, @@ -623,7 +675,7 @@ def list( resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListConfigurationAssignmentsResult"]: + ) -> AsyncIterable[_models.ListConfigurationAssignmentsResult]: """List configurationAssignments for resource. List configurationAssignments for resource. @@ -637,47 +689,59 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -686,17 +750,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore 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..660ed509771d 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,98 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.utils import case_insensitive_dict 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]] class ConfigurationAssignmentsWithinSubscriptionOperations: - """ConfigurationAssignmentsWithinSubscriptionOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`configuration_assignments_within_subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ListConfigurationAssignmentsResult"]: + ) -> AsyncIterable[_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.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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -95,17 +106,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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/configurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore 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..4d7518ac1080 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,47 +6,49 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.utils import case_insensitive_dict 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]] class MaintenanceConfigurationsForResourceGroupOperations: - """MaintenanceConfigurationsForResourceGroupOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`maintenance_configurations_for_resource_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, resource_group_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListMaintenanceConfigurationsResult"]: + ) -> AsyncIterable[_models.ListMaintenanceConfigurationsResult]: """Get Configuration records within a subscription and resource group. Get Configuration records within a subscription and resource group. @@ -53,44 +56,53 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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 +111,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore 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..e4712fcd943f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,48 +6,51 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._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]] class MaintenanceConfigurationsOperations: - """MaintenanceConfigurationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`maintenance_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace_async async def get( self, resource_group_name: str, resource_name: str, **kwargs: Any - ) -> "_models.MaintenanceConfiguration": + ) -> _models.MaintenanceConfiguration: """Get Configuration record. Get Configuration record. @@ -60,38 +64,40 @@ async def get( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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,15 +106,18 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + 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, resource_name: str, - configuration: "_models.MaintenanceConfiguration", + configuration: _models.MaintenanceConfiguration, **kwargs: Any - ) -> "_models.MaintenanceConfiguration": + ) -> _models.MaintenanceConfiguration: """Create or Update configuration record. Create or Update configuration record. @@ -124,43 +133,44 @@ async def create_or_update( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') - - # 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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,14 +179,17 @@ 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 + 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, resource_name: str, **kwargs: Any - ) -> Optional["_models.MaintenanceConfiguration"]: + ) -> Optional[_models.MaintenanceConfiguration]: """Delete Configuration record. Delete Configuration record. @@ -190,38 +203,40 @@ async def delete( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MaintenanceConfiguration"]] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MaintenanceConfiguration]] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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,15 +247,18 @@ async def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + 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, resource_name: str, - configuration: "_models.MaintenanceConfiguration", + configuration: _models.MaintenanceConfiguration, **kwargs: Any - ) -> "_models.MaintenanceConfiguration": + ) -> _models.MaintenanceConfiguration: """Patch configuration record. Patch configuration record. @@ -256,43 +274,44 @@ async def update( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') - - # 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + _json = self._serialize.body(configuration, 'MaintenanceConfiguration') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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,54 +320,65 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + update.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}"} # type: ignore + + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ListMaintenanceConfigurationsResult"]: + ) -> AsyncIterable[_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.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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -357,17 +387,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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/maintenanceConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore 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..eb17c5556d67 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,84 +6,96 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] class Operations: - """Operations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.OperationsListResult"]: + ) -> AsyncIterable[_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) - :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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - 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( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -91,17 +104,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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': '/providers/Microsoft.Maintenance/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Maintenance/operations"} # type: ignore diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_patch.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/aio/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..f290078e540c 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,88 +6,99 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._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]] class PublicMaintenanceConfigurationsOperations: - """PublicMaintenanceConfigurationsOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`public_maintenance_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list( self, **kwargs: Any - ) -> AsyncIterable["_models.ListMaintenanceConfigurationsResult"]: + ) -> AsyncIterable[_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.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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -95,26 +107,32 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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 + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations"} # type: ignore + @distributed_trace_async async def get( self, resource_name: str, **kwargs: Any - ) -> "_models.MaintenanceConfiguration": + ) -> _models.MaintenanceConfiguration: """Get Public Maintenance Configuration record. Get Public Maintenance Configuration record. @@ -126,37 +144,39 @@ async def get( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_name=resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +185,6 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}'} # type: ignore + + 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..b33c93961cda 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,42 +6,44 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar -import warnings +from typing import Any, AsyncIterable, Callable, Dict, Optional, TypeVar 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.utils import case_insensitive_dict 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]] class UpdatesOperations: - """UpdatesOperations async operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.aio.MaintenanceManagementClient`'s + :attr:`updates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer) -> None: - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs) -> None: + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @distributed_trace def list_parent( self, resource_group_name: str, @@ -50,7 +53,7 @@ def list_parent( resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUpdatesResult"]: + ) -> AsyncIterable[_models.ListUpdatesResult]: """Get Updates to resource. Get updates to resources. @@ -69,48 +72,61 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUpdatesResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -119,21 +135,27 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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 + 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, @@ -141,7 +163,7 @@ def list( resource_type: str, resource_name: str, **kwargs: Any - ) -> AsyncIterable["_models.ListUpdatesResult"]: + ) -> AsyncIterable[_models.ListUpdatesResult]: """Get Updates to resource. Get updates to resources. @@ -156,46 +178,57 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUpdatesResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -204,17 +237,22 @@ async def extract_data(pipeline_response): async def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = await self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"} # type: ignore 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..ffc74d1b7bd6 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, @@ -56,7 +36,9 @@ UpdateStatus, Visibility, ) - +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'ApplyUpdate', 'ConfigurationAssignment', @@ -85,3 +67,5 @@ 'UpdateStatus', 'Visibility', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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..2f437f9bc766 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,11 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta -from six import with_metaclass - -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)): +from enum import Enum +from azure.core import CaseInsensitiveEnumMeta + + +class CreatedByType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The type of identity that created the resource. """ @@ -35,7 +19,7 @@ class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): MANAGED_IDENTITY = "ManagedIdentity" KEY = "Key" -class ImpactType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ImpactType(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The impact type """ @@ -48,13 +32,15 @@ class ImpactType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): #: Pending updates can redeploy resource. REDEPLOY = "Redeploy" -class MaintenanceScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class MaintenanceScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """Gets or sets maintenanceScope of the configuration """ #: This maintenance scope controls installation of azure platform updates i.e. services on #: physical nodes hosting customer VMs. HOST = "Host" + #: This maintenance scope controls the default update maintenance of the Azure Resource. + RESOURCE = "Resource" #: This maintenance scope controls os image installation on VM/VMSS. OS_IMAGE = "OSImage" #: This maintenance scope controls extension installation on VM/VMSS. @@ -66,7 +52,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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 +61,14 @@ class RebootOptions(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NEVER = "Never" ALWAYS = "Always" -class TaskScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TaskScope(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """The status """ @@ -97,7 +83,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(str, Enum, metaclass=CaseInsensitiveEnumMeta): """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..2cd0f0725e6b 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 @@ -7,12 +7,14 @@ # -------------------------------------------------------------------------- import datetime -from typing import Any, Dict, List, Optional, Union +from typing import Any, Dict, List, Optional, TYPE_CHECKING, Union from azure.core.exceptions import HttpResponseError import msrest.serialization -from ._maintenance_management_client_enums import * +if TYPE_CHECKING: + # pylint: disable=unused-import,ungrouped-imports + import __init__ as _models class Resource(msrest.serialization.Model): @@ -49,6 +51,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -70,13 +74,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", - "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 + :ivar status: The status. Known values are: "Pending", "InProgress", "Completed", "RetryNow", + "RetryLater". + :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 = { @@ -99,11 +103,20 @@ class ApplyUpdate(Resource): def __init__( self, *, - status: Optional[Union[str, "UpdateStatus"]] = None, + status: Optional[Union[str, "_models.UpdateStatus"]] = None, resource_id: Optional[str] = None, last_update_time: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword status: The status. Known values are: "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 +137,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 +170,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 +187,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 +206,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 +221,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 +243,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 +260,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. Known values + are: "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 = { @@ -253,13 +289,31 @@ class InputPatchConfiguration(msrest.serialization.Model): def __init__( self, *, - reboot_setting: Optional[Union[str, "RebootOptions"]] = "IfRequired", - windows_parameters: Optional["InputWindowsParameters"] = None, - linux_parameters: Optional["InputLinuxParameters"] = None, - pre_tasks: Optional[List["TaskProperties"]] = None, - post_tasks: Optional[List["TaskProperties"]] = None, + reboot_setting: Optional[Union[str, "_models.RebootOptions"]] = "IfRequired", + windows_parameters: Optional["_models.InputWindowsParameters"] = None, + linux_parameters: Optional["_models.InputLinuxParameters"] = None, + pre_tasks: Optional[List["_models.TaskProperties"]] = None, + post_tasks: Optional[List["_models.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. Known + values are: "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 +325,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 +351,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 +371,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 = { @@ -318,9 +382,13 @@ class ListApplyUpdate(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ApplyUpdate"]] = None, + value: Optional[List["_models.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 +396,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 = { @@ -339,9 +407,13 @@ class ListConfigurationAssignmentsResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["ConfigurationAssignment"]] = None, + value: Optional[List["_models.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 +421,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 = { @@ -360,9 +432,13 @@ class ListMaintenanceConfigurationsResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["MaintenanceConfiguration"]] = None, + value: Optional[List["_models.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 +446,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 = { @@ -381,9 +457,13 @@ class ListUpdatesResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Update"]] = None, + value: Optional[List["_models.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 +482,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 - 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 + :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. Known values are: + "Host", "Resource", "OSImage", "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". + :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'. Known values are: "Custom", "Public". + :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 +527,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 = { @@ -483,9 +563,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, namespace: Optional[str] = None, extension_properties: Optional[Dict[str, str]] = None, - maintenance_scope: Optional[Union[str, "MaintenanceScope"]] = None, - visibility: Optional[Union[str, "Visibility"]] = None, - install_patches: Optional["InputPatchConfiguration"] = None, + maintenance_scope: Optional[Union[str, "_models.MaintenanceScope"]] = None, + visibility: Optional[Union[str, "_models.Visibility"]] = None, + install_patches: Optional["_models.InputPatchConfiguration"] = None, start_date_time: Optional[str] = None, expiration_date_time: Optional[str] = None, duration: Optional[str] = None, @@ -493,6 +573,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. Known values + are: "Host", "Resource", "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'. Known values are: "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 +640,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 = { @@ -522,9 +651,13 @@ class MaintenanceError(msrest.serialization.Model): def __init__( self, *, - error: Optional["ErrorDetails"] = None, + error: Optional["_models.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 +665,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 = { @@ -556,12 +689,24 @@ def __init__( self, *, name: Optional[str] = None, - display: Optional["OperationInfo"] = None, + display: Optional["_models.OperationInfo"] = None, origin: Optional[str] = None, properties: Optional[Any] = None, 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 +718,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 +744,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 +764,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 = { @@ -620,9 +775,13 @@ class OperationsListResult(msrest.serialization.Model): def __init__( self, *, - value: Optional[List["Operation"]] = None, + value: Optional[List["_models.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 +789,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 - 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 + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Known values are: + "User", "Application", "ManagedIdentity", "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. Known values + are: "User", "Application", "ManagedIdentity", "Key". + :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 = { @@ -659,13 +818,29 @@ def __init__( self, *, created_by: Optional[str] = None, - created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, created_at: Optional[datetime.datetime] = None, last_modified_by: Optional[str] = None, - last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_by_type: Optional[Union[str, "_models.CreatedByType"]] = None, last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Known values are: + "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. Known + values are: "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 +853,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 - each VM. Possible values include: "Global", "Resource". Default value: "Global". - :type task_scope: str or ~azure.mgmt.maintenance.models.TaskScope + :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. Known values are: "Global", "Resource". Default value: "Global". + :vartype task_scope: str or ~azure.mgmt.maintenance.models.TaskScope """ _attribute_map = { @@ -698,9 +873,18 @@ def __init__( *, parameters: Optional[Dict[str, str]] = None, source: Optional[str] = None, - task_scope: Optional[Union[str, "TaskScope"]] = "Global", + task_scope: Optional[Union[str, "_models.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. Known values are: "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 +894,21 @@ 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. Known values are: "Host", "Resource", "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 + :vartype maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope + :ivar impact_type: The impact type. Known values are: "None", "Freeze", "Restart", "Redeploy". + :vartype impact_type: str or ~azure.mgmt.maintenance.models.ImpactType + :ivar status: The status. Known values are: "Pending", "InProgress", "Completed", "RetryNow", + "RetryLater". + :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 = { @@ -740,14 +923,32 @@ class Update(msrest.serialization.Model): def __init__( self, *, - maintenance_scope: Optional[Union[str, "MaintenanceScope"]] = None, - impact_type: Optional[Union[str, "ImpactType"]] = None, - status: Optional[Union[str, "UpdateStatus"]] = None, + maintenance_scope: Optional[Union[str, "_models.MaintenanceScope"]] = None, + impact_type: Optional[Union[str, "_models.ImpactType"]] = None, + status: Optional[Union[str, "_models.UpdateStatus"]] = None, impact_duration_in_sec: Optional[int] = None, not_before: Optional[datetime.datetime] = None, resource_id: Optional[str] = None, **kwargs ): + """ + :keyword maintenance_scope: The impact area. Known values are: "Host", "Resource", "OSImage", + "Extension", "InGuestPatch", "SQLDB", "SQLManagedInstance". + :paramtype maintenance_scope: str or ~azure.mgmt.maintenance.models.MaintenanceScope + :keyword impact_type: The impact type. Known values are: "None", "Freeze", "Restart", + "Redeploy". + :paramtype impact_type: str or ~azure.mgmt.maintenance.models.ImpactType + :keyword status: The status. Known values are: "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/models/_patch.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/models/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py index 9073f0a77635..777d5d4225d7 100644 --- a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/__init__.py @@ -16,6 +16,9 @@ from ._operations import Operations from ._updates_operations import UpdatesOperations +from ._patch import __all__ as _patch_all +from ._patch import * # type: ignore # pylint: disable=unused-wildcard-import +from ._patch import patch_sdk as _patch_sdk __all__ = [ 'PublicMaintenanceConfigurationsOperations', 'ApplyUpdatesOperations', @@ -27,3 +30,5 @@ 'Operations', 'UpdatesOperations', ] +__all__.extend([p for p in _patch_all if p not in __all__]) +_patch_sdk() \ No newline at end of file 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..28cd15042d5f 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,52 +6,87 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplyUpdateForResourceGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class ApplyUpdateForResourceGroupOperations(object): - """ApplyUpdateForResourceGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`apply_update_for_resource_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. @@ -62,40 +98,47 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListApplyUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplyUpdate"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplyUpdate] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -104,17 +147,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore 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..479b6c82593b 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,58 +6,267 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('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}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + apply_update_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/{applyUpdateName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('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") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/applyUpdates/default") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ApplyUpdatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class ApplyUpdatesOperations(object): - """ApplyUpdatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`apply_updates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. @@ -80,43 +290,45 @@ def get_parent( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.get_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +337,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 + 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. @@ -156,41 +370,43 @@ def get( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +415,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 + 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. @@ -233,42 +451,44 @@ def create_or_update_parent( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.create_or_update_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +497,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 + 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. @@ -305,40 +527,42 @@ def create_or_update( :rtype: ~azure.mgmt.maintenance.models.ApplyUpdate :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ApplyUpdate"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ApplyUpdate] + + + 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, + api_version=api_version, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.put(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +571,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 + 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. @@ -363,39 +589,45 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListApplyUpdate] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListApplyUpdate"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListApplyUpdate] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -404,17 +636,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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/applyUpdates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/applyUpdates"} # type: ignore 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..abebcce71136 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,58 +6,430 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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, + provider_name: str, + resource_parent_type: str, + resource_parent_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('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}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_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: Optional[_models.ConfigurationAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('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}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + 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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('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}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + configuration_assignment_name: str, + *, + json: Optional[_models.ConfigurationAssignment] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + 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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments/{configurationAssignmentName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConfigurationAssignmentsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class ConfigurationAssignmentsOperations(object): - """ConfigurationAssignmentsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`configuration_assignments` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. @@ -80,43 +453,45 @@ def get_parent( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + + 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, + api_version=api_version, + template_url=self.get_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +500,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 + 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. @@ -165,48 +542,49 @@ def create_or_update_parent( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +593,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 + 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. @@ -252,43 +632,45 @@ def delete_parent( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfigurationAssignment"]] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + + + 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, + api_version=api_version, + template_url=self.delete_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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 +681,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 + 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. @@ -330,41 +714,43 @@ def get( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + + 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, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +759,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 + 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. @@ -407,46 +795,47 @@ def create_or_update( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ConfigurationAssignment"] error_map = { 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') - - # 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.ConfigurationAssignment] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +844,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 + 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. @@ -486,41 +877,43 @@ def delete( :rtype: ~azure.mgmt.maintenance.models.ConfigurationAssignment or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.ConfigurationAssignment"]] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.ConfigurationAssignment]] + + + 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, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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 +924,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 + 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,49 +956,63 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -612,30 +1021,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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 + 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,47 +1063,59 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -698,17 +1124,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore 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..cd592fc73fe4 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,134 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class ConfigurationAssignmentsWithinSubscriptionOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class ConfigurationAssignmentsWithinSubscriptionOperations(object): - """ConfigurationAssignmentsWithinSubscriptionOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`configuration_assignments_within_subscription` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListConfigurationAssignmentsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -100,17 +142,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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/configurationAssignments'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/configurationAssignments"} # type: ignore 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..34bb7be2a0cd 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,52 +6,87 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class MaintenanceConfigurationsForResourceGroupOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class MaintenanceConfigurationsForResourceGroupOperations(object): - """MaintenanceConfigurationsForResourceGroupOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`maintenance_configurations_for_resource_group` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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,44 +94,53 @@ 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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,17 +149,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore 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..2a05dcf07841 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,53 +6,250 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_create_or_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: Optional[_models.MaintenanceConfiguration] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + resource_name: str, + *, + json: Optional[_models.MaintenanceConfiguration] = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', None)) # type: Optional[str] + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "resourceName": _SERIALIZER.url("resource_name", resource_name, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + if content_type is not None: + _headers['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=_url, + params=_params, + headers=_headers, + json=json, + content=content, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class MaintenanceConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class MaintenanceConfigurationsOperations(object): - """MaintenanceConfigurationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`maintenance_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. @@ -65,38 +263,40 @@ def get( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +305,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + 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. @@ -130,43 +332,44 @@ def create_or_update( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') - - # 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + _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, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.create_or_update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +378,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 + 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. @@ -197,38 +402,40 @@ def delete( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration or None :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.MaintenanceConfiguration"]] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[Optional[_models.MaintenanceConfiguration]] + + + request = build_delete_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + template_url=self.delete.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.delete(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + 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 +446,18 @@ def delete( return cls(pipeline_response, deserialized, {}) return deserialized - delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + 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. @@ -264,43 +473,44 @@ def update( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') - - # 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') - - 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) + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + content_type = kwargs.pop('content_type', _headers.pop('Content-Type', "application/json")) # type: Optional[str] + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + _json = self._serialize.body(configuration, 'MaintenanceConfiguration') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + resource_name=resource_name, + api_version=api_version, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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,55 +519,65 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized - update.metadata = {'url': '/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/Microsoft.Maintenance/maintenanceConfigurations/{resourceName}'} # type: ignore + 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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -366,17 +586,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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/maintenanceConfigurations'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/maintenanceConfigurations"} # type: ignore 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..c9eaedc69be7 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,89 +6,125 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + # Construct URL + _url = kwargs.pop("template_url", "/providers/Microsoft.Maintenance/operations") -class Operations(object): - """Operations operations. + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class Operations: + """ + .. warning:: + **DO NOT** instantiate this class directly. - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`operations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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 """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationsListResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.OperationsListResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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( + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - 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( + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -96,17 +133,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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': '/providers/Microsoft.Maintenance/operations'} # type: ignore + list.metadata = {'url': "/providers/Microsoft.Maintenance/operations"} # type: ignore diff --git a/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_patch.py b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_patch.py new file mode 100644 index 000000000000..0ad201a8c586 --- /dev/null +++ b/sdk/maintenance/azure-mgmt-maintenance/azure/mgmt/maintenance/operations/_patch.py @@ -0,0 +1,19 @@ +# ------------------------------------ +# Copyright (c) Microsoft Corporation. +# Licensed under the MIT License. +# ------------------------------------ +"""Customize generated code here. + +Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize +""" +from typing import List + +__all__: List[str] = [] # Add all objects you want publicly available to users at this package level + +def patch_sdk(): + """Do not remove from this file. + + `patch_sdk` is a last resort escape hatch that allows you to do customizations + you can't accomplish using the techniques described in + https://aka.ms/azsdk/python/dpcodegen/python/customize + """ diff --git a/sdk/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..386b400933e4 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,93 +6,169 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + _url = _format_url_section(_url, **path_format_arguments) + + # Construct parameters + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}") # pylint: disable=line-too-long + 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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class PublicMaintenanceConfigurationsOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class PublicMaintenanceConfigurationsOperations(object): - """PublicMaintenanceConfigurationsOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`public_maintenance_configurations` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListMaintenanceConfigurationsResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -100,27 +177,32 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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 + 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. @@ -132,37 +214,39 @@ def get( :rtype: ~azure.mgmt.maintenance.models.MaintenanceConfiguration :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.MaintenanceConfiguration"] error_map = { 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') + error_map.update(kwargs.pop('error_map', {}) or {}) + + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.MaintenanceConfiguration] + + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_name=resource_name, + api_version=api_version, + template_url=self.get.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore - request = self._client.get(url, query_parameters, header_parameters) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # type: ignore # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) response = pipeline_response.http_response if response.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 +255,6 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized - get.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Maintenance/publicMaintenanceConfigurations/{resourceName}'} # type: ignore + + 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..1d53ee287ad3 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 @@ -1,3 +1,4 @@ +# pylint: disable=too-many-lines # coding=utf-8 # -------------------------------------------------------------------------- # Copyright (c) Microsoft Corporation. All rights reserved. @@ -5,57 +6,143 @@ # 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 warnings +from typing import Any, Callable, Dict, Iterable, Optional, TypeVar + +from msrest import Serializer 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.core.utils import case_insensitive_dict from azure.mgmt.core.exceptions import ARMErrorFormat from .. import models as _models +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: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceParentType}/{resourceParentName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + + +def build_list_request( + subscription_id: str, + resource_group_name: str, + provider_name: str, + resource_type: str, + resource_name: str, + **kwargs: Any +) -> HttpRequest: + _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {}) + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + accept = _headers.pop('Accept', "application/json") + + # Construct URL + _url = kwargs.pop("template_url", "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates") # pylint: disable=line-too-long + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "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 + _params['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + _headers['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=_url, + params=_params, + headers=_headers, + **kwargs + ) + +class UpdatesOperations: + """ + .. warning:: + **DO NOT** instantiate this class directly. -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]] - -class UpdatesOperations(object): - """UpdatesOperations operations. - - You should not instantiate this class directly. Instead, you should create a Client instance that - instantiates it for you and attaches it as an attribute. - - :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.mgmt.maintenance.models - :param client: Client for service requests. - :param config: Configuration of service client. - :param serializer: An object model serializer. - :param deserializer: An object model deserializer. + Instead, you should access the following operations through + :class:`~azure.mgmt.maintenance.MaintenanceManagementClient`'s + :attr:`updates` attribute. """ models = _models - def __init__(self, client, config, serializer, deserializer): - self._client = client - self._serialize = serializer - self._deserialize = deserializer - self._config = config + def __init__(self, *args, **kwargs): + input_args = list(args) + self._client = input_args.pop(0) if input_args else kwargs.pop("client") + self._config = input_args.pop(0) if input_args else kwargs.pop("config") + self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer") + self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer") + + @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. @@ -77,45 +164,57 @@ def list_parent( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListUpdatesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUpdatesResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUpdatesResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list_parent.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -124,30 +223,35 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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 + 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. @@ -165,43 +269,53 @@ def list( :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.maintenance.models.ListUpdatesResult] :raises: ~azure.core.exceptions.HttpResponseError """ - cls = kwargs.pop('cls', None) # type: ClsType["_models.ListUpdatesResult"] + _headers = kwargs.pop("headers", {}) or {} + _params = case_insensitive_dict(kwargs.pop("params", {}) or {}) + + api_version = kwargs.pop('api_version', _params.pop('api-version', "2022-07-01-preview")) # type: str + cls = kwargs.pop('cls', None) # type: ClsType[_models.ListUpdatesResult] + error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } - error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-09-01-preview" - accept = "application/json" - + error_map.update(kwargs.pop('error_map', {}) or {}) 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, + api_version=api_version, + template_url=self.list.metadata['url'], + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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, + api_version=api_version, + template_url=next_link, + headers=_headers, + params=_params, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) # type: ignore + 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) @@ -210,17 +324,22 @@ def extract_data(pipeline_response): def get_next(next_link=None): request = prepare_request(next_link) - pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + pipeline_response = self._client._pipeline.run( # pylint: disable=protected-access + request, + stream=False, + **kwargs + ) 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}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates'} # type: ignore + list.metadata = {'url': "/subscriptions/{subscriptionId}/resourcegroups/{resourceGroupName}/providers/{providerName}/{resourceType}/{resourceName}/providers/Microsoft.Maintenance/updates"} # type: ignore