diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json b/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json index 8f69f4c433ac..6d26ac8f0e78 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.2", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.1", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "8816b8568ee46dae94967bfadb97e19301604667", + "commit": "c7e0bbd2eae063ca701b000d99b68f729a54543c", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/resourcehealth/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.1 --use=@autorest/modelerfour@4.19.2 --version=3.4.2", + "autorest_command": "autorest specification/resourcehealth/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --python3-only --track2 --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/resourcehealth/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_configuration.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_configuration.py index aa6e986be91f..0b73b7705009 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_configuration.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION @@ -68,4 +68,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_microsoft_resource_health.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_microsoft_resource_health.py index fa9ec9d491ae..99ee420e99d5 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_microsoft_resource_health.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/_microsoft_resource_health.py @@ -23,7 +23,6 @@ from typing import Any, Optional from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse class _SDKClient(object): def __init__(self, *args, **kwargs): @@ -69,12 +68,10 @@ def __init__( credential, # type: "TokenCredential" subscription_id, # type: str api_version=None, # type: Optional[str] - base_url=None, # type: Optional[str] + base_url="https://management.azure.com", # type: str profile=KnownProfiles.default, # type: KnownProfiles **kwargs # type: Any ): - if not base_url: - base_url = 'https://management.azure.com' self._config = MicrosoftResourceHealthConfiguration(credential, subscription_id, **kwargs) self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(MicrosoftResourceHealth, self).__init__( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_configuration.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_configuration.py index 977710df23ce..678ec022cbb7 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_configuration.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_configuration.py @@ -12,7 +12,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_microsoft_resource_health.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_microsoft_resource_health.py index 186f57a8a753..bb93c90918f1 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_microsoft_resource_health.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/aio/_microsoft_resource_health.py @@ -11,7 +11,6 @@ from typing import Any, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from azure.profiles import KnownProfiles, ProfileDefinition from azure.profiles.multiapiclient import MultiApiClientMixin @@ -21,6 +20,7 @@ if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports + from azure.core.credentials import TokenCredential from azure.core.credentials_async import AsyncTokenCredential class _SDKClient(object): @@ -67,12 +67,10 @@ def __init__( credential: "AsyncTokenCredential", subscription_id: str, api_version: Optional[str] = None, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", profile: KnownProfiles = KnownProfiles.default, **kwargs # type: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' self._config = MicrosoftResourceHealthConfiguration(credential, subscription_id, **kwargs) self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) super(MicrosoftResourceHealth, self).__init__( diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/__init__.py index 5fd5e46488bd..2e70d24a50b1 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/__init__.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['MicrosoftResourceHealth'] -try: - from ._patch import patch_sdk # type: ignore - patch_sdk() -except ImportError: - pass +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_configuration.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_configuration.py index dbd14312fbba..ec260ee7a9c2 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_configuration.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,16 +33,15 @@ class MicrosoftResourceHealthConfiguration(Configuration): def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + credential: "TokenCredential", + subscription_id: str, + **kwargs: Any + ) -> None: + super(MicrosoftResourceHealthConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(MicrosoftResourceHealthConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_metadata.json b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_metadata.json index 1257297688dc..a9d3d5e80835 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_metadata.json +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_metadata.json @@ -5,13 +5,13 @@ "name": "MicrosoftResourceHealth", "filename": "_microsoft_resource_health", "description": "The Resource Health Client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftResourceHealthConfiguration\"]}}, \"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\": [\"MicrosoftResourceHealthConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}, \"azurecore\": {\"azure.core.pipeline.transport\": [\"AsyncHttpResponse\", \"HttpRequest\"]}}}" + "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftResourceHealthConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}", + "async_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"], \"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"AsyncARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"MicrosoftResourceHealthConfiguration\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\", \"Optional\"]}}}" }, "global_parameters": { "sync": { @@ -54,7 +54,7 @@ "required": false }, "base_url": { - "signature": "base_url=None, # type: Optional[str]", + "signature": "base_url=\"https://management.azure.com\", # type: str", "description": "Service URL", "docstring_type": "str", "required": false @@ -74,7 +74,7 @@ "required": false }, "base_url": { - "signature": "base_url: Optional[str] = None,", + "signature": "base_url: str = \"https://management.azure.com\",", "description": "Service URL", "docstring_type": "str", "required": false @@ -91,11 +91,10 @@ "config": { "credential": true, "credential_scopes": ["https://management.azure.com/.default"], - "credential_default_policy_type": "BearerTokenCredentialPolicy", - "credential_default_policy_type_has_async_version": true, - "credential_key_header_name": null, - "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", - "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" + "credential_call_sync": "ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "credential_call_async": "AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs)", + "sync_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMChallengeAuthenticationPolicy\", \"ARMHttpLoggingPolicy\"]}, \"local\": {\"._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}}", + "async_imports": "{\"regular\": {\"azurecore\": {\"azure.core.configuration\": [\"Configuration\"], \"azure.core.pipeline\": [\"policies\"], \"azure.mgmt.core.policies\": [\"ARMHttpLoggingPolicy\", \"AsyncARMChallengeAuthenticationPolicy\"]}, \"local\": {\".._version\": [\"VERSION\"]}}, \"conditional\": {\"stdlib\": {\"typing\": [\"Any\"]}}, \"typing\": {\"azurecore\": {\"azure.core.credentials_async\": [\"AsyncTokenCredential\"]}}}" }, "operation_groups": { "availability_statuses": "AvailabilityStatusesOperations", diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_microsoft_resource_health.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_microsoft_resource_health.py index 147fc7e722e9..689c747439aa 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_microsoft_resource_health.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_microsoft_resource_health.py @@ -6,88 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from copy import deepcopy +from typing import Any, Optional, TYPE_CHECKING +from azure.core.rest import HttpRequest, HttpResponse from azure.mgmt.core import ARMPipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import MicrosoftResourceHealthConfiguration +from .operations import AvailabilityStatusesOperations, ChildAvailabilityStatusesOperations, ChildResourcesOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Optional - from azure.core.credentials import TokenCredential - from azure.core.pipeline.transport import HttpRequest, HttpResponse - -from ._configuration import MicrosoftResourceHealthConfiguration -from .operations import AvailabilityStatusesOperations -from .operations import ChildAvailabilityStatusesOperations -from .operations import ChildResourcesOperations -from .operations import Operations -from . import models - -class MicrosoftResourceHealth(object): +class MicrosoftResourceHealth: """The Resource Health Client. :ivar availability_statuses: AvailabilityStatusesOperations operations - :vartype availability_statuses: azure.mgmt.resourcehealth.v2015_01_01.operations.AvailabilityStatusesOperations + :vartype availability_statuses: + azure.mgmt.resourcehealth.v2015_01_01.operations.AvailabilityStatusesOperations :ivar child_availability_statuses: ChildAvailabilityStatusesOperations operations - :vartype child_availability_statuses: azure.mgmt.resourcehealth.v2015_01_01.operations.ChildAvailabilityStatusesOperations + :vartype child_availability_statuses: + azure.mgmt.resourcehealth.v2015_01_01.operations.ChildAvailabilityStatusesOperations :ivar child_resources: ChildResourcesOperations operations - :vartype child_resources: azure.mgmt.resourcehealth.v2015_01_01.operations.ChildResourcesOperations + :vartype child_resources: + azure.mgmt.resourcehealth.v2015_01_01.operations.ChildResourcesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.resourcehealth.v2015_01_01.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = MicrosoftResourceHealthConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = MicrosoftResourceHealthConfiguration(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.availability_statuses = AvailabilityStatusesOperations(self._client, self._config, self._serialize, self._deserialize) + self.child_availability_statuses = ChildAvailabilityStatusesOperations(self._client, self._config, self._serialize, self._deserialize) + self.child_resources = ChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.child_availability_statuses = ChildAvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.child_resources = ChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_patch.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_vendor.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/_vendor.py @@ -0,0 +1,27 @@ +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is regenerated. +# -------------------------------------------------------------------------- + +from azure.core.pipeline.transport import HttpRequest + +def _convert_request(request, files=None): + data = request.content if not files else None + request = HttpRequest(method=request.method, url=request.url, headers=request.headers, data=data) + if files: + request.set_formdata_body(files) + return request + +def _format_url_section(template, **kwargs): + components = template.split("/") + while components: + try: + return template.format(**kwargs) + except KeyError as key: + formatted_components = template.split("/") + components = [ + c for c in formatted_components if "{}".format(key.args[0]) not in c + ] + template = "/".join(components) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/__init__.py index 0333edd9e09f..97f470f4cda8 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/__init__.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/__init__.py @@ -8,3 +8,8 @@ from ._microsoft_resource_health import MicrosoftResourceHealth __all__ = ['MicrosoftResourceHealth'] + +# `._patch.py` is used for handwritten extensions to the generated code +# Example: https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +from ._patch import patch_sdk +patch_sdk() diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_configuration.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_configuration.py index 0310721e5f29..c48dbf95ca23 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_configuration.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,11 +37,11 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(MicrosoftResourceHealthConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: raise ValueError("Parameter 'subscription_id' must not be None.") - super(MicrosoftResourceHealthConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_microsoft_resource_health.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_microsoft_resource_health.py index f3b66cc1dfc2..c8c0dcba29a0 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_microsoft_resource_health.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_microsoft_resource_health.py @@ -6,84 +6,89 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Optional, TYPE_CHECKING +from copy import deepcopy +from typing import Any, Awaitable, Optional, TYPE_CHECKING -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.rest import AsyncHttpResponse, HttpRequest from azure.mgmt.core import AsyncARMPipelineClient from msrest import Deserializer, Serializer +from .. import models +from ._configuration import MicrosoftResourceHealthConfiguration +from .operations import AvailabilityStatusesOperations, ChildAvailabilityStatusesOperations, ChildResourcesOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import MicrosoftResourceHealthConfiguration -from .operations import AvailabilityStatusesOperations -from .operations import ChildAvailabilityStatusesOperations -from .operations import ChildResourcesOperations -from .operations import Operations -from .. import models - - -class MicrosoftResourceHealth(object): +class MicrosoftResourceHealth: """The Resource Health Client. :ivar availability_statuses: AvailabilityStatusesOperations operations - :vartype availability_statuses: azure.mgmt.resourcehealth.v2015_01_01.aio.operations.AvailabilityStatusesOperations + :vartype availability_statuses: + azure.mgmt.resourcehealth.v2015_01_01.aio.operations.AvailabilityStatusesOperations :ivar child_availability_statuses: ChildAvailabilityStatusesOperations operations - :vartype child_availability_statuses: azure.mgmt.resourcehealth.v2015_01_01.aio.operations.ChildAvailabilityStatusesOperations + :vartype child_availability_statuses: + azure.mgmt.resourcehealth.v2015_01_01.aio.operations.ChildAvailabilityStatusesOperations :ivar child_resources: ChildResourcesOperations operations - :vartype child_resources: azure.mgmt.resourcehealth.v2015_01_01.aio.operations.ChildResourcesOperations + :vartype child_resources: + azure.mgmt.resourcehealth.v2015_01_01.aio.operations.ChildResourcesOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.resourcehealth.v2015_01_01.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential - :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure subscription. The subscription ID forms part of the URI for every service call. + :param subscription_id: Subscription credentials which uniquely identify Microsoft Azure + subscription. The subscription ID forms part of the URI for every service call. :type subscription_id: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = MicrosoftResourceHealthConfiguration(credential, subscription_id, **kwargs) + self._config = MicrosoftResourceHealthConfiguration(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.availability_statuses = AvailabilityStatusesOperations(self._client, self._config, self._serialize, self._deserialize) + self.child_availability_statuses = ChildAvailabilityStatusesOperations(self._client, self._config, self._serialize, self._deserialize) + self.child_resources = ChildResourcesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.availability_statuses = AvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.child_availability_statuses = ChildAvailabilityStatusesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.child_resources = ChildResourcesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - 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/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_patch.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/_patch.py @@ -0,0 +1,31 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# +# Copyright (c) Microsoft Corporation. All rights reserved. +# +# The MIT License (MIT) +# +# Permission is hereby granted, free of charge, to any person obtaining a copy +# of this software and associated documentation files (the ""Software""), to +# deal in the Software without restriction, including without limitation the +# rights to use, copy, modify, merge, publish, distribute, sublicense, and/or +# sell copies of the Software, and to permit persons to whom the Software is +# furnished to do so, subject to the following conditions: +# +# The above copyright notice and this permission notice shall be included in +# all copies or substantial portions of the Software. +# +# THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR +# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, +# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE +# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER +# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING +# FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS +# IN THE SOFTWARE. +# +# -------------------------------------------------------------------------- + +# This file is used for handwritten extensions to the generated code. Example: +# https://github.com/Azure/azure-sdk-for-python/blob/main/doc/dev/customize_code/how-to-patch-sdk-code.md +def patch_sdk(): + pass \ No newline at end of file diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py index 9aa9ad2e1c9a..a8d26facaac0 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_availability_statuses_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._availability_statuses_operations import build_get_by_resource_request, build_list_by_resource_group_request, build_list_by_subscription_id_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription_id( self, filter: Optional[str] = None, @@ -57,8 +63,10 @@ def list_by_subscription_id( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -66,38 +74,33 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription_id.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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + template_url=self.list_by_subscription_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -110,17 +113,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_subscription_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/availabilityStatuses'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -140,8 +145,10 @@ def list_by_resource_group( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -149,39 +156,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + expand=expand, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -194,17 +197,19 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceHealth/availabilityStatuses'} # type: ignore + @distributed_trace_async async def get_by_resource( self, resource_uri: str, @@ -236,35 +241,23 @@ async def get_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - # Construct URL - url = self.get_by_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.get_by_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AvailabilityStatus', pipeline_response) @@ -273,8 +266,11 @@ async def get_by_resource( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource.metadata = {'url': '/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses/current'} # type: ignore + + @distributed_trace def list( self, resource_uri: str, @@ -298,8 +294,10 @@ def list( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -307,38 +305,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -351,12 +344,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py index 842b10e3c9bf..0633c95739c7 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_availability_statuses_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._child_availability_statuses_operations import build_get_by_resource_request, build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get_by_resource( self, resource_uri: str, @@ -70,35 +76,23 @@ async def get_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - - # Construct URL - url = self.get_by_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.get_by_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AvailabilityStatus', pipeline_response) @@ -107,8 +101,11 @@ async def get_by_resource( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource.metadata = {'url': '/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses/current'} # type: ignore + + @distributed_trace def list( self, resource_uri: str, @@ -130,8 +127,10 @@ def list( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -139,38 +138,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -183,12 +177,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py index 28f9e67cace2..1e9405f44d2d 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_child_resources_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._child_resources_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, resource_uri: str, @@ -62,8 +68,10 @@ def list( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -71,38 +79,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,12 +118,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py index 8716fc3ee045..23c17020e5da 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/aio/operations/_operations.py @@ -5,16 +5,20 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -40,6 +44,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def list( self, **kwargs: Any @@ -56,27 +61,20 @@ async def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - - # 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') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('OperationListResult', pipeline_response) @@ -85,4 +83,6 @@ async def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.ResourceHealth/operations'} # type: ignore + diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/__init__.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/__init__.py index 709646a61bf1..0345d19f1524 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/__init__.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/__init__.py @@ -6,32 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AvailabilityStatus - from ._models_py3 import AvailabilityStatusListResult - from ._models_py3 import AvailabilityStatusProperties - from ._models_py3 import AvailabilityStatusPropertiesRecentlyResolvedState - from ._models_py3 import ErrorResponse - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationListResult - from ._models_py3 import RecommendedAction - from ._models_py3 import ServiceImpactingEvent - from ._models_py3 import ServiceImpactingEventIncidentProperties - from ._models_py3 import ServiceImpactingEventStatus -except (SyntaxError, ImportError): - from ._models import AvailabilityStatus # type: ignore - from ._models import AvailabilityStatusListResult # type: ignore - from ._models import AvailabilityStatusProperties # type: ignore - from ._models import AvailabilityStatusPropertiesRecentlyResolvedState # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationListResult # type: ignore - from ._models import RecommendedAction # type: ignore - from ._models import ServiceImpactingEvent # type: ignore - from ._models import ServiceImpactingEventIncidentProperties # type: ignore - from ._models import ServiceImpactingEventStatus # type: ignore +from ._models_py3 import AvailabilityStatus +from ._models_py3 import AvailabilityStatusListResult +from ._models_py3 import AvailabilityStatusProperties +from ._models_py3 import AvailabilityStatusPropertiesRecentlyResolvedState +from ._models_py3 import ErrorResponse +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationListResult +from ._models_py3 import RecommendedAction +from ._models_py3 import ServiceImpactingEvent +from ._models_py3 import ServiceImpactingEventIncidentProperties +from ._models_py3 import ServiceImpactingEventStatus + from ._microsoft_resource_health_enums import ( AvailabilityStateValues, diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_microsoft_resource_health_enums.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_microsoft_resource_health_enums.py index 0b33432ea906..fa9328ba4abe 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_microsoft_resource_health_enums.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_microsoft_resource_health_enums.py @@ -6,27 +6,12 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class AvailabilityStateValues(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AvailabilityStateValues(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Availability status of the resource. """ @@ -34,7 +19,7 @@ class AvailabilityStateValues(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum UNAVAILABLE = "Unavailable" UNKNOWN = "Unknown" -class ReasonChronicityTypes(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ReasonChronicityTypes(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Chronicity of the availability transition. """ diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_models.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_models.py deleted file mode 100644 index f0383944cc15..000000000000 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_models.py +++ /dev/null @@ -1,413 +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 AvailabilityStatus(msrest.serialization.Model): - """availabilityStatus of a resource. - - :param id: Azure Resource Manager Identity for the availabilityStatuses resource. - :type id: str - :param name: current. - :type name: str - :param type: Microsoft.ResourceHealth/AvailabilityStatuses. - :type type: str - :param location: Azure Resource Manager geo location of the resource. - :type location: str - :param properties: Properties of availability state. - :type properties: ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusProperties - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'location': {'key': 'location', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'AvailabilityStatusProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailabilityStatus, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.type = kwargs.get('type', None) - self.location = kwargs.get('location', None) - self.properties = kwargs.get('properties', None) - - -class AvailabilityStatusListResult(msrest.serialization.Model): - """The List availabilityStatus operation response. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. The list of availabilityStatuses. - :type value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatus] - :param next_link: The URI to fetch the next page of availabilityStatuses. Call ListNext() with - this URI to fetch the next page of availabilityStatuses. - :type next_link: str - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AvailabilityStatus]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailabilityStatusListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - self.next_link = kwargs.get('next_link', None) - - -class AvailabilityStatusProperties(msrest.serialization.Model): - """Properties of availability state. - - :param availability_state: Availability status of the resource. Possible values include: - "Available", "Unavailable", "Unknown". - :type availability_state: str or - ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStateValues - :param summary: Summary description of the availability state. - :type summary: str - :param detailed_status: Details of the availability status. - :type detailed_status: str - :param reason_type: When the resource's availabilityState is Unavailable, it describes where - the health impacting event was originated. Examples are planned, unplanned, user initiated or - an outage etc. - :type reason_type: str - :param root_cause_attribution_time: When the resource's availabilityState is Unavailable, it - provides the Timestamp for when the health impacting event was received. - :type root_cause_attribution_time: ~datetime.datetime - :param resolution_eta: When the resource's availabilityState is Unavailable and the reasonType - is not User Initiated, it provides the date and time for when the issue is expected to be - resolved. - :type resolution_eta: ~datetime.datetime - :param occured_time: Timestamp for when last change in health status occurred. - :type occured_time: ~datetime.datetime - :param reason_chronicity: Chronicity of the availability transition. Possible values include: - "Transient", "Persistent". - :type reason_chronicity: str or - ~azure.mgmt.resourcehealth.v2015_01_01.models.ReasonChronicityTypes - :param reported_time: Timestamp for when the health was last checked. - :type reported_time: ~datetime.datetime - :param is_arm_resource: flag to show if child resource need detail health. - :type is_arm_resource: bool - :param recently_resolved_state: An annotation describing a change in the availabilityState to - Available from Unavailable with a reasonType of type Unplanned. - :type recently_resolved_state: - ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusPropertiesRecentlyResolvedState - :param recommended_actions: Lists actions the user can take based on the current - availabilityState of the resource. - :type recommended_actions: - list[~azure.mgmt.resourcehealth.v2015_01_01.models.RecommendedAction] - :param service_impacting_events: Lists the service impacting events that may be affecting the - health of the resource. - :type service_impacting_events: - list[~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEvent] - """ - - _attribute_map = { - 'availability_state': {'key': 'availabilityState', 'type': 'str'}, - 'summary': {'key': 'summary', 'type': 'str'}, - 'detailed_status': {'key': 'detailedStatus', 'type': 'str'}, - 'reason_type': {'key': 'reasonType', 'type': 'str'}, - 'root_cause_attribution_time': {'key': 'rootCauseAttributionTime', 'type': 'iso-8601'}, - 'resolution_eta': {'key': 'resolutionETA', 'type': 'iso-8601'}, - 'occured_time': {'key': 'occuredTime', 'type': 'iso-8601'}, - 'reason_chronicity': {'key': 'reasonChronicity', 'type': 'str'}, - 'reported_time': {'key': 'reportedTime', 'type': 'iso-8601'}, - 'is_arm_resource': {'key': 'isArmResource', 'type': 'bool'}, - 'recently_resolved_state': {'key': 'recentlyResolvedState', 'type': 'AvailabilityStatusPropertiesRecentlyResolvedState'}, - 'recommended_actions': {'key': 'recommendedActions', 'type': '[RecommendedAction]'}, - 'service_impacting_events': {'key': 'serviceImpactingEvents', 'type': '[ServiceImpactingEvent]'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailabilityStatusProperties, self).__init__(**kwargs) - self.availability_state = kwargs.get('availability_state', None) - self.summary = kwargs.get('summary', None) - self.detailed_status = kwargs.get('detailed_status', None) - self.reason_type = kwargs.get('reason_type', None) - self.root_cause_attribution_time = kwargs.get('root_cause_attribution_time', None) - self.resolution_eta = kwargs.get('resolution_eta', None) - self.occured_time = kwargs.get('occured_time', None) - self.reason_chronicity = kwargs.get('reason_chronicity', None) - self.reported_time = kwargs.get('reported_time', None) - self.is_arm_resource = kwargs.get('is_arm_resource', None) - self.recently_resolved_state = kwargs.get('recently_resolved_state', None) - self.recommended_actions = kwargs.get('recommended_actions', None) - self.service_impacting_events = kwargs.get('service_impacting_events', None) - - -class AvailabilityStatusPropertiesRecentlyResolvedState(msrest.serialization.Model): - """An annotation describing a change in the availabilityState to Available from Unavailable with a reasonType of type Unplanned. - - :param unavailable_occurred_time: Timestamp for when the availabilityState changed to - Unavailable. - :type unavailable_occurred_time: ~datetime.datetime - :param resolved_time: Timestamp when the availabilityState changes to Available. - :type resolved_time: ~datetime.datetime - :param unavailability_summary: Brief description of cause of the resource becoming unavailable. - :type unavailability_summary: str - """ - - _attribute_map = { - 'unavailable_occurred_time': {'key': 'unavailableOccurredTime', 'type': 'iso-8601'}, - 'resolved_time': {'key': 'resolvedTime', 'type': 'iso-8601'}, - 'unavailability_summary': {'key': 'unavailabilitySummary', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AvailabilityStatusPropertiesRecentlyResolvedState, self).__init__(**kwargs) - self.unavailable_occurred_time = kwargs.get('unavailable_occurred_time', None) - self.resolved_time = kwargs.get('resolved_time', None) - self.unavailability_summary = kwargs.get('unavailability_summary', None) - - -class ErrorResponse(msrest.serialization.Model): - """Error details. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar details: The error details. - :vartype details: str - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'details': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'details': {'key': 'details', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class Operation(msrest.serialization.Model): - """Operation available in the resourcehealth resource provider. - - :param name: Name of the operation. - :type name: str - :param display: Properties of the operation. - :type display: ~azure.mgmt.resourcehealth.v2015_01_01.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """Properties of the operation. - - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :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(OperationDisplay, 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 OperationListResult(msrest.serialization.Model): - """Lists the operations response. - - All required parameters must be populated in order to send to Azure. - - :param value: Required. List of operations available in the resourcehealth resource provider. - :type value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.Operation] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationListResult, self).__init__(**kwargs) - self.value = kwargs['value'] - - -class RecommendedAction(msrest.serialization.Model): - """Lists actions the user can take based on the current availabilityState of the resource. - - :param action: Recommended action. - :type action: str - :param action_url: Link to the action. - :type action_url: str - :param action_url_text: Substring of action, it describes which text should host the action - url. - :type action_url_text: str - """ - - _attribute_map = { - 'action': {'key': 'action', 'type': 'str'}, - 'action_url': {'key': 'actionUrl', 'type': 'str'}, - 'action_url_text': {'key': 'actionUrlText', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(RecommendedAction, self).__init__(**kwargs) - self.action = kwargs.get('action', None) - self.action_url = kwargs.get('action_url', None) - self.action_url_text = kwargs.get('action_url_text', None) - - -class ServiceImpactingEvent(msrest.serialization.Model): - """Lists the service impacting events that may be affecting the health of the resource. - - :param event_start_time: Timestamp for when the event started. - :type event_start_time: ~datetime.datetime - :param event_status_last_modified_time: Timestamp for when event was submitted/detected. - :type event_status_last_modified_time: ~datetime.datetime - :param correlation_id: Correlation id for the event. - :type correlation_id: str - :param status: Status of the service impacting event. - :type status: ~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEventStatus - :param incident_properties: Properties of the service impacting event. - :type incident_properties: - ~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEventIncidentProperties - """ - - _attribute_map = { - 'event_start_time': {'key': 'eventStartTime', 'type': 'iso-8601'}, - 'event_status_last_modified_time': {'key': 'eventStatusLastModifiedTime', 'type': 'iso-8601'}, - 'correlation_id': {'key': 'correlationId', 'type': 'str'}, - 'status': {'key': 'status', 'type': 'ServiceImpactingEventStatus'}, - 'incident_properties': {'key': 'incidentProperties', 'type': 'ServiceImpactingEventIncidentProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceImpactingEvent, self).__init__(**kwargs) - self.event_start_time = kwargs.get('event_start_time', None) - self.event_status_last_modified_time = kwargs.get('event_status_last_modified_time', None) - self.correlation_id = kwargs.get('correlation_id', None) - self.status = kwargs.get('status', None) - self.incident_properties = kwargs.get('incident_properties', None) - - -class ServiceImpactingEventIncidentProperties(msrest.serialization.Model): - """Properties of the service impacting event. - - :param title: Title of the incident. - :type title: str - :param service: Service impacted by the event. - :type service: str - :param region: Region impacted by the event. - :type region: str - :param incident_type: Type of Event. - :type incident_type: str - """ - - _attribute_map = { - 'title': {'key': 'title', 'type': 'str'}, - 'service': {'key': 'service', 'type': 'str'}, - 'region': {'key': 'region', 'type': 'str'}, - 'incident_type': {'key': 'incidentType', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceImpactingEventIncidentProperties, self).__init__(**kwargs) - self.title = kwargs.get('title', None) - self.service = kwargs.get('service', None) - self.region = kwargs.get('region', None) - self.incident_type = kwargs.get('incident_type', None) - - -class ServiceImpactingEventStatus(msrest.serialization.Model): - """Status of the service impacting event. - - :param value: Current status of the event. - :type value: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ServiceImpactingEventStatus, self).__init__(**kwargs) - self.value = kwargs.get('value', None) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_models_py3.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_models_py3.py index 605799e7971e..34559f77526c 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_models_py3.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/models/_models_py3.py @@ -18,16 +18,16 @@ class AvailabilityStatus(msrest.serialization.Model): """availabilityStatus of a resource. - :param id: Azure Resource Manager Identity for the availabilityStatuses resource. - :type id: str - :param name: current. - :type name: str - :param type: Microsoft.ResourceHealth/AvailabilityStatuses. - :type type: str - :param location: Azure Resource Manager geo location of the resource. - :type location: str - :param properties: Properties of availability state. - :type properties: ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusProperties + :ivar id: Azure Resource Manager Identity for the availabilityStatuses resource. + :vartype id: str + :ivar name: current. + :vartype name: str + :ivar type: Microsoft.ResourceHealth/AvailabilityStatuses. + :vartype type: str + :ivar location: Azure Resource Manager geo location of the resource. + :vartype location: str + :ivar properties: Properties of availability state. + :vartype properties: ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusProperties """ _attribute_map = { @@ -48,6 +48,19 @@ def __init__( properties: Optional["AvailabilityStatusProperties"] = None, **kwargs ): + """ + :keyword id: Azure Resource Manager Identity for the availabilityStatuses resource. + :paramtype id: str + :keyword name: current. + :paramtype name: str + :keyword type: Microsoft.ResourceHealth/AvailabilityStatuses. + :paramtype type: str + :keyword location: Azure Resource Manager geo location of the resource. + :paramtype location: str + :keyword properties: Properties of availability state. + :paramtype properties: + ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusProperties + """ super(AvailabilityStatus, self).__init__(**kwargs) self.id = id self.name = name @@ -61,11 +74,11 @@ class AvailabilityStatusListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. The list of availabilityStatuses. - :type value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatus] - :param next_link: The URI to fetch the next page of availabilityStatuses. Call ListNext() with + :ivar value: Required. The list of availabilityStatuses. + :vartype value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatus] + :ivar next_link: The URI to fetch the next page of availabilityStatuses. Call ListNext() with this URI to fetch the next page of availabilityStatuses. - :type next_link: str + :vartype next_link: str """ _validation = { @@ -84,6 +97,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Required. The list of availabilityStatuses. + :paramtype value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatus] + :keyword next_link: The URI to fetch the next page of availabilityStatuses. Call ListNext() + with this URI to fetch the next page of availabilityStatuses. + :paramtype next_link: str + """ super(AvailabilityStatusListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -92,46 +112,46 @@ def __init__( class AvailabilityStatusProperties(msrest.serialization.Model): """Properties of availability state. - :param availability_state: Availability status of the resource. Possible values include: + :ivar availability_state: Availability status of the resource. Possible values include: "Available", "Unavailable", "Unknown". - :type availability_state: str or + :vartype availability_state: str or ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStateValues - :param summary: Summary description of the availability state. - :type summary: str - :param detailed_status: Details of the availability status. - :type detailed_status: str - :param reason_type: When the resource's availabilityState is Unavailable, it describes where - the health impacting event was originated. Examples are planned, unplanned, user initiated or - an outage etc. - :type reason_type: str - :param root_cause_attribution_time: When the resource's availabilityState is Unavailable, it + :ivar summary: Summary description of the availability state. + :vartype summary: str + :ivar detailed_status: Details of the availability status. + :vartype detailed_status: str + :ivar reason_type: When the resource's availabilityState is Unavailable, it describes where the + health impacting event was originated. Examples are planned, unplanned, user initiated or an + outage etc. + :vartype reason_type: str + :ivar root_cause_attribution_time: When the resource's availabilityState is Unavailable, it provides the Timestamp for when the health impacting event was received. - :type root_cause_attribution_time: ~datetime.datetime - :param resolution_eta: When the resource's availabilityState is Unavailable and the reasonType + :vartype root_cause_attribution_time: ~datetime.datetime + :ivar resolution_eta: When the resource's availabilityState is Unavailable and the reasonType is not User Initiated, it provides the date and time for when the issue is expected to be resolved. - :type resolution_eta: ~datetime.datetime - :param occured_time: Timestamp for when last change in health status occurred. - :type occured_time: ~datetime.datetime - :param reason_chronicity: Chronicity of the availability transition. Possible values include: + :vartype resolution_eta: ~datetime.datetime + :ivar occured_time: Timestamp for when last change in health status occurred. + :vartype occured_time: ~datetime.datetime + :ivar reason_chronicity: Chronicity of the availability transition. Possible values include: "Transient", "Persistent". - :type reason_chronicity: str or + :vartype reason_chronicity: str or ~azure.mgmt.resourcehealth.v2015_01_01.models.ReasonChronicityTypes - :param reported_time: Timestamp for when the health was last checked. - :type reported_time: ~datetime.datetime - :param is_arm_resource: flag to show if child resource need detail health. - :type is_arm_resource: bool - :param recently_resolved_state: An annotation describing a change in the availabilityState to + :ivar reported_time: Timestamp for when the health was last checked. + :vartype reported_time: ~datetime.datetime + :ivar is_arm_resource: flag to show if child resource need detail health. + :vartype is_arm_resource: bool + :ivar recently_resolved_state: An annotation describing a change in the availabilityState to Available from Unavailable with a reasonType of type Unplanned. - :type recently_resolved_state: + :vartype recently_resolved_state: ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusPropertiesRecentlyResolvedState - :param recommended_actions: Lists actions the user can take based on the current + :ivar recommended_actions: Lists actions the user can take based on the current availabilityState of the resource. - :type recommended_actions: + :vartype recommended_actions: list[~azure.mgmt.resourcehealth.v2015_01_01.models.RecommendedAction] - :param service_impacting_events: Lists the service impacting events that may be affecting the + :ivar service_impacting_events: Lists the service impacting events that may be affecting the health of the resource. - :type service_impacting_events: + :vartype service_impacting_events: list[~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEvent] """ @@ -169,6 +189,49 @@ def __init__( service_impacting_events: Optional[List["ServiceImpactingEvent"]] = None, **kwargs ): + """ + :keyword availability_state: Availability status of the resource. Possible values include: + "Available", "Unavailable", "Unknown". + :paramtype availability_state: str or + ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStateValues + :keyword summary: Summary description of the availability state. + :paramtype summary: str + :keyword detailed_status: Details of the availability status. + :paramtype detailed_status: str + :keyword reason_type: When the resource's availabilityState is Unavailable, it describes where + the health impacting event was originated. Examples are planned, unplanned, user initiated or + an outage etc. + :paramtype reason_type: str + :keyword root_cause_attribution_time: When the resource's availabilityState is Unavailable, it + provides the Timestamp for when the health impacting event was received. + :paramtype root_cause_attribution_time: ~datetime.datetime + :keyword resolution_eta: When the resource's availabilityState is Unavailable and the + reasonType is not User Initiated, it provides the date and time for when the issue is expected + to be resolved. + :paramtype resolution_eta: ~datetime.datetime + :keyword occured_time: Timestamp for when last change in health status occurred. + :paramtype occured_time: ~datetime.datetime + :keyword reason_chronicity: Chronicity of the availability transition. Possible values include: + "Transient", "Persistent". + :paramtype reason_chronicity: str or + ~azure.mgmt.resourcehealth.v2015_01_01.models.ReasonChronicityTypes + :keyword reported_time: Timestamp for when the health was last checked. + :paramtype reported_time: ~datetime.datetime + :keyword is_arm_resource: flag to show if child resource need detail health. + :paramtype is_arm_resource: bool + :keyword recently_resolved_state: An annotation describing a change in the availabilityState to + Available from Unavailable with a reasonType of type Unplanned. + :paramtype recently_resolved_state: + ~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusPropertiesRecentlyResolvedState + :keyword recommended_actions: Lists actions the user can take based on the current + availabilityState of the resource. + :paramtype recommended_actions: + list[~azure.mgmt.resourcehealth.v2015_01_01.models.RecommendedAction] + :keyword service_impacting_events: Lists the service impacting events that may be affecting the + health of the resource. + :paramtype service_impacting_events: + list[~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEvent] + """ super(AvailabilityStatusProperties, self).__init__(**kwargs) self.availability_state = availability_state self.summary = summary @@ -188,13 +251,13 @@ def __init__( class AvailabilityStatusPropertiesRecentlyResolvedState(msrest.serialization.Model): """An annotation describing a change in the availabilityState to Available from Unavailable with a reasonType of type Unplanned. - :param unavailable_occurred_time: Timestamp for when the availabilityState changed to + :ivar unavailable_occurred_time: Timestamp for when the availabilityState changed to Unavailable. - :type unavailable_occurred_time: ~datetime.datetime - :param resolved_time: Timestamp when the availabilityState changes to Available. - :type resolved_time: ~datetime.datetime - :param unavailability_summary: Brief description of cause of the resource becoming unavailable. - :type unavailability_summary: str + :vartype unavailable_occurred_time: ~datetime.datetime + :ivar resolved_time: Timestamp when the availabilityState changes to Available. + :vartype resolved_time: ~datetime.datetime + :ivar unavailability_summary: Brief description of cause of the resource becoming unavailable. + :vartype unavailability_summary: str """ _attribute_map = { @@ -211,6 +274,16 @@ def __init__( unavailability_summary: Optional[str] = None, **kwargs ): + """ + :keyword unavailable_occurred_time: Timestamp for when the availabilityState changed to + Unavailable. + :paramtype unavailable_occurred_time: ~datetime.datetime + :keyword resolved_time: Timestamp when the availabilityState changes to Available. + :paramtype resolved_time: ~datetime.datetime + :keyword unavailability_summary: Brief description of cause of the resource becoming + unavailable. + :paramtype unavailability_summary: str + """ super(AvailabilityStatusPropertiesRecentlyResolvedState, self).__init__(**kwargs) self.unavailable_occurred_time = unavailable_occurred_time self.resolved_time = resolved_time @@ -246,6 +319,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorResponse, self).__init__(**kwargs) self.code = None self.message = None @@ -255,10 +330,10 @@ def __init__( class Operation(msrest.serialization.Model): """Operation available in the resourcehealth resource provider. - :param name: Name of the operation. - :type name: str - :param display: Properties of the operation. - :type display: ~azure.mgmt.resourcehealth.v2015_01_01.models.OperationDisplay + :ivar name: Name of the operation. + :vartype name: str + :ivar display: Properties of the operation. + :vartype display: ~azure.mgmt.resourcehealth.v2015_01_01.models.OperationDisplay """ _attribute_map = { @@ -273,6 +348,12 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword display: Properties of the operation. + :paramtype display: ~azure.mgmt.resourcehealth.v2015_01_01.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.display = display @@ -281,14 +362,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Properties of the operation. - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: Resource name. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -307,6 +388,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: Resource name. + :paramtype resource: str + :keyword operation: Operation name. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -319,8 +410,8 @@ class OperationListResult(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param value: Required. List of operations available in the resourcehealth resource provider. - :type value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.Operation] + :ivar value: Required. List of operations available in the resourcehealth resource provider. + :vartype value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.Operation] """ _validation = { @@ -337,6 +428,10 @@ def __init__( value: List["Operation"], **kwargs ): + """ + :keyword value: Required. List of operations available in the resourcehealth resource provider. + :paramtype value: list[~azure.mgmt.resourcehealth.v2015_01_01.models.Operation] + """ super(OperationListResult, self).__init__(**kwargs) self.value = value @@ -344,13 +439,12 @@ def __init__( class RecommendedAction(msrest.serialization.Model): """Lists actions the user can take based on the current availabilityState of the resource. - :param action: Recommended action. - :type action: str - :param action_url: Link to the action. - :type action_url: str - :param action_url_text: Substring of action, it describes which text should host the action - url. - :type action_url_text: str + :ivar action: Recommended action. + :vartype action: str + :ivar action_url: Link to the action. + :vartype action_url: str + :ivar action_url_text: Substring of action, it describes which text should host the action url. + :vartype action_url_text: str """ _attribute_map = { @@ -367,6 +461,15 @@ def __init__( action_url_text: Optional[str] = None, **kwargs ): + """ + :keyword action: Recommended action. + :paramtype action: str + :keyword action_url: Link to the action. + :paramtype action_url: str + :keyword action_url_text: Substring of action, it describes which text should host the action + url. + :paramtype action_url_text: str + """ super(RecommendedAction, self).__init__(**kwargs) self.action = action self.action_url = action_url @@ -376,16 +479,16 @@ def __init__( class ServiceImpactingEvent(msrest.serialization.Model): """Lists the service impacting events that may be affecting the health of the resource. - :param event_start_time: Timestamp for when the event started. - :type event_start_time: ~datetime.datetime - :param event_status_last_modified_time: Timestamp for when event was submitted/detected. - :type event_status_last_modified_time: ~datetime.datetime - :param correlation_id: Correlation id for the event. - :type correlation_id: str - :param status: Status of the service impacting event. - :type status: ~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEventStatus - :param incident_properties: Properties of the service impacting event. - :type incident_properties: + :ivar event_start_time: Timestamp for when the event started. + :vartype event_start_time: ~datetime.datetime + :ivar event_status_last_modified_time: Timestamp for when event was submitted/detected. + :vartype event_status_last_modified_time: ~datetime.datetime + :ivar correlation_id: Correlation id for the event. + :vartype correlation_id: str + :ivar status: Status of the service impacting event. + :vartype status: ~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEventStatus + :ivar incident_properties: Properties of the service impacting event. + :vartype incident_properties: ~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEventIncidentProperties """ @@ -407,6 +510,19 @@ def __init__( incident_properties: Optional["ServiceImpactingEventIncidentProperties"] = None, **kwargs ): + """ + :keyword event_start_time: Timestamp for when the event started. + :paramtype event_start_time: ~datetime.datetime + :keyword event_status_last_modified_time: Timestamp for when event was submitted/detected. + :paramtype event_status_last_modified_time: ~datetime.datetime + :keyword correlation_id: Correlation id for the event. + :paramtype correlation_id: str + :keyword status: Status of the service impacting event. + :paramtype status: ~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEventStatus + :keyword incident_properties: Properties of the service impacting event. + :paramtype incident_properties: + ~azure.mgmt.resourcehealth.v2015_01_01.models.ServiceImpactingEventIncidentProperties + """ super(ServiceImpactingEvent, self).__init__(**kwargs) self.event_start_time = event_start_time self.event_status_last_modified_time = event_status_last_modified_time @@ -418,14 +534,14 @@ def __init__( class ServiceImpactingEventIncidentProperties(msrest.serialization.Model): """Properties of the service impacting event. - :param title: Title of the incident. - :type title: str - :param service: Service impacted by the event. - :type service: str - :param region: Region impacted by the event. - :type region: str - :param incident_type: Type of Event. - :type incident_type: str + :ivar title: Title of the incident. + :vartype title: str + :ivar service: Service impacted by the event. + :vartype service: str + :ivar region: Region impacted by the event. + :vartype region: str + :ivar incident_type: Type of Event. + :vartype incident_type: str """ _attribute_map = { @@ -444,6 +560,16 @@ def __init__( incident_type: Optional[str] = None, **kwargs ): + """ + :keyword title: Title of the incident. + :paramtype title: str + :keyword service: Service impacted by the event. + :paramtype service: str + :keyword region: Region impacted by the event. + :paramtype region: str + :keyword incident_type: Type of Event. + :paramtype incident_type: str + """ super(ServiceImpactingEventIncidentProperties, self).__init__(**kwargs) self.title = title self.service = service @@ -454,8 +580,8 @@ def __init__( class ServiceImpactingEventStatus(msrest.serialization.Model): """Status of the service impacting event. - :param value: Current status of the event. - :type value: str + :ivar value: Current status of the event. + :vartype value: str """ _attribute_map = { @@ -468,5 +594,9 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword value: Current status of the event. + :paramtype value: str + """ super(ServiceImpactingEventStatus, self).__init__(**kwargs) self.value = value diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py index c517ba055954..54916d662509 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_availability_statuses_operations.py @@ -5,23 +5,179 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_id_request( + subscription_id: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/availabilityStatuses') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceHealth/availabilityStatuses') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_by_resource_request( + resource_uri: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses/current') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_uri: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class AvailabilityStatusesOperations(object): """AvailabilityStatusesOperations operations. @@ -45,13 +201,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription_id( self, - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AvailabilityStatusListResult"] + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AvailabilityStatusListResult"]: """Lists the current availability status for all the resources in the subscription. Use the nextLink property in the response to get the next page of availability statuses. @@ -62,8 +218,10 @@ def list_by_subscription_id( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -71,38 +229,33 @@ def list_by_subscription_id( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription_id.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') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + template_url=self.list_by_subscription_id.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_id_request( + subscription_id=self._config.subscription_id, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -115,25 +268,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_subscription_id.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.ResourceHealth/availabilityStatuses'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AvailabilityStatusListResult"] + resource_group_name: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AvailabilityStatusListResult"]: """Lists the current availability status for all the resources in the resource group. Use the nextLink property in the response to get the next page of availability statuses. @@ -146,8 +300,10 @@ def list_by_resource_group( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -155,39 +311,35 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + expand=expand, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -200,25 +352,26 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) list_by_resource_group.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ResourceHealth/availabilityStatuses'} # type: ignore + @distributed_trace def get_by_resource( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.AvailabilityStatus" + resource_uri: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.AvailabilityStatus": """Gets current availability status for a single resource. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -243,35 +396,23 @@ def get_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - # Construct URL - url = self.get_by_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.get_by_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AvailabilityStatus', pipeline_response) @@ -280,16 +421,18 @@ def get_by_resource( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource.metadata = {'url': '/{resourceUri}/providers/Microsoft.ResourceHealth/availabilityStatuses/current'} # type: ignore + + @distributed_trace def list( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AvailabilityStatusListResult"] + resource_uri: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AvailabilityStatusListResult"]: """Lists the historical availability statuses for a single resource. Use the nextLink property in the response to get the next page of availability status. @@ -306,8 +449,10 @@ def list( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -315,38 +460,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -359,12 +499,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py index 2c616a9da512..2cc347c960f7 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_availability_statuses_operations.py @@ -5,23 +5,101 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +def build_get_by_resource_request( + resource_uri: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses/current') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_request( + resource_uri: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ChildAvailabilityStatusesOperations(object): """ChildAvailabilityStatusesOperations operations. @@ -45,14 +123,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_by_resource( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> "_models.AvailabilityStatus" + resource_uri: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> "_models.AvailabilityStatus": """Gets current availability status for a single resource. :param resource_uri: The fully qualified ID of the resource, including the resource name and @@ -75,35 +153,23 @@ def get_by_resource( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - # Construct URL - url = self.get_by_resource.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_by_resource_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.get_by_resource.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AvailabilityStatus', pipeline_response) @@ -112,16 +178,18 @@ def get_by_resource( return cls(pipeline_response, deserialized, {}) return deserialized + get_by_resource.metadata = {'url': '/{resourceUri}/providers/Microsoft.ResourceHealth/childAvailabilityStatuses/current'} # type: ignore + + @distributed_trace def list( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AvailabilityStatusListResult"] + resource_uri: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AvailabilityStatusListResult"]: """Lists the historical availability statuses for a single child resource. Use the nextLink property in the response to get the next page of availability status. @@ -136,8 +204,10 @@ def list( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -145,38 +215,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -189,12 +254,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py index a692873dff7b..07f4f05e5f8e 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_child_resources_operations.py @@ -5,23 +5,63 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + resource_uri: str, + *, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/{resourceUri}/providers/Microsoft.ResourceHealth/childResources') + path_format_arguments = { + "resourceUri": _SERIALIZER.url("resource_uri", resource_uri, 'str', skip_quote=True), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + if filter is not None: + query_parameters['$filter'] = _SERIALIZER.query("filter", filter, 'str') + if expand is not None: + query_parameters['$expand'] = _SERIALIZER.query("expand", expand, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class ChildResourcesOperations(object): """ChildResourcesOperations operations. @@ -45,14 +85,14 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - resource_uri, # type: str - filter=None, # type: Optional[str] - expand=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AvailabilityStatusListResult"] + resource_uri: str, + filter: Optional[str] = None, + expand: Optional[str] = None, + **kwargs: Any + ) -> Iterable["_models.AvailabilityStatusListResult"]: """Lists the all the children and its current health status for a parent resource. Use the nextLink property in the response to get the next page of children current health. @@ -67,8 +107,10 @@ def list( in the response. :type expand: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AvailabilityStatusListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] + :return: An iterator like instance of either AvailabilityStatusListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~azure.mgmt.resourcehealth.v2015_01_01.models.AvailabilityStatusListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AvailabilityStatusListResult"] @@ -76,38 +118,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceUri': self._serialize.url("resource_uri", resource_uri, 'str', skip_quote=True), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - if filter is not None: - query_parameters['$filter'] = self._serialize.query("filter", filter, 'str') - if expand is not None: - query_parameters['$expand'] = self._serialize.query("expand", expand, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + resource_uri=resource_uri, + filter=filter, + expand=expand, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AvailabilityStatusListResult', pipeline_response) + deserialized = self._deserialize("AvailabilityStatusListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -120,12 +157,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py index 3270e4cdcbee..7216860a6530 100644 --- a/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py +++ b/sdk/resourcehealth/azure-mgmt-resourcehealth/azure/mgmt/resourcehealth/v2015_01_01/operations/_operations.py @@ -5,22 +5,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 TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2015-01-01" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.ResourceHealth/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -44,11 +71,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> "_models.OperationListResult" + **kwargs: Any + ) -> "_models.OperationListResult": """Lists available operations for the resourcehealth resource provider. :keyword callable cls: A custom type or function that will be passed the direct response @@ -61,27 +88,20 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2015-01-01" - accept = "application/json" - - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('OperationListResult', pipeline_response) @@ -90,4 +110,6 @@ def list( return cls(pipeline_response, deserialized, {}) return deserialized + list.metadata = {'url': '/providers/Microsoft.ResourceHealth/operations'} # type: ignore +