From 4853b674d8f42f57d539ba7008160035d385e07d Mon Sep 17 00:00:00 2001 From: SDKAuto Date: Wed, 5 Jan 2022 12:32:02 +0000 Subject: [PATCH] CodeGen from PR 16870 in Azure/azure-rest-api-specs Track2 modify readme.go.md (#16870) --- .../_meta.json | 10 +- .../mgmt/baremetalinfrastructure/__init__.py | 9 +- .../_bare_metal_infrastructure_client.py | 82 +-- .../baremetalinfrastructure/_configuration.py | 19 +- .../baremetalinfrastructure/_metadata.json | 21 +- .../mgmt/baremetalinfrastructure/_patch.py | 31 + .../mgmt/baremetalinfrastructure/_vendor.py | 27 + .../mgmt/baremetalinfrastructure/_version.py | 2 +- .../baremetalinfrastructure/aio/__init__.py | 5 + .../aio/_bare_metal_infrastructure_client.py | 70 +- .../aio/_configuration.py | 6 +- .../baremetalinfrastructure/aio/_patch.py | 31 + .../_azure_bare_metal_instances_operations.py | 184 +++-- .../aio/operations/_operations.py | 47 +- .../models/__init__.py | 57 +- ..._bare_metal_infrastructure_client_enums.py | 29 +- .../baremetalinfrastructure/models/_models.py | 629 ------------------ .../models/_models_py3.py | 216 ++++-- .../_azure_bare_metal_instances_operations.py | 371 +++++++---- .../operations/_operations.py | 85 ++- 20 files changed, 805 insertions(+), 1126 deletions(-) create mode 100644 sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_patch.py create mode 100644 sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_vendor.py create mode 100644 sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_patch.py delete mode 100644 sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models.py diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/_meta.json b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/_meta.json index 3203ca0cd0af..51e23b803ae7 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/_meta.json +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.5", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.4", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "1e42e81660d1bc0be000477a4659b29a7ce7d67b", + "commit": "754938e4cb9416358b02dcc11f444adf14b3b7b6", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/baremetalinfrastructure/resource-manager/readme.md --multiapi --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --track2 --use=@autorest/python@5.8.4 --use=@autorest/modelerfour@4.19.2 --version=3.4.5", + "autorest_command": "autorest specification/baremetalinfrastructure/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/baremetalinfrastructure/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/__init__.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/__init__.py index 6dbdb2252ab8..f0831a201b57 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/__init__.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['BareMetalInfrastructureClient'] -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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_bare_metal_infrastructure_client.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_bare_metal_infrastructure_client.py index f54a50e7b5c7..ade5a03dbe57 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_bare_metal_infrastructure_client.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_bare_metal_infrastructure_client.py @@ -6,78 +6,80 @@ # 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 BareMetalInfrastructureClientConfiguration +from .operations import AzureBareMetalInstancesOperations, 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 BareMetalInfrastructureClientConfiguration -from .operations import AzureBareMetalInstancesOperations -from .operations import Operations -from . import models - -class BareMetalInfrastructureClient(object): +class BareMetalInfrastructureClient: """The BareMetalInfrastructure Management client. :ivar azure_bare_metal_instances: AzureBareMetalInstancesOperations operations - :vartype azure_bare_metal_instances: bare_metal_infrastructure_client.operations.AzureBareMetalInstancesOperations + :vartype azure_bare_metal_instances: + bare_metal_infrastructure_client.operations.AzureBareMetalInstancesOperations :ivar operations: Operations operations :vartype operations: bare_metal_infrastructure_client.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The ID of the target subscription. :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 = BareMetalInfrastructureClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = BareMetalInfrastructureClientConfiguration(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.azure_bare_metal_instances = AzureBareMetalInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.azure_bare_metal_instances = AzureBareMetalInstancesOperations( - 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', min_length=1), - } - 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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_configuration.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_configuration.py index d5c6592d6f3c..a7b33a17d4f6 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_configuration.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_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 BareMetalInfrastructureClientConfiguration(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(BareMetalInfrastructureClientConfiguration, 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(BareMetalInfrastructureClientConfiguration, 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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_metadata.json b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_metadata.json index 130f161d94ed..57221b4e8dfa 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_metadata.json +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_metadata.json @@ -5,13 +5,13 @@ "name": "BareMetalInfrastructureClient", "filename": "_bare_metal_infrastructure_client", "description": "The BareMetalInfrastructure Management client.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": false, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"BareMetalInfrastructureClientConfiguration\"]}}, \"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\": [\"BareMetalInfrastructureClientConfiguration\"]}}, \"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\": [\"BareMetalInfrastructureClientConfiguration\"]}}, \"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\": [\"BareMetalInfrastructureClientConfiguration\"]}}, \"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": { "azure_bare_metal_instances": "AzureBareMetalInstancesOperations", diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_patch.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_vendor.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_version.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_version.py index c47f66669f1b..e5754a47ce68 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_version.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0" +VERSION = "1.0.0b1" diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/__init__.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/__init__.py index 091cd3a1ba39..3ade17d70f54 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/__init__.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/__init__.py @@ -8,3 +8,8 @@ from ._bare_metal_infrastructure_client import BareMetalInfrastructureClient __all__ = ['BareMetalInfrastructureClient'] + +# `._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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_bare_metal_infrastructure_client.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_bare_metal_infrastructure_client.py index 10c7370cdf49..67f3b45ab9f9 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_bare_metal_infrastructure_client.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_bare_metal_infrastructure_client.py @@ -6,74 +6,80 @@ # 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 BareMetalInfrastructureClientConfiguration +from .operations import AzureBareMetalInstancesOperations, Operations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import BareMetalInfrastructureClientConfiguration -from .operations import AzureBareMetalInstancesOperations -from .operations import Operations -from .. import models - - -class BareMetalInfrastructureClient(object): +class BareMetalInfrastructureClient: """The BareMetalInfrastructure Management client. :ivar azure_bare_metal_instances: AzureBareMetalInstancesOperations operations - :vartype azure_bare_metal_instances: bare_metal_infrastructure_client.aio.operations.AzureBareMetalInstancesOperations + :vartype azure_bare_metal_instances: + bare_metal_infrastructure_client.aio.operations.AzureBareMetalInstancesOperations :ivar operations: Operations operations :vartype operations: bare_metal_infrastructure_client.aio.operations.Operations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The ID of the target subscription. :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 = BareMetalInfrastructureClientConfiguration(credential, subscription_id, **kwargs) + self._config = BareMetalInfrastructureClientConfiguration(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.azure_bare_metal_instances = AzureBareMetalInstancesOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) - self.azure_bare_metal_instances = AzureBareMetalInstancesOperations( - 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', min_length=1), - } - 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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_configuration.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_configuration.py index 0809070280c1..694cbc8e7dad 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_configuration.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/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(BareMetalInfrastructureClientConfiguration, 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(BareMetalInfrastructureClientConfiguration, 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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_patch.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_azure_bare_metal_instances_operations.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_azure_bare_metal_instances_operations.py index 9eac689264e9..577ab178175c 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_azure_bare_metal_instances_operations.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_azure_bare_metal_instances_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._azure_bare_metal_instances_operations import build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -51,8 +57,10 @@ def list_by_subscription( various properties of each Azure BareMetal instance. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] + :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBareMetalInstancesListResult"] @@ -60,34 +68,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBareMetalInstancesListResult', pipeline_response) + deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -100,17 +103,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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -124,8 +129,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] + :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of + cls(response) + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBareMetalInstancesListResult"] @@ -133,35 +140,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBareMetalInstancesListResult', pipeline_response) + deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -174,17 +177,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.BareMetalInfrastructure/bareMetalInstances'} # type: ignore + @distributed_trace_async async def get( self, resource_group_name: str, @@ -210,33 +215,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'azureBareMetalInstanceName': self._serialize.url("azure_bare_metal_instance_name", azure_bare_metal_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + azure_bare_metal_instance_name=azure_bare_metal_instance_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AzureBareMetalInstance', pipeline_response) @@ -245,8 +240,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}'} # type: ignore + + @distributed_trace_async async def update( self, resource_group_name: str, @@ -275,38 +273,28 @@ async def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'azureBareMetalInstanceName': self._serialize.url("azure_bare_metal_instance_name", azure_bare_metal_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + _json = self._serialize.body(tags_parameter, 'Tags') + + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + azure_bare_metal_instance_name=azure_bare_metal_instance_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(tags_parameter, 'Tags') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AzureBareMetalInstance', pipeline_response) @@ -315,4 +303,6 @@ async def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}'} # type: ignore + diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_operations.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_operations.py index c287db466cd0..5ef16c65d495 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_operations.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/aio/operations/_operations.py @@ -5,17 +5,22 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -41,6 +46,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +55,8 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either OperationList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~bare_metal_infrastructure_client.models.OperationList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~bare_metal_infrastructure_client.models.OperationList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.OperationList"] @@ -57,30 +64,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +97,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.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/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/__init__.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/__init__.py index 226e9d9b036f..b04d6229ca57 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/__init__.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/__init__.py @@ -6,44 +6,25 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import AzureBareMetalInstance - from ._models_py3 import AzureBareMetalInstancesListResult - from ._models_py3 import Disk - from ._models_py3 import Display - from ._models_py3 import ErrorDefinition - from ._models_py3 import ErrorResponse - from ._models_py3 import HardwareProfile - from ._models_py3 import IpAddress - from ._models_py3 import NetworkProfile - from ._models_py3 import OSProfile - from ._models_py3 import Operation - from ._models_py3 import OperationList - from ._models_py3 import Resource - from ._models_py3 import Result - from ._models_py3 import StorageProfile - from ._models_py3 import SystemData - from ._models_py3 import Tags - from ._models_py3 import TrackedResource -except (SyntaxError, ImportError): - from ._models import AzureBareMetalInstance # type: ignore - from ._models import AzureBareMetalInstancesListResult # type: ignore - from ._models import Disk # type: ignore - from ._models import Display # type: ignore - from ._models import ErrorDefinition # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import HardwareProfile # type: ignore - from ._models import IpAddress # type: ignore - from ._models import NetworkProfile # type: ignore - from ._models import OSProfile # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationList # type: ignore - from ._models import Resource # type: ignore - from ._models import Result # type: ignore - from ._models import StorageProfile # type: ignore - from ._models import SystemData # type: ignore - from ._models import Tags # type: ignore - from ._models import TrackedResource # type: ignore +from ._models_py3 import AzureBareMetalInstance +from ._models_py3 import AzureBareMetalInstancesListResult +from ._models_py3 import Disk +from ._models_py3 import Display +from ._models_py3 import ErrorDefinition +from ._models_py3 import ErrorResponse +from ._models_py3 import HardwareProfile +from ._models_py3 import IpAddress +from ._models_py3 import NetworkProfile +from ._models_py3 import OSProfile +from ._models_py3 import Operation +from ._models_py3 import OperationList +from ._models_py3 import Resource +from ._models_py3 import Result +from ._models_py3 import StorageProfile +from ._models_py3 import SystemData +from ._models_py3 import Tags +from ._models_py3 import TrackedResource + from ._bare_metal_infrastructure_client_enums import ( AzureBareMetalHardwareTypeNamesEnum, diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_bare_metal_infrastructure_client_enums.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_bare_metal_infrastructure_client_enums.py index 99ecca39cb99..5ed6e077731f 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_bare_metal_infrastructure_client_enums.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_bare_metal_infrastructure_client_enums.py @@ -6,34 +6,19 @@ # 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 AzureBareMetalHardwareTypeNamesEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AzureBareMetalHardwareTypeNamesEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Name of the hardware type (vendor and/or their product name) """ CISCO_UCS = "Cisco_UCS" HPE = "HPE" -class AzureBareMetalInstancePowerStateEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AzureBareMetalInstancePowerStateEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Resource power state """ @@ -44,7 +29,7 @@ class AzureBareMetalInstancePowerStateEnum(with_metaclass(_CaseInsensitiveEnumMe RESTARTING = "restarting" UNKNOWN = "unknown" -class AzureBareMetalInstanceSizeNamesEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AzureBareMetalInstanceSizeNamesEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Specifies the AzureBareMetal instance SKU. """ @@ -92,7 +77,7 @@ class AzureBareMetalInstanceSizeNamesEnum(with_metaclass(_CaseInsensitiveEnumMet S896_OOO = "S896ooo" S960_M = "S960m" -class AzureBareMetalProvisioningStatesEnum(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class AzureBareMetalProvisioningStatesEnum(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """State of provisioning of the AzureBareMetalInstance """ @@ -104,7 +89,7 @@ class AzureBareMetalProvisioningStatesEnum(with_metaclass(_CaseInsensitiveEnumMe DELETING = "Deleting" MIGRATING = "Migrating" -class CreatedByType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The type of identity that created the resource. """ diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models.py deleted file mode 100644 index 939d0c638486..000000000000 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models.py +++ /dev/null @@ -1,629 +0,0 @@ -# coding=utf-8 -# -------------------------------------------------------------------------- -# Copyright (c) Microsoft Corporation. All rights reserved. -# Licensed under the MIT License. See License.txt in the project root for license information. -# Code generated by Microsoft (R) AutoRest Code Generator. -# Changes may cause incorrect behavior and will be lost if the code is regenerated. -# -------------------------------------------------------------------------- - -from azure.core.exceptions import HttpResponseError -import msrest.serialization - - -class Resource(msrest.serialization.Model): - """Common fields that are returned in the response for all Azure Resource Manager resources. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Resource, self).__init__(**kwargs) - self.id = None - self.name = None - self.type = None - - -class TrackedResource(Resource): - """The resource model definition for an Azure Resource Manager tracked top level resource which has 'tags' and a 'location'. - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(TrackedResource, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - self.location = kwargs['location'] - - -class AzureBareMetalInstance(TrackedResource): - """AzureBareMetal instance info on Azure (ARM properties and AzureBareMetal properties). - - Variables are only populated by the server, and will be ignored when sending a request. - - All required parameters must be populated in order to send to Azure. - - :ivar id: Fully qualified resource ID for the resource. Ex - - /subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/{resourceProviderNamespace}/{resourceType}/{resourceName}. - :vartype id: str - :ivar name: The name of the resource. - :vartype name: str - :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or - "Microsoft.Storage/storageAccounts". - :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str - :ivar system_data: The system metadata relating to this resource. - :vartype system_data: ~bare_metal_infrastructure_client.models.SystemData - :param hardware_profile: Specifies the hardware settings for the AzureBareMetal instance. - :type hardware_profile: ~bare_metal_infrastructure_client.models.HardwareProfile - :param storage_profile: Specifies the storage settings for the AzureBareMetal instance disks. - :type storage_profile: ~bare_metal_infrastructure_client.models.StorageProfile - :param os_profile: Specifies the operating system settings for the AzureBareMetal instance. - :type os_profile: ~bare_metal_infrastructure_client.models.OSProfile - :param network_profile: Specifies the network settings for the AzureBareMetal instance. - :type network_profile: ~bare_metal_infrastructure_client.models.NetworkProfile - :ivar azure_bare_metal_instance_id: Specifies the AzureBareMetal instance unique ID. - :vartype azure_bare_metal_instance_id: str - :ivar power_state: Resource power state. Possible values include: "starting", "started", - "stopping", "stopped", "restarting", "unknown". - :vartype power_state: str or - ~bare_metal_infrastructure_client.models.AzureBareMetalInstancePowerStateEnum - :ivar proximity_placement_group: Resource proximity placement group. - :vartype proximity_placement_group: str - :ivar hw_revision: Hardware revision of an AzureBareMetal instance. - :vartype hw_revision: str - :param partner_node_id: ARM ID of another AzureBareMetalInstance that will share a network with - this AzureBareMetalInstance. - :type partner_node_id: str - :ivar provisioning_state: State of provisioning of the AzureBareMetalInstance. Possible values - include: "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". - :vartype provisioning_state: str or - ~bare_metal_infrastructure_client.models.AzureBareMetalProvisioningStatesEnum - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'system_data': {'readonly': True}, - 'azure_bare_metal_instance_id': {'readonly': True}, - 'power_state': {'readonly': True}, - 'proximity_placement_group': {'readonly': True}, - 'hw_revision': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - 'tags': {'key': 'tags', 'type': '{str}'}, - 'location': {'key': 'location', 'type': 'str'}, - 'system_data': {'key': 'systemData', 'type': 'SystemData'}, - 'hardware_profile': {'key': 'properties.hardwareProfile', 'type': 'HardwareProfile'}, - 'storage_profile': {'key': 'properties.storageProfile', 'type': 'StorageProfile'}, - 'os_profile': {'key': 'properties.osProfile', 'type': 'OSProfile'}, - 'network_profile': {'key': 'properties.networkProfile', 'type': 'NetworkProfile'}, - 'azure_bare_metal_instance_id': {'key': 'properties.azureBareMetalInstanceId', 'type': 'str'}, - 'power_state': {'key': 'properties.powerState', 'type': 'str'}, - 'proximity_placement_group': {'key': 'properties.proximityPlacementGroup', 'type': 'str'}, - 'hw_revision': {'key': 'properties.hwRevision', 'type': 'str'}, - 'partner_node_id': {'key': 'properties.partnerNodeId', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBareMetalInstance, self).__init__(**kwargs) - self.system_data = None - self.hardware_profile = kwargs.get('hardware_profile', None) - self.storage_profile = kwargs.get('storage_profile', None) - self.os_profile = kwargs.get('os_profile', None) - self.network_profile = kwargs.get('network_profile', None) - self.azure_bare_metal_instance_id = None - self.power_state = None - self.proximity_placement_group = None - self.hw_revision = None - self.partner_node_id = kwargs.get('partner_node_id', None) - self.provisioning_state = None - - -class AzureBareMetalInstancesListResult(msrest.serialization.Model): - """The response from the List AzureBareMetal Instances operation. - - :param value: The list of Azure BareMetal instances. - :type value: list[~bare_metal_infrastructure_client.models.AzureBareMetalInstance] - :param next_link: The URL to get the next set of AzureBareMetal instances. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[AzureBareMetalInstance]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(AzureBareMetalInstancesListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Disk(msrest.serialization.Model): - """Specifies the disk information fo the AzureBareMetal instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param name: The disk name. - :type name: str - :param disk_size_gb: Specifies the size of an empty data disk in gigabytes. - :type disk_size_gb: int - :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify - data disks within the VM and therefore must be unique for each data disk attached to a VM. - :vartype lun: int - """ - - _validation = { - 'lun': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'disk_size_gb': {'key': 'diskSizeGB', 'type': 'int'}, - 'lun': {'key': 'lun', 'type': 'int'}, - } - - def __init__( - self, - **kwargs - ): - super(Disk, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.disk_size_gb = kwargs.get('disk_size_gb', None) - self.lun = None - - -class Display(msrest.serialization.Model): - """Detailed BareMetal operation information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar provider: The localized friendly form of the resource provider name. - :vartype provider: str - :ivar resource: The localized friendly form of the resource type related to this - action/operation. - :vartype resource: str - :ivar operation: The localized friendly name for the operation as shown to the user. - :vartype operation: str - :ivar description: The localized friendly description for the operation as shown to the user. - :vartype description: str - """ - - _validation = { - 'provider': {'readonly': True}, - 'resource': {'readonly': True}, - 'operation': {'readonly': True}, - 'description': {'readonly': True}, - } - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Display, self).__init__(**kwargs) - self.provider = None - self.resource = None - self.operation = None - self.description = None - - -class ErrorDefinition(msrest.serialization.Model): - """Error definition. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: Service specific error code which serves as the substatus for the HTTP error code. - :vartype code: str - :ivar message: Description of the error. - :vartype message: str - :ivar details: Internal error details. - :vartype details: list[~bare_metal_infrastructure_client.models.ErrorDefinition] - """ - - _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': '[ErrorDefinition]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDefinition, self).__init__(**kwargs) - self.code = None - self.message = None - self.details = None - - -class ErrorResponse(msrest.serialization.Model): - """Error response. - - :param error: The error details. - :type error: ~bare_metal_infrastructure_client.models.ErrorDefinition - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDefinition'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class HardwareProfile(msrest.serialization.Model): - """Specifies the hardware settings for the AzureBareMetal instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar hardware_type: Name of the hardware type (vendor and/or their product name). Possible - values include: "Cisco_UCS", "HPE". - :vartype hardware_type: str or - ~bare_metal_infrastructure_client.models.AzureBareMetalHardwareTypeNamesEnum - :ivar azure_bare_metal_instance_size: Specifies the AzureBareMetal instance SKU. Possible - values include: "S72m", "S144m", "S72", "S144", "S192", "S192m", "S192xm", "S96", "S112", - "S224", "S224m", "S224om", "S224oo", "S224oom", "S224ooo", "S384", "S384m", "S384xm", - "S384xxm", "S448", "S448m", "S448om", "S448oo", "S448oom", "S448ooo", "S576m", "S576xm", - "S672", "S672m", "S672om", "S672oo", "S672oom", "S672ooo", "S768", "S768m", "S768xm", "S896", - "S896m", "S896om", "S896oo", "S896oom", "S896ooo", "S960m". - :vartype azure_bare_metal_instance_size: str or - ~bare_metal_infrastructure_client.models.AzureBareMetalInstanceSizeNamesEnum - """ - - _validation = { - 'hardware_type': {'readonly': True}, - 'azure_bare_metal_instance_size': {'readonly': True}, - } - - _attribute_map = { - 'hardware_type': {'key': 'hardwareType', 'type': 'str'}, - 'azure_bare_metal_instance_size': {'key': 'azureBareMetalInstanceSize', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(HardwareProfile, self).__init__(**kwargs) - self.hardware_type = None - self.azure_bare_metal_instance_size = None - - -class IpAddress(msrest.serialization.Model): - """Specifies the IP address of the network interface. - - :param ip_address: Specifies the IP address of the network interface. - :type ip_address: str - """ - - _attribute_map = { - 'ip_address': {'key': 'ipAddress', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(IpAddress, self).__init__(**kwargs) - self.ip_address = kwargs.get('ip_address', None) - - -class NetworkProfile(msrest.serialization.Model): - """Specifies the network settings for the AzureBareMetal instance disks. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param network_interfaces: Specifies the network interfaces for the AzureBareMetal instance. - :type network_interfaces: list[~bare_metal_infrastructure_client.models.IpAddress] - :ivar circuit_id: Specifies the circuit id for connecting to express route. - :vartype circuit_id: str - """ - - _validation = { - 'circuit_id': {'readonly': True}, - } - - _attribute_map = { - 'network_interfaces': {'key': 'networkInterfaces', 'type': '[IpAddress]'}, - 'circuit_id': {'key': 'circuitId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(NetworkProfile, self).__init__(**kwargs) - self.network_interfaces = kwargs.get('network_interfaces', None) - self.circuit_id = None - - -class Operation(msrest.serialization.Model): - """AzureBareMetal operation information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar name: The name of the operation being performed on this particular object. This name - should match the action name that appears in RBAC / the event service. - :vartype name: str - :param display: Displayed AzureBareMetal operation information. - :type display: ~bare_metal_infrastructure_client.models.Display - :ivar is_data_action: indicates whether an operation is a data action or not. - :vartype is_data_action: bool - """ - - _validation = { - 'name': {'readonly': True}, - 'is_data_action': {'readonly': True}, - } - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'display': {'key': 'display', 'type': 'Display'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = None - self.display = kwargs.get('display', None) - self.is_data_action = None - - -class OperationList(msrest.serialization.Model): - """List of AzureBareMetal operations. - - :param value: List of AzureBareMetal operations. - :type value: list[~bare_metal_infrastructure_client.models.Operation] - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationList, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - - -class OSProfile(msrest.serialization.Model): - """Specifies the operating system settings for the AzureBareMetal instance. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param computer_name: Specifies the host OS name of the AzureBareMetal instance. - :type computer_name: str - :ivar os_type: This property allows you to specify the type of the OS. - :vartype os_type: str - :ivar version: Specifies version of operating system. - :vartype version: str - :param ssh_public_key: Specifies the SSH public key used to access the operating system. - :type ssh_public_key: str - """ - - _validation = { - 'os_type': {'readonly': True}, - 'version': {'readonly': True}, - } - - _attribute_map = { - 'computer_name': {'key': 'computerName', 'type': 'str'}, - 'os_type': {'key': 'osType', 'type': 'str'}, - 'version': {'key': 'version', 'type': 'str'}, - 'ssh_public_key': {'key': 'sshPublicKey', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OSProfile, self).__init__(**kwargs) - self.computer_name = kwargs.get('computer_name', None) - self.os_type = None - self.version = None - self.ssh_public_key = kwargs.get('ssh_public_key', None) - - -class Result(msrest.serialization.Model): - """Sample result definition. - - :param sample_property: Sample property of type string. - :type sample_property: str - """ - - _attribute_map = { - 'sample_property': {'key': 'sampleProperty', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Result, self).__init__(**kwargs) - self.sample_property = kwargs.get('sample_property', None) - - -class StorageProfile(msrest.serialization.Model): - """Specifies the storage settings for the AzureBareMetal instance disks. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar nfs_ip_address: IP Address to connect to storage. - :vartype nfs_ip_address: str - :param os_disks: Specifies information about the operating system disk used by baremetal - instance. - :type os_disks: list[~bare_metal_infrastructure_client.models.Disk] - """ - - _validation = { - 'nfs_ip_address': {'readonly': True}, - } - - _attribute_map = { - 'nfs_ip_address': {'key': 'nfsIpAddress', 'type': 'str'}, - 'os_disks': {'key': 'osDisks', 'type': '[Disk]'}, - } - - def __init__( - self, - **kwargs - ): - super(StorageProfile, self).__init__(**kwargs) - self.nfs_ip_address = None - self.os_disks = kwargs.get('os_disks', None) - - -class SystemData(msrest.serialization.Model): - """Metadata pertaining to creation and last modification of the resource. - - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible - values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime - """ - - _attribute_map = { - 'created_by': {'key': 'createdBy', 'type': 'str'}, - 'created_by_type': {'key': 'createdByType', 'type': 'str'}, - 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, - 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, - 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, - 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, - } - - def __init__( - self, - **kwargs - ): - super(SystemData, self).__init__(**kwargs) - self.created_by = kwargs.get('created_by', None) - self.created_by_type = kwargs.get('created_by_type', None) - self.created_at = kwargs.get('created_at', None) - self.last_modified_by = kwargs.get('last_modified_by', None) - self.last_modified_by_type = kwargs.get('last_modified_by_type', None) - self.last_modified_at = kwargs.get('last_modified_at', None) - - -class Tags(msrest.serialization.Model): - """Tags field of the AzureBareMetal instance. - - :param tags: A set of tags. Tags field of the AzureBareMetal instance. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(Tags, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models_py3.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models_py3.py index 2a059b47c3da..db02281e2acd 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models_py3.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/models/_models_py3.py @@ -46,6 +46,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -67,10 +69,10 @@ class TrackedResource(Resource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str """ _validation = { @@ -95,6 +97,12 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + """ super(TrackedResource, self).__init__(**kwargs) self.tags = tags self.location = location @@ -115,20 +123,20 @@ class AzureBareMetalInstance(TrackedResource): :ivar type: The type of the resource. E.g. "Microsoft.Compute/virtualMachines" or "Microsoft.Storage/storageAccounts". :vartype type: str - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - :param location: Required. The geo-location where the resource lives. - :type location: str + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] + :ivar location: Required. The geo-location where the resource lives. + :vartype location: str :ivar system_data: The system metadata relating to this resource. :vartype system_data: ~bare_metal_infrastructure_client.models.SystemData - :param hardware_profile: Specifies the hardware settings for the AzureBareMetal instance. - :type hardware_profile: ~bare_metal_infrastructure_client.models.HardwareProfile - :param storage_profile: Specifies the storage settings for the AzureBareMetal instance disks. - :type storage_profile: ~bare_metal_infrastructure_client.models.StorageProfile - :param os_profile: Specifies the operating system settings for the AzureBareMetal instance. - :type os_profile: ~bare_metal_infrastructure_client.models.OSProfile - :param network_profile: Specifies the network settings for the AzureBareMetal instance. - :type network_profile: ~bare_metal_infrastructure_client.models.NetworkProfile + :ivar hardware_profile: Specifies the hardware settings for the AzureBareMetal instance. + :vartype hardware_profile: ~bare_metal_infrastructure_client.models.HardwareProfile + :ivar storage_profile: Specifies the storage settings for the AzureBareMetal instance disks. + :vartype storage_profile: ~bare_metal_infrastructure_client.models.StorageProfile + :ivar os_profile: Specifies the operating system settings for the AzureBareMetal instance. + :vartype os_profile: ~bare_metal_infrastructure_client.models.OSProfile + :ivar network_profile: Specifies the network settings for the AzureBareMetal instance. + :vartype network_profile: ~bare_metal_infrastructure_client.models.NetworkProfile :ivar azure_bare_metal_instance_id: Specifies the AzureBareMetal instance unique ID. :vartype azure_bare_metal_instance_id: str :ivar power_state: Resource power state. Possible values include: "starting", "started", @@ -139,9 +147,9 @@ class AzureBareMetalInstance(TrackedResource): :vartype proximity_placement_group: str :ivar hw_revision: Hardware revision of an AzureBareMetal instance. :vartype hw_revision: str - :param partner_node_id: ARM ID of another AzureBareMetalInstance that will share a network with + :ivar partner_node_id: ARM ID of another AzureBareMetalInstance that will share a network with this AzureBareMetalInstance. - :type partner_node_id: str + :vartype partner_node_id: str :ivar provisioning_state: State of provisioning of the AzureBareMetalInstance. Possible values include: "Accepted", "Creating", "Updating", "Failed", "Succeeded", "Deleting", "Migrating". :vartype provisioning_state: str or @@ -192,6 +200,23 @@ def __init__( partner_node_id: Optional[str] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + :keyword location: Required. The geo-location where the resource lives. + :paramtype location: str + :keyword hardware_profile: Specifies the hardware settings for the AzureBareMetal instance. + :paramtype hardware_profile: ~bare_metal_infrastructure_client.models.HardwareProfile + :keyword storage_profile: Specifies the storage settings for the AzureBareMetal instance disks. + :paramtype storage_profile: ~bare_metal_infrastructure_client.models.StorageProfile + :keyword os_profile: Specifies the operating system settings for the AzureBareMetal instance. + :paramtype os_profile: ~bare_metal_infrastructure_client.models.OSProfile + :keyword network_profile: Specifies the network settings for the AzureBareMetal instance. + :paramtype network_profile: ~bare_metal_infrastructure_client.models.NetworkProfile + :keyword partner_node_id: ARM ID of another AzureBareMetalInstance that will share a network + with this AzureBareMetalInstance. + :paramtype partner_node_id: str + """ super(AzureBareMetalInstance, self).__init__(tags=tags, location=location, **kwargs) self.system_data = None self.hardware_profile = hardware_profile @@ -209,10 +234,10 @@ def __init__( class AzureBareMetalInstancesListResult(msrest.serialization.Model): """The response from the List AzureBareMetal Instances operation. - :param value: The list of Azure BareMetal instances. - :type value: list[~bare_metal_infrastructure_client.models.AzureBareMetalInstance] - :param next_link: The URL to get the next set of AzureBareMetal instances. - :type next_link: str + :ivar value: The list of Azure BareMetal instances. + :vartype value: list[~bare_metal_infrastructure_client.models.AzureBareMetalInstance] + :ivar next_link: The URL to get the next set of AzureBareMetal instances. + :vartype next_link: str """ _attribute_map = { @@ -227,6 +252,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: The list of Azure BareMetal instances. + :paramtype value: list[~bare_metal_infrastructure_client.models.AzureBareMetalInstance] + :keyword next_link: The URL to get the next set of AzureBareMetal instances. + :paramtype next_link: str + """ super(AzureBareMetalInstancesListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -237,10 +268,10 @@ class Disk(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param name: The disk name. - :type name: str - :param disk_size_gb: Specifies the size of an empty data disk in gigabytes. - :type disk_size_gb: int + :ivar name: The disk name. + :vartype name: str + :ivar disk_size_gb: Specifies the size of an empty data disk in gigabytes. + :vartype disk_size_gb: int :ivar lun: Specifies the logical unit number of the data disk. This value is used to identify data disks within the VM and therefore must be unique for each data disk attached to a VM. :vartype lun: int @@ -263,6 +294,12 @@ def __init__( disk_size_gb: Optional[int] = None, **kwargs ): + """ + :keyword name: The disk name. + :paramtype name: str + :keyword disk_size_gb: Specifies the size of an empty data disk in gigabytes. + :paramtype disk_size_gb: int + """ super(Disk, self).__init__(**kwargs) self.name = name self.disk_size_gb = disk_size_gb @@ -303,6 +340,8 @@ def __init__( self, **kwargs ): + """ + """ super(Display, self).__init__(**kwargs) self.provider = None self.resource = None @@ -339,6 +378,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDefinition, self).__init__(**kwargs) self.code = None self.message = None @@ -348,8 +389,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Error response. - :param error: The error details. - :type error: ~bare_metal_infrastructure_client.models.ErrorDefinition + :ivar error: The error details. + :vartype error: ~bare_metal_infrastructure_client.models.ErrorDefinition """ _attribute_map = { @@ -362,6 +403,10 @@ def __init__( error: Optional["ErrorDefinition"] = None, **kwargs ): + """ + :keyword error: The error details. + :paramtype error: ~bare_metal_infrastructure_client.models.ErrorDefinition + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -399,6 +444,8 @@ def __init__( self, **kwargs ): + """ + """ super(HardwareProfile, self).__init__(**kwargs) self.hardware_type = None self.azure_bare_metal_instance_size = None @@ -407,8 +454,8 @@ def __init__( class IpAddress(msrest.serialization.Model): """Specifies the IP address of the network interface. - :param ip_address: Specifies the IP address of the network interface. - :type ip_address: str + :ivar ip_address: Specifies the IP address of the network interface. + :vartype ip_address: str """ _attribute_map = { @@ -421,6 +468,10 @@ def __init__( ip_address: Optional[str] = None, **kwargs ): + """ + :keyword ip_address: Specifies the IP address of the network interface. + :paramtype ip_address: str + """ super(IpAddress, self).__init__(**kwargs) self.ip_address = ip_address @@ -430,8 +481,8 @@ class NetworkProfile(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param network_interfaces: Specifies the network interfaces for the AzureBareMetal instance. - :type network_interfaces: list[~bare_metal_infrastructure_client.models.IpAddress] + :ivar network_interfaces: Specifies the network interfaces for the AzureBareMetal instance. + :vartype network_interfaces: list[~bare_metal_infrastructure_client.models.IpAddress] :ivar circuit_id: Specifies the circuit id for connecting to express route. :vartype circuit_id: str """ @@ -451,6 +502,10 @@ def __init__( network_interfaces: Optional[List["IpAddress"]] = None, **kwargs ): + """ + :keyword network_interfaces: Specifies the network interfaces for the AzureBareMetal instance. + :paramtype network_interfaces: list[~bare_metal_infrastructure_client.models.IpAddress] + """ super(NetworkProfile, self).__init__(**kwargs) self.network_interfaces = network_interfaces self.circuit_id = None @@ -464,8 +519,8 @@ class Operation(msrest.serialization.Model): :ivar name: The name of the operation being performed on this particular object. This name should match the action name that appears in RBAC / the event service. :vartype name: str - :param display: Displayed AzureBareMetal operation information. - :type display: ~bare_metal_infrastructure_client.models.Display + :ivar display: Displayed AzureBareMetal operation information. + :vartype display: ~bare_metal_infrastructure_client.models.Display :ivar is_data_action: indicates whether an operation is a data action or not. :vartype is_data_action: bool """ @@ -487,6 +542,10 @@ def __init__( display: Optional["Display"] = None, **kwargs ): + """ + :keyword display: Displayed AzureBareMetal operation information. + :paramtype display: ~bare_metal_infrastructure_client.models.Display + """ super(Operation, self).__init__(**kwargs) self.name = None self.display = display @@ -496,8 +555,8 @@ def __init__( class OperationList(msrest.serialization.Model): """List of AzureBareMetal operations. - :param value: List of AzureBareMetal operations. - :type value: list[~bare_metal_infrastructure_client.models.Operation] + :ivar value: List of AzureBareMetal operations. + :vartype value: list[~bare_metal_infrastructure_client.models.Operation] """ _attribute_map = { @@ -510,6 +569,10 @@ def __init__( value: Optional[List["Operation"]] = None, **kwargs ): + """ + :keyword value: List of AzureBareMetal operations. + :paramtype value: list[~bare_metal_infrastructure_client.models.Operation] + """ super(OperationList, self).__init__(**kwargs) self.value = value @@ -519,14 +582,14 @@ class OSProfile(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param computer_name: Specifies the host OS name of the AzureBareMetal instance. - :type computer_name: str + :ivar computer_name: Specifies the host OS name of the AzureBareMetal instance. + :vartype computer_name: str :ivar os_type: This property allows you to specify the type of the OS. :vartype os_type: str :ivar version: Specifies version of operating system. :vartype version: str - :param ssh_public_key: Specifies the SSH public key used to access the operating system. - :type ssh_public_key: str + :ivar ssh_public_key: Specifies the SSH public key used to access the operating system. + :vartype ssh_public_key: str """ _validation = { @@ -548,6 +611,12 @@ def __init__( ssh_public_key: Optional[str] = None, **kwargs ): + """ + :keyword computer_name: Specifies the host OS name of the AzureBareMetal instance. + :paramtype computer_name: str + :keyword ssh_public_key: Specifies the SSH public key used to access the operating system. + :paramtype ssh_public_key: str + """ super(OSProfile, self).__init__(**kwargs) self.computer_name = computer_name self.os_type = None @@ -558,8 +627,8 @@ def __init__( class Result(msrest.serialization.Model): """Sample result definition. - :param sample_property: Sample property of type string. - :type sample_property: str + :ivar sample_property: Sample property of type string. + :vartype sample_property: str """ _attribute_map = { @@ -572,6 +641,10 @@ def __init__( sample_property: Optional[str] = None, **kwargs ): + """ + :keyword sample_property: Sample property of type string. + :paramtype sample_property: str + """ super(Result, self).__init__(**kwargs) self.sample_property = sample_property @@ -583,9 +656,9 @@ class StorageProfile(msrest.serialization.Model): :ivar nfs_ip_address: IP Address to connect to storage. :vartype nfs_ip_address: str - :param os_disks: Specifies information about the operating system disk used by baremetal + :ivar os_disks: Specifies information about the operating system disk used by baremetal instance. - :type os_disks: list[~bare_metal_infrastructure_client.models.Disk] + :vartype os_disks: list[~bare_metal_infrastructure_client.models.Disk] """ _validation = { @@ -603,6 +676,11 @@ def __init__( os_disks: Optional[List["Disk"]] = None, **kwargs ): + """ + :keyword os_disks: Specifies information about the operating system disk used by baremetal + instance. + :paramtype os_disks: list[~bare_metal_infrastructure_client.models.Disk] + """ super(StorageProfile, self).__init__(**kwargs) self.nfs_ip_address = None self.os_disks = os_disks @@ -611,20 +689,20 @@ def __init__( class SystemData(msrest.serialization.Model): """Metadata pertaining to creation and last modification of the resource. - :param created_by: The identity that created the resource. - :type created_by: str - :param created_by_type: The type of identity that created the resource. Possible values - include: "User", "Application", "ManagedIdentity", "Key". - :type created_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType - :param created_at: The timestamp of resource creation (UTC). - :type created_at: ~datetime.datetime - :param last_modified_by: The identity that last modified the resource. - :type last_modified_by: str - :param last_modified_by_type: The type of identity that last modified the resource. Possible + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible values include: "User", "Application", "ManagedIdentity", "Key". - :type last_modified_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType - :param last_modified_at: The timestamp of resource last modification (UTC). - :type last_modified_at: ~datetime.datetime + :vartype last_modified_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime """ _attribute_map = { @@ -647,6 +725,22 @@ def __init__( last_modified_at: Optional[datetime.datetime] = None, **kwargs ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~bare_metal_infrastructure_client.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ super(SystemData, self).__init__(**kwargs) self.created_by = created_by self.created_by_type = created_by_type @@ -659,8 +753,8 @@ def __init__( class Tags(msrest.serialization.Model): """Tags field of the AzureBareMetal instance. - :param tags: A set of tags. Tags field of the AzureBareMetal instance. - :type tags: dict[str, str] + :ivar tags: A set of tags. Tags field of the AzureBareMetal instance. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -673,5 +767,9 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Tags field of the AzureBareMetal instance. + :paramtype tags: dict[str, str] + """ super(Tags, self).__init__(**kwargs) self.tags = tags diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_azure_bare_metal_instances_operations.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_azure_bare_metal_instances_operations.py index 36c469569177..e11d92a40e32 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_azure_bare_metal_instances_operations.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_azure_bare_metal_instances_operations.py @@ -5,23 +5,169 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-09" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + subscription_id: str, + resource_group_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-09" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id: str, + resource_group_name: str, + azure_bare_metal_instance_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-09" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "azureBareMetalInstanceName": _SERIALIZER.url("azure_bare_metal_instance_name", azure_bare_metal_instance_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_update_request( + subscription_id: str, + resource_group_name: str, + azure_bare_metal_instance_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2021-08-09" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str', min_length=1), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), + "azureBareMetalInstanceName": _SERIALIZER.url("azure_bare_metal_instance_name", azure_bare_metal_instance_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) class AzureBareMetalInstancesOperations(object): """AzureBareMetalInstancesOperations operations. @@ -45,19 +191,21 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AzureBareMetalInstancesListResult"] + **kwargs: Any + ) -> Iterable["_models.AzureBareMetalInstancesListResult"]: """Gets a list of Azure BareMetal instances in the specified subscription. Gets a list of AzureBareMetal instances in the specified subscription. The operations returns various properties of each Azure BareMetal instance. :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] + :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBareMetalInstancesListResult"] @@ -65,34 +213,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBareMetalInstancesListResult', pipeline_response) + deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -105,23 +248,24 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.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.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.AzureBareMetalInstancesListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.AzureBareMetalInstancesListResult"]: """Gets a list of Azure BareMetal instances in the specified subscription and resource group. Gets a list of AzureBareMetal instances in the specified subscription and resource group. The @@ -130,8 +274,10 @@ def list_by_resource_group( :param resource_group_name: The name of the resource group. The name is case insensitive. :type resource_group_name: str :keyword callable cls: A custom type or function that will be passed the direct response - :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] + :return: An iterator like instance of either AzureBareMetalInstancesListResult or the result of + cls(response) + :rtype: + ~azure.core.paging.ItemPaged[~bare_metal_infrastructure_client.models.AzureBareMetalInstancesListResult] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.AzureBareMetalInstancesListResult"] @@ -139,35 +285,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - 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', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=self.list_by_resource_group.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('AzureBareMetalInstancesListResult', pipeline_response) + deserialized = self._deserialize("AzureBareMetalInstancesListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -180,24 +322,25 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.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.BareMetalInfrastructure/bareMetalInstances'} # type: ignore + @distributed_trace def get( self, - resource_group_name, # type: str - azure_bare_metal_instance_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureBareMetalInstance" + resource_group_name: str, + azure_bare_metal_instance_name: str, + **kwargs: Any + ) -> "_models.AzureBareMetalInstance": """Gets an Azure BareMetal instance. Gets an Azure BareMetal instance for the specified subscription, resource group, and instance @@ -217,33 +360,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'azureBareMetalInstanceName': self._serialize.url("azure_bare_metal_instance_name", azure_bare_metal_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + azure_bare_metal_instance_name=azure_bare_metal_instance_name, + template_url=self.get.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AzureBareMetalInstance', pipeline_response) @@ -252,16 +385,18 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}'} # type: ignore + + @distributed_trace def update( self, - resource_group_name, # type: str - azure_bare_metal_instance_name, # type: str - tags_parameter, # type: "_models.Tags" - **kwargs # type: Any - ): - # type: (...) -> "_models.AzureBareMetalInstance" + resource_group_name: str, + azure_bare_metal_instance_name: str, + tags_parameter: "_models.Tags", + **kwargs: Any + ) -> "_models.AzureBareMetalInstance": """Patches the Tags field of a Azure BareMetal instance. Patches the Tags field of a Azure BareMetal instance for the specified subscription, resource @@ -283,38 +418,28 @@ def update( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str', min_length=1), - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str', max_length=90, min_length=1), - 'azureBareMetalInstanceName': self._serialize.url("azure_bare_metal_instance_name", azure_bare_metal_instance_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(tags_parameter, 'Tags') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Content-Type'] = self._serialize.header("content_type", content_type, 'str') - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + request = build_update_request( + subscription_id=self._config.subscription_id, + resource_group_name=resource_group_name, + azure_bare_metal_instance_name=azure_bare_metal_instance_name, + content_type=content_type, + json=_json, + template_url=self.update.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(tags_parameter, 'Tags') - body_content_kwargs['content'] = body_content - request = self._client.patch(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) deserialized = self._deserialize('AzureBareMetalInstance', pipeline_response) @@ -323,4 +448,6 @@ def update( return cls(pipeline_response, deserialized, {}) return deserialized + update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.BareMetalInfrastructure/bareMetalInstances/{azureBareMetalInstanceName}'} # type: ignore + diff --git a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_operations.py b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_operations.py index 473bc60feab6..49a784f2b18f 100644 --- a/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_operations.py +++ b/sdk/baremetalinfrastructure/azure-mgmt-baremetalinfrastructure/azure/mgmt/baremetalinfrastructure/operations/_operations.py @@ -5,23 +5,50 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + **kwargs: Any +) -> HttpRequest: + api_version = "2021-08-09" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.BareMetalInfrastructure/operations') + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class Operations(object): """Operations operations. @@ -45,11 +72,11 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OperationList"] + **kwargs: Any + ) -> Iterable["_models.OperationList"]: """Gets a list of AzureBareMetal management operations. :keyword callable cls: A custom type or function that will be passed the direct response @@ -62,30 +89,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2021-08-09" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationList', pipeline_response) + deserialized = self._deserialize("OperationList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,12 +122,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.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 )