diff --git a/sdk/quantum/azure-mgmt-quantum/_meta.json b/sdk/quantum/azure-mgmt-quantum/_meta.json index 08d9d2f8324a..c7c8a219e33d 100644 --- a/sdk/quantum/azure-mgmt-quantum/_meta.json +++ b/sdk/quantum/azure-mgmt-quantum/_meta.json @@ -1,11 +1,11 @@ { - "autorest": "3.4.2", + "autorest": "3.7.2", "use": [ - "@autorest/python@5.8.0", - "@autorest/modelerfour@4.19.2" + "@autorest/python@5.12.0", + "@autorest/modelerfour@4.19.3" ], - "commit": "5e076b3d3a0d6b5c9f083a0fddf0e3082137b0c6", + "commit": "211006238f3b07a46f938d8920e6bafc9dc64374", "repository_url": "https://github.com/Azure/azure-rest-api-specs", - "autorest_command": "autorest specification/quantum/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.0 --use=@autorest/modelerfour@4.19.2 --version=3.4.2", + "autorest_command": "autorest specification/quantum/resource-manager/readme.md --multiapi --python --python-sdks-folder=/mnt/vss/_work/1/s/azure-sdk-for-python/sdk --python3-only --use=@autorest/python@5.12.0 --use=@autorest/modelerfour@4.19.3 --version=3.7.2", "readme": "specification/quantum/resource-manager/readme.md" } \ No newline at end of file diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/__init__.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/__init__.py index ecf2e7c67cdf..d8cad6c357f4 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/__init__.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['AzureQuantumManagementClient'] -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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_azure_quantum_management_client.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_azure_quantum_management_client.py index e74caffd2e08..a7e3d9fd3444 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_azure_quantum_management_client.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_azure_quantum_management_client.py @@ -6,26 +6,22 @@ # 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 AzureQuantumManagementClientConfiguration +from .operations import OfferingsOperations, Operations, WorkspaceOperations, WorkspacesOperations + 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 AzureQuantumManagementClientConfiguration -from .operations import WorkspacesOperations -from .operations import OfferingsOperations -from .operations import Operations -from . import models - -class AzureQuantumManagementClient(object): +class AzureQuantumManagementClient: """AzureQuantumManagementClient. :ivar workspaces: WorkspacesOperations operations @@ -34,56 +30,63 @@ class AzureQuantumManagementClient(object): :vartype offerings: azure.mgmt.quantum.operations.OfferingsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.quantum.operations.Operations + :ivar workspace: WorkspaceOperations operations + :vartype workspace: azure.mgmt.quantum.operations.WorkspaceOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, - credential, # type: "TokenCredential" - subscription_id, # type: str - base_url=None, # type: Optional[str] - **kwargs # type: Any - ): - # type: (...) -> None - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureQuantumManagementClientConfiguration(credential, subscription_id, **kwargs) + credential: "TokenCredential", + subscription_id: str, + base_url: str = "https://management.azure.com", + **kwargs: Any + ) -> None: + self._config = AzureQuantumManagementClientConfiguration(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.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.offerings = OfferingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspaces = WorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.offerings = OfferingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - def _send_request(self, http_request, **kwargs): - # type: (HttpRequest, Any) -> HttpResponse + def _send_request( + self, + request, # type: HttpRequest + **kwargs: Any + ) -> HttpResponse: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.HttpResponse + :rtype: ~azure.core.rest.HttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) def close(self): # type: () -> None diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_configuration.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_configuration.py index e8b4b8dec359..2165ccfe5410 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_configuration.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_configuration.py @@ -6,18 +6,16 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +from typing import Any, TYPE_CHECKING from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMChallengeAuthenticationPolicy, ARMHttpLoggingPolicy from ._version import VERSION if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any - from azure.core.credentials import TokenCredential @@ -35,20 +33,19 @@ class AzureQuantumManagementClientConfiguration(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(AzureQuantumManagementClientConfiguration, 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(AzureQuantumManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-04-preview" + self.api_version = "2022-04-05-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-quantum/{}'.format(VERSION)) self._configure(**kwargs) @@ -68,4 +65,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = ARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_metadata.json b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_metadata.json index 6136cbdae779..ce1fe2ef1e46 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_metadata.json +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_metadata.json @@ -1,17 +1,17 @@ { - "chosen_version": "2019-11-04-preview", - "total_api_version_list": ["2019-11-04-preview"], + "chosen_version": "2022-04-05-preview", + "total_api_version_list": ["2022-04-05-preview"], "client": { "name": "AzureQuantumManagementClient", "filename": "_azure_quantum_management_client", "description": "AzureQuantumManagementClient.", - "base_url": "\u0027https://management.azure.com\u0027", - "custom_base_url": null, + "host_value": "\"https://management.azure.com\"", + "parameterized_host_template": null, "azure_arm": true, "has_lro_operations": true, "client_side_validation": false, - "sync_imports": "{\"typing\": {\"azurecore\": {\"azure.core.credentials\": [\"TokenCredential\"]}}, \"regular\": {\"azurecore\": {\"azure.profiles\": [\"KnownProfiles\", \"ProfileDefinition\"], \"azure.profiles.multiapiclient\": [\"MultiApiClientMixin\"], \"msrest\": [\"Deserializer\", \"Serializer\"], \"azure.mgmt.core\": [\"ARMPipelineClient\"]}, \"local\": {\"._configuration\": [\"AzureQuantumManagementClientConfiguration\"]}}, \"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\": [\"AzureQuantumManagementClientConfiguration\"]}}, \"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\": [\"AzureQuantumManagementClientConfiguration\"]}}, \"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\": [\"AzureQuantumManagementClientConfiguration\"]}}, \"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,15 +91,15 @@ "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": { "workspaces": "WorkspacesOperations", "offerings": "OfferingsOperations", - "operations": "Operations" + "operations": "Operations", + "workspace": "WorkspaceOperations" } } \ No newline at end of file diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_patch.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_vendor.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_vendor.py new file mode 100644 index 000000000000..138f663c53a4 --- /dev/null +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_version.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_version.py index dfa6ee022f15..e5754a47ce68 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_version.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/_version.py @@ -6,4 +6,4 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -VERSION = "1.0.0b2" +VERSION = "1.0.0b1" diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/__init__.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/__init__.py index 7927c1da8d35..eefb549dcb20 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/__init__.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/__init__.py @@ -8,3 +8,8 @@ from ._azure_quantum_management_client import AzureQuantumManagementClient __all__ = ['AzureQuantumManagementClient'] + +# `._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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_azure_quantum_management_client.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_azure_quantum_management_client.py index 3ecd7df9d3a2..276f0e1cf3bf 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_azure_quantum_management_client.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_azure_quantum_management_client.py @@ -6,24 +6,22 @@ # 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 AzureQuantumManagementClientConfiguration +from .operations import OfferingsOperations, Operations, WorkspaceOperations, WorkspacesOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import AzureQuantumManagementClientConfiguration -from .operations import WorkspacesOperations -from .operations import OfferingsOperations -from .operations import Operations -from .. import models - - -class AzureQuantumManagementClient(object): +class AzureQuantumManagementClient: """AzureQuantumManagementClient. :ivar workspaces: WorkspacesOperations operations @@ -32,54 +30,63 @@ class AzureQuantumManagementClient(object): :vartype offerings: azure.mgmt.quantum.aio.operations.OfferingsOperations :ivar operations: Operations operations :vartype operations: azure.mgmt.quantum.aio.operations.Operations + :ivar workspace: WorkspaceOperations operations + :vartype workspace: azure.mgmt.quantum.aio.operations.WorkspaceOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials_async.AsyncTokenCredential :param subscription_id: The Azure subscription ID. :type subscription_id: str - :param str base_url: Service URL - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :param base_url: Service URL. Default value is 'https://management.azure.com'. + :type base_url: str + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. """ def __init__( self, credential: "AsyncTokenCredential", subscription_id: str, - base_url: Optional[str] = None, + base_url: str = "https://management.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://management.azure.com' - self._config = AzureQuantumManagementClientConfiguration(credential, subscription_id, **kwargs) + self._config = AzureQuantumManagementClientConfiguration(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.workspaces = WorkspacesOperations(self._client, self._config, self._serialize, self._deserialize) + self.offerings = OfferingsOperations(self._client, self._config, self._serialize, self._deserialize) + self.operations = Operations(self._client, self._config, self._serialize, self._deserialize) + self.workspace = WorkspaceOperations(self._client, self._config, self._serialize, self._deserialize) - self.workspaces = WorkspacesOperations( - self._client, self._config, self._serialize, self._deserialize) - self.offerings = OfferingsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.operations = Operations( - self._client, self._config, self._serialize, self._deserialize) - async def _send_request(self, http_request: HttpRequest, **kwargs: Any) -> AsyncHttpResponse: + def _send_request( + self, + request: HttpRequest, + **kwargs: Any + ) -> Awaitable[AsyncHttpResponse]: """Runs the network request through the client's chained policies. - :param http_request: The network request you want to make. Required. - :type http_request: ~azure.core.pipeline.transport.HttpRequest - :keyword bool stream: Whether the response payload will be streamed. Defaults to True. + >>> from azure.core.rest import HttpRequest + >>> request = HttpRequest("GET", "https://www.example.org/") + + >>> response = await client._send_request(request) + + + For more information on this code flow, see https://aka.ms/azsdk/python/protocol/quickstart + + :param request: The network request you want to make. Required. + :type request: ~azure.core.rest.HttpRequest + :keyword bool stream: Whether the response payload will be streamed. Defaults to False. :return: The response of your network call. Does not do error handling on your response. - :rtype: ~azure.core.pipeline.transport.AsyncHttpResponse + :rtype: ~azure.core.rest.AsyncHttpResponse """ - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - http_request.url = self._client.format_url(http_request.url, **path_format_arguments) - stream = kwargs.pop("stream", True) - pipeline_response = await self._client._pipeline.run(http_request, stream=stream, **kwargs) - return pipeline_response.http_response + + request_copy = deepcopy(request) + request_copy.url = self._client.format_url(request_copy.url) + return self._client.send_request(request_copy, **kwargs) async def close(self) -> None: await self._client.close() diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_configuration.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_configuration.py index 35fc3b1c23c1..7efe790605a7 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_configuration.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_configuration.py @@ -10,7 +10,7 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy +from azure.mgmt.core.policies import ARMHttpLoggingPolicy, AsyncARMChallengeAuthenticationPolicy from .._version import VERSION @@ -37,15 +37,15 @@ def __init__( subscription_id: str, **kwargs: Any ) -> None: + super(AzureQuantumManagementClientConfiguration, 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(AzureQuantumManagementClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id - self.api_version = "2019-11-04-preview" + self.api_version = "2022-04-05-preview" self.credential_scopes = kwargs.pop('credential_scopes', ['https://management.azure.com/.default']) kwargs.setdefault('sdk_moniker', 'mgmt-quantum/{}'.format(VERSION)) self._configure(**kwargs) @@ -64,4 +64,4 @@ def _configure( self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) self.authentication_policy = kwargs.get('authentication_policy') if self.credential and not self.authentication_policy: - self.authentication_policy = policies.AsyncBearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs) + self.authentication_policy = AsyncARMChallengeAuthenticationPolicy(self.credential, *self.credential_scopes, **kwargs) diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_patch.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/_patch.py new file mode 100644 index 000000000000..74e48ecd07cf --- /dev/null +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/__init__.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/__init__.py index be714f399997..7eae3e8df6c1 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/__init__.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/__init__.py @@ -9,9 +9,11 @@ from ._workspaces_operations import WorkspacesOperations from ._offerings_operations import OfferingsOperations from ._operations import Operations +from ._workspace_operations import WorkspaceOperations __all__ = [ 'WorkspacesOperations', 'OfferingsOperations', 'Operations', + 'WorkspaceOperations', ] diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_offerings_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_offerings_operations.py index f0a358e93a60..0bec8a6e7717 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_offerings_operations.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_offerings_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._offerings_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, location_name: str, @@ -60,35 +66,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location_name=location_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('OfferingsListResult', pipeline_response) + deserialized = self._deserialize("OfferingsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -101,12 +103,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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_operations.py index cee85b21cc0d..15c3acf7e5af 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_operations.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/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 @@ -57,30 +63,27 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -93,12 +96,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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_workspace_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_workspace_operations.py new file mode 100644 index 000000000000..c02ce1cf6435 --- /dev/null +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_workspace_operations.py @@ -0,0 +1,102 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async +from azure.mgmt.core.exceptions import ARMErrorFormat + +from ... import models as _models +from ..._vendor import _convert_request +from ...operations._workspace_operations import build_check_name_availability_request +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] + +class WorkspaceOperations: + """WorkspaceOperations async operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.quantum.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer) -> None: + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace_async + async def check_name_availability( + self, + location_name: str, + check_name_availability_parameters: "_models.CheckNameAvailabilityParameters", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": + """Check the availability of the resource name. + + :param location_name: Location. + :type location_name: str + :param check_name_availability_parameters: The name and type of the resource. + :type check_name_availability_parameters: + ~azure.mgmt.quantum.models.CheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult, or the result of cls(response) + :rtype: ~azure.mgmt.quantum.models.CheckNameAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(check_name_availability_parameters, 'CheckNameAvailabilityParameters') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Quantum/locations/{locationName}/checkNameAvailability'} # type: ignore + diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_workspaces_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_workspaces_operations.py index 7164002c7e56..94af5b81c3e0 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_workspaces_operations.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/aio/operations/_workspaces_operations.py @@ -5,19 +5,24 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union import warnings from azure.core.async_paging import AsyncItemPaged, AsyncList from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest +from azure.core.pipeline.transport import AsyncHttpResponse from azure.core.polling import AsyncLROPoller, AsyncNoPolling, AsyncPollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.core.tracing.decorator_async import distributed_trace_async from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.async_arm_polling import AsyncARMPolling from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._workspaces_operations import build_create_or_update_request_initial, build_delete_request_initial, build_get_request, build_list_by_resource_group_request, build_list_by_subscription_request, build_update_tags_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -43,6 +48,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def get( self, resource_group_name: str, @@ -65,33 +71,23 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_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('QuantumWorkspace', pipeline_response) @@ -100,8 +96,10 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + async def _create_or_update_initial( self, resource_group_name: str, @@ -114,39 +112,28 @@ async def _create_or_update_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_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(quantum_workspace, 'QuantumWorkspace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(quantum_workspace, 'QuantumWorkspace') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('QuantumWorkspace', pipeline_response) @@ -158,8 +145,11 @@ async def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + + @distributed_trace_async async def begin_create_or_update( self, resource_group_name: str, @@ -177,15 +167,19 @@ async def begin_create_or_update( :type quantum_workspace: ~azure.mgmt.quantum.models.QuantumWorkspace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of AsyncLROPoller that returns either QuantumWorkspace or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of AsyncLROPoller that returns either QuantumWorkspace or the result of + cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[~azure.mgmt.quantum.models.QuantumWorkspace] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.QuantumWorkspace"] lro_delay = kwargs.pop( 'polling_interval', @@ -197,27 +191,21 @@ async def begin_create_or_update( resource_group_name=resource_group_name, workspace_name=workspace_name, quantum_workspace=quantum_workspace, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('QuantumWorkspace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -229,8 +217,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + @distributed_trace_async async def update_tags( self, resource_group_name: str, @@ -256,38 +246,28 @@ async def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_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(workspace_tags, 'TagsObject') - # 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_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.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(workspace_tags, 'TagsObject') - 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('QuantumWorkspace', pipeline_response) @@ -296,8 +276,10 @@ async def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + async def _delete_initial( self, resource_group_name: str, @@ -309,40 +291,31 @@ async def _delete_initial( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = await self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + + @distributed_trace_async async def begin_delete( self, resource_group_name: str, @@ -357,15 +330,17 @@ async def begin_delete( :type workspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be AsyncARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be AsyncARMPolling. Pass in False for + this operation to not poll, or pass in your own initialized polling object for a personal + polling strategy. :paramtype polling: bool or ~azure.core.polling.AsyncPollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of AsyncLROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.AsyncLROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, AsyncPollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.AsyncPollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -379,21 +354,14 @@ async def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'), - } - if polling is True: polling_method = AsyncARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = AsyncARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = AsyncNoPolling() else: polling_method = polling if cont_token: @@ -405,8 +373,10 @@ def get_long_running_output(pipeline_response): ) else: return AsyncLROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, **kwargs: Any @@ -423,34 +393,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request async def extract_data(pipeline_response): - deserialized = self._deserialize('WorkspaceListResult', pipeline_response) + deserialized = self._deserialize("WorkspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -463,17 +428,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.Quantum/workspaces'} # type: ignore + @distributed_trace def list_by_resource_group( self, resource_group_name: str, @@ -493,35 +460,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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( + resource_group_name=resource_group_name, + 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('WorkspaceListResult', pipeline_response) + deserialized = self._deserialize("WorkspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -534,12 +497,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/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/__init__.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/__init__.py index 04204a4f788c..4b5886fbea43 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/__init__.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/__init__.py @@ -6,56 +6,36 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -try: - from ._models_py3 import ErrorAdditionalInfo - from ._models_py3 import ErrorDetail - from ._models_py3 import ErrorResponse - from ._models_py3 import OfferingsListResult - from ._models_py3 import Operation - from ._models_py3 import OperationDisplay - from ._models_py3 import OperationsList - from ._models_py3 import PricingDetail - from ._models_py3 import PricingDimension - from ._models_py3 import Provider - from ._models_py3 import ProviderDescription - from ._models_py3 import ProviderProperties - from ._models_py3 import ProviderPropertiesAad - from ._models_py3 import ProviderPropertiesManagedApplication - from ._models_py3 import QuantumWorkspace - from ._models_py3 import QuantumWorkspaceIdentity - from ._models_py3 import QuotaDimension - from ._models_py3 import Resource - from ._models_py3 import SkuDescription - from ._models_py3 import TagsObject - from ._models_py3 import TargetDescription - from ._models_py3 import TrackedResource - from ._models_py3 import WorkspaceListResult -except (SyntaxError, ImportError): - from ._models import ErrorAdditionalInfo # type: ignore - from ._models import ErrorDetail # type: ignore - from ._models import ErrorResponse # type: ignore - from ._models import OfferingsListResult # type: ignore - from ._models import Operation # type: ignore - from ._models import OperationDisplay # type: ignore - from ._models import OperationsList # type: ignore - from ._models import PricingDetail # type: ignore - from ._models import PricingDimension # type: ignore - from ._models import Provider # type: ignore - from ._models import ProviderDescription # type: ignore - from ._models import ProviderProperties # type: ignore - from ._models import ProviderPropertiesAad # type: ignore - from ._models import ProviderPropertiesManagedApplication # type: ignore - from ._models import QuantumWorkspace # type: ignore - from ._models import QuantumWorkspaceIdentity # type: ignore - from ._models import QuotaDimension # type: ignore - from ._models import Resource # type: ignore - from ._models import SkuDescription # type: ignore - from ._models import TagsObject # type: ignore - from ._models import TargetDescription # type: ignore - from ._models import TrackedResource # type: ignore - from ._models import WorkspaceListResult # type: ignore +from ._models_py3 import CheckNameAvailabilityParameters +from ._models_py3 import CheckNameAvailabilityResult +from ._models_py3 import ErrorAdditionalInfo +from ._models_py3 import ErrorDetail +from ._models_py3 import ErrorResponse +from ._models_py3 import OfferingsListResult +from ._models_py3 import Operation +from ._models_py3 import OperationDisplay +from ._models_py3 import OperationsList +from ._models_py3 import PricingDetail +from ._models_py3 import PricingDimension +from ._models_py3 import Provider +from ._models_py3 import ProviderDescription +from ._models_py3 import ProviderProperties +from ._models_py3 import ProviderPropertiesAad +from ._models_py3 import ProviderPropertiesManagedApplication +from ._models_py3 import QuantumWorkspace +from ._models_py3 import QuantumWorkspaceIdentity +from ._models_py3 import QuotaDimension +from ._models_py3 import Resource +from ._models_py3 import SkuDescription +from ._models_py3 import SystemData +from ._models_py3 import TagsObject +from ._models_py3 import TargetDescription +from ._models_py3 import TrackedResource +from ._models_py3 import WorkspaceListResult + from ._azure_quantum_management_client_enums import ( + CreatedByType, ProvisioningStatus, ResourceIdentityType, Status, @@ -63,6 +43,8 @@ ) __all__ = [ + 'CheckNameAvailabilityParameters', + 'CheckNameAvailabilityResult', 'ErrorAdditionalInfo', 'ErrorDetail', 'ErrorResponse', @@ -82,10 +64,12 @@ 'QuotaDimension', 'Resource', 'SkuDescription', + 'SystemData', 'TagsObject', 'TargetDescription', 'TrackedResource', 'WorkspaceListResult', + 'CreatedByType', 'ProvisioningStatus', 'ResourceIdentityType', 'Status', diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_azure_quantum_management_client_enums.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_azure_quantum_management_client_enums.py index 9b40201cad9e..98503b153943 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_azure_quantum_management_client_enums.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_azure_quantum_management_client_enums.py @@ -6,27 +6,21 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) +class CreatedByType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The type of identity that created the resource. + """ + USER = "User" + APPLICATION = "Application" + MANAGED_IDENTITY = "ManagedIdentity" + KEY = "Key" -class ProvisioningStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProvisioningStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning status field """ @@ -37,14 +31,14 @@ class ProvisioningStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): PROVIDER_PROVISIONING = "ProviderProvisioning" FAILED = "Failed" -class ResourceIdentityType(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ResourceIdentityType(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The identity type. """ SYSTEM_ASSIGNED = "SystemAssigned" NONE = "None" -class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class Status(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provisioning status field """ @@ -55,7 +49,7 @@ class Status(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DELETED = "Deleted" FAILED = "Failed" -class UsableStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class UsableStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Whether the current workspace is ready to accept Jobs. """ diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_models.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_models.py deleted file mode 100644 index a71b94e8e1b4..000000000000 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_models.py +++ /dev/null @@ -1,811 +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 ErrorAdditionalInfo(msrest.serialization.Model): - """The resource management error additional info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar type: The additional info type. - :vartype type: str - :ivar info: The additional info. - :vartype info: any - """ - - _validation = { - 'type': {'readonly': True}, - 'info': {'readonly': True}, - } - - _attribute_map = { - 'type': {'key': 'type', 'type': 'str'}, - 'info': {'key': 'info', 'type': 'object'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorAdditionalInfo, self).__init__(**kwargs) - self.type = None - self.info = None - - -class ErrorDetail(msrest.serialization.Model): - """The error detail. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar code: The error code. - :vartype code: str - :ivar message: The error message. - :vartype message: str - :ivar target: The error target. - :vartype target: str - :ivar details: The error details. - :vartype details: list[~azure.mgmt.quantum.models.ErrorDetail] - :ivar additional_info: The error additional info. - :vartype additional_info: list[~azure.mgmt.quantum.models.ErrorAdditionalInfo] - """ - - _validation = { - 'code': {'readonly': True}, - 'message': {'readonly': True}, - 'target': {'readonly': True}, - 'details': {'readonly': True}, - 'additional_info': {'readonly': True}, - } - - _attribute_map = { - 'code': {'key': 'code', 'type': 'str'}, - 'message': {'key': 'message', 'type': 'str'}, - 'target': {'key': 'target', 'type': 'str'}, - 'details': {'key': 'details', 'type': '[ErrorDetail]'}, - 'additional_info': {'key': 'additionalInfo', 'type': '[ErrorAdditionalInfo]'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorDetail, self).__init__(**kwargs) - self.code = None - self.message = None - self.target = None - self.details = None - self.additional_info = None - - -class ErrorResponse(msrest.serialization.Model): - """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - - :param error: The error object. - :type error: ~azure.mgmt.quantum.models.ErrorDetail - """ - - _attribute_map = { - 'error': {'key': 'error', 'type': 'ErrorDetail'}, - } - - def __init__( - self, - **kwargs - ): - super(ErrorResponse, self).__init__(**kwargs) - self.error = kwargs.get('error', None) - - -class OfferingsListResult(msrest.serialization.Model): - """The response of a list Providers operation. - - :param value: Result of a list Providers operation. - :type value: list[~azure.mgmt.quantum.models.ProviderDescription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Providers. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[ProviderDescription]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OfferingsListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) - - -class Operation(msrest.serialization.Model): - """Operation provided by provider. - - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Properties of the operation. - :type display: ~azure.mgmt.quantum.models.OperationDisplay - """ - - _attribute_map = { - 'name': {'key': 'name', 'type': 'str'}, - 'is_data_action': {'key': 'isDataAction', 'type': 'bool'}, - 'display': {'key': 'display', 'type': 'OperationDisplay'}, - } - - def __init__( - self, - **kwargs - ): - super(Operation, self).__init__(**kwargs) - self.name = kwargs.get('name', None) - self.is_data_action = kwargs.get('is_data_action', None) - self.display = kwargs.get('display', None) - - -class OperationDisplay(msrest.serialization.Model): - """Properties of the operation. - - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Description of the operation. - :type description: str - """ - - _attribute_map = { - 'provider': {'key': 'provider', 'type': 'str'}, - 'resource': {'key': 'resource', 'type': 'str'}, - 'operation': {'key': 'operation', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationDisplay, self).__init__(**kwargs) - self.provider = kwargs.get('provider', None) - self.resource = kwargs.get('resource', None) - self.operation = kwargs.get('operation', None) - self.description = kwargs.get('description', None) - - -class OperationsList(msrest.serialization.Model): - """Lists the operations available. - - All required parameters must be populated in order to send to Azure. - - :param next_link: Url to follow for getting next page of operations. - :type next_link: str - :param value: Required. Array of operations. - :type value: list[~azure.mgmt.quantum.models.Operation] - """ - - _validation = { - 'value': {'required': True}, - } - - _attribute_map = { - 'next_link': {'key': 'nextLink', 'type': 'str'}, - 'value': {'key': 'value', 'type': '[Operation]'}, - } - - def __init__( - self, - **kwargs - ): - super(OperationsList, self).__init__(**kwargs) - self.next_link = kwargs.get('next_link', None) - self.value = kwargs['value'] - - -class PricingDetail(msrest.serialization.Model): - """Detailed pricing information for an sku. - - :param id: Unique id for this pricing information. - :type id: str - :param value: The unit cost of this sku. - :type value: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'value': {'key': 'value', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PricingDetail, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.value = kwargs.get('value', None) - - -class PricingDimension(msrest.serialization.Model): - """Information about pricing dimension. - - :param id: Unique id of this pricing dimension. - :type id: str - :param name: The display name of this pricing dimension. - :type name: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(PricingDimension, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - - -class Provider(msrest.serialization.Model): - """Information about a Provider. A Provider is an entity that offers Targets to run Azure Quantum Jobs. - - :param provider_id: Unique id of this provider. - :type provider_id: str - :param provider_sku: The sku associated with pricing information for this provider. - :type provider_sku: str - :param instance_uri: A Uri identifying the specific instance of this provider. - :type instance_uri: str - :param application_name: The provider's marketplace application display name. - :type application_name: str - :param provisioning_state: Provisioning status field. Possible values include: "Succeeded", - "Launching", "Updating", "Deleting", "Deleted", "Failed". - :type provisioning_state: str or ~azure.mgmt.quantum.models.Status - :param resource_usage_id: Id to track resource usage for the provider. - :type resource_usage_id: str - """ - - _attribute_map = { - 'provider_id': {'key': 'providerId', 'type': 'str'}, - 'provider_sku': {'key': 'providerSku', 'type': 'str'}, - 'instance_uri': {'key': 'instanceUri', 'type': 'str'}, - 'application_name': {'key': 'applicationName', 'type': 'str'}, - 'provisioning_state': {'key': 'provisioningState', 'type': 'str'}, - 'resource_usage_id': {'key': 'resourceUsageId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(Provider, self).__init__(**kwargs) - self.provider_id = kwargs.get('provider_id', None) - self.provider_sku = kwargs.get('provider_sku', None) - self.instance_uri = kwargs.get('instance_uri', None) - self.application_name = kwargs.get('application_name', None) - self.provisioning_state = kwargs.get('provisioning_state', None) - self.resource_usage_id = kwargs.get('resource_usage_id', None) - - -class ProviderDescription(msrest.serialization.Model): - """Information about an offering. A provider offering is an entity that offers Targets to run Azure Quantum Jobs. - - Variables are only populated by the server, and will be ignored when sending a request. - - :param id: Unique provider's id. - :type id: str - :ivar name: Provider's display name. - :vartype name: str - :param properties: A list of provider-specific properties. - :type properties: ~azure.mgmt.quantum.models.ProviderProperties - """ - - _validation = { - 'name': {'readonly': True}, - } - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'properties': {'key': 'properties', 'type': 'ProviderProperties'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderDescription, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = None - self.properties = kwargs.get('properties', None) - - -class ProviderProperties(msrest.serialization.Model): - """Provider properties. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar description: A description about this provider. - :vartype description: str - :ivar provider_type: Provider type. - :vartype provider_type: str - :ivar company: Company name. - :vartype company: str - :ivar default_endpoint: Provider's default endpoint. - :vartype default_endpoint: str - :param aad: Azure Active Directory info. - :type aad: ~azure.mgmt.quantum.models.ProviderPropertiesAad - :param managed_application: Provider's Managed-Application info. - :type managed_application: ~azure.mgmt.quantum.models.ProviderPropertiesManagedApplication - :param targets: The list of targets available from this provider. - :type targets: list[~azure.mgmt.quantum.models.TargetDescription] - :param skus: The list of skus available from this provider. - :type skus: list[~azure.mgmt.quantum.models.SkuDescription] - :param quota_dimensions: The list of quota dimensions from the provider. - :type quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] - :param pricing_dimensions: The list of pricing dimensions from the provider. - :type pricing_dimensions: list[~azure.mgmt.quantum.models.PricingDimension] - """ - - _validation = { - 'description': {'readonly': True}, - 'provider_type': {'readonly': True}, - 'company': {'readonly': True}, - 'default_endpoint': {'readonly': True}, - } - - _attribute_map = { - 'description': {'key': 'description', 'type': 'str'}, - 'provider_type': {'key': 'providerType', 'type': 'str'}, - 'company': {'key': 'company', 'type': 'str'}, - 'default_endpoint': {'key': 'defaultEndpoint', 'type': 'str'}, - 'aad': {'key': 'aad', 'type': 'ProviderPropertiesAad'}, - 'managed_application': {'key': 'managedApplication', 'type': 'ProviderPropertiesManagedApplication'}, - 'targets': {'key': 'targets', 'type': '[TargetDescription]'}, - 'skus': {'key': 'skus', 'type': '[SkuDescription]'}, - 'quota_dimensions': {'key': 'quotaDimensions', 'type': '[QuotaDimension]'}, - 'pricing_dimensions': {'key': 'pricingDimensions', 'type': '[PricingDimension]'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderProperties, self).__init__(**kwargs) - self.description = None - self.provider_type = None - self.company = None - self.default_endpoint = None - self.aad = kwargs.get('aad', None) - self.managed_application = kwargs.get('managed_application', None) - self.targets = kwargs.get('targets', None) - self.skus = kwargs.get('skus', None) - self.quota_dimensions = kwargs.get('quota_dimensions', None) - self.pricing_dimensions = kwargs.get('pricing_dimensions', None) - - -class ProviderPropertiesAad(msrest.serialization.Model): - """Azure Active Directory info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar application_id: Provider's application id. - :vartype application_id: str - :ivar tenant_id: Provider's tenant id. - :vartype tenant_id: str - """ - - _validation = { - 'application_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'application_id': {'key': 'applicationId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderPropertiesAad, self).__init__(**kwargs) - self.application_id = None - self.tenant_id = None - - -class ProviderPropertiesManagedApplication(msrest.serialization.Model): - """Provider's Managed-Application info. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar publisher_id: Provider's publisher id. - :vartype publisher_id: str - :ivar offer_id: Provider's offer id. - :vartype offer_id: str - """ - - _validation = { - 'publisher_id': {'readonly': True}, - 'offer_id': {'readonly': True}, - } - - _attribute_map = { - 'publisher_id': {'key': 'publisherId', 'type': 'str'}, - 'offer_id': {'key': 'offerId', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(ProviderPropertiesManagedApplication, self).__init__(**kwargs) - self.publisher_id = None - self.offer_id = None - - -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 QuantumWorkspace(TrackedResource): - """The resource proxy definition object for quantum workspace. - - 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 - :param identity: Managed Identity information. - :type identity: ~azure.mgmt.quantum.models.QuantumWorkspaceIdentity - :param providers: List of Providers selected for this Workspace. - :type providers: list[~azure.mgmt.quantum.models.Provider] - :ivar usable: Whether the current workspace is ready to accept Jobs. Possible values include: - "Yes", "No", "Partial". - :vartype usable: str or ~azure.mgmt.quantum.models.UsableStatus - :ivar provisioning_state: Provisioning status field. Possible values include: "Succeeded", - "ProviderLaunching", "ProviderUpdating", "ProviderDeleting", "ProviderProvisioning", "Failed". - :vartype provisioning_state: str or ~azure.mgmt.quantum.models.ProvisioningStatus - :param storage_account: ARM Resource Id of the storage account associated with this workspace. - :type storage_account: str - :ivar endpoint_uri: The URI of the workspace endpoint. - :vartype endpoint_uri: str - """ - - _validation = { - 'id': {'readonly': True}, - 'name': {'readonly': True}, - 'type': {'readonly': True}, - 'location': {'required': True}, - 'usable': {'readonly': True}, - 'provisioning_state': {'readonly': True}, - 'endpoint_uri': {'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'}, - 'identity': {'key': 'identity', 'type': 'QuantumWorkspaceIdentity'}, - 'providers': {'key': 'properties.providers', 'type': '[Provider]'}, - 'usable': {'key': 'properties.usable', 'type': 'str'}, - 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, - 'storage_account': {'key': 'properties.storageAccount', 'type': 'str'}, - 'endpoint_uri': {'key': 'properties.endpointUri', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuantumWorkspace, self).__init__(**kwargs) - self.identity = kwargs.get('identity', None) - self.providers = kwargs.get('providers', None) - self.usable = None - self.provisioning_state = None - self.storage_account = kwargs.get('storage_account', None) - self.endpoint_uri = None - - -class QuantumWorkspaceIdentity(msrest.serialization.Model): - """Managed Identity information. - - Variables are only populated by the server, and will be ignored when sending a request. - - :ivar principal_id: The principal ID of resource identity. - :vartype principal_id: str - :ivar tenant_id: The tenant ID of resource. - :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.quantum.models.ResourceIdentityType - """ - - _validation = { - 'principal_id': {'readonly': True}, - 'tenant_id': {'readonly': True}, - } - - _attribute_map = { - 'principal_id': {'key': 'principalId', 'type': 'str'}, - 'tenant_id': {'key': 'tenantId', 'type': 'str'}, - 'type': {'key': 'type', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuantumWorkspaceIdentity, self).__init__(**kwargs) - self.principal_id = None - self.tenant_id = None - self.type = kwargs.get('type', None) - - -class QuotaDimension(msrest.serialization.Model): - """Information about a specific quota dimension. - - :param id: Unique id of this dimension. - :type id: str - :param scope: The scope of this quota dimension. - :type scope: str - :param period: The reset period of this quota dimension. - :type period: str - :param quota: The max limit of this dimension. - :type quota: float - :param name: The display name of this quota dimension. - :type name: str - :param description: A description about this quota dimension. - :type description: str - :param unit: The standard unit of measurement used for this quota dimension. - :type unit: str - :param unit_plural: The standard unit of measurement used for this quota dimension in plural - form. - :type unit_plural: str - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'scope': {'key': 'scope', 'type': 'str'}, - 'period': {'key': 'period', 'type': 'str'}, - 'quota': {'key': 'quota', 'type': 'float'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'unit': {'key': 'unit', 'type': 'str'}, - 'unit_plural': {'key': 'unitPlural', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(QuotaDimension, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.scope = kwargs.get('scope', None) - self.period = kwargs.get('period', None) - self.quota = kwargs.get('quota', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.unit = kwargs.get('unit', None) - self.unit_plural = kwargs.get('unit_plural', None) - - -class SkuDescription(msrest.serialization.Model): - """Information about a specific sku. - - :param id: Unique sku id. - :type id: str - :param name: Display name of this sku. - :type name: str - :param description: Description about this sku. - :type description: str - :param targets: The list of targets available for this sku. - :type targets: list[str] - :param quota_dimensions: The list of quota dimensions for this sku. - :type quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] - :param pricing_details: The list of pricing details for the sku. - :type pricing_details: list[~azure.mgmt.quantum.models.PricingDetail] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'targets': {'key': 'targets', 'type': '[str]'}, - 'quota_dimensions': {'key': 'quotaDimensions', 'type': '[QuotaDimension]'}, - 'pricing_details': {'key': 'pricingDetails', 'type': '[PricingDetail]'}, - } - - def __init__( - self, - **kwargs - ): - super(SkuDescription, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.targets = kwargs.get('targets', None) - self.quota_dimensions = kwargs.get('quota_dimensions', None) - self.pricing_details = kwargs.get('pricing_details', None) - - -class TagsObject(msrest.serialization.Model): - """Tags object for patch operations. - - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] - """ - - _attribute_map = { - 'tags': {'key': 'tags', 'type': '{str}'}, - } - - def __init__( - self, - **kwargs - ): - super(TagsObject, self).__init__(**kwargs) - self.tags = kwargs.get('tags', None) - - -class TargetDescription(msrest.serialization.Model): - """Information about a Target. A target is the component that can process a specific type of Job. - - :param id: Unique target id. - :type id: str - :param name: Display name of this target. - :type name: str - :param description: A description about this target. - :type description: str - :param accepted_data_formats: List of data formats accepted by this target. - :type accepted_data_formats: list[str] - :param accepted_content_encodings: List of content encodings accepted by this target. - :type accepted_content_encodings: list[str] - """ - - _attribute_map = { - 'id': {'key': 'id', 'type': 'str'}, - 'name': {'key': 'name', 'type': 'str'}, - 'description': {'key': 'description', 'type': 'str'}, - 'accepted_data_formats': {'key': 'acceptedDataFormats', 'type': '[str]'}, - 'accepted_content_encodings': {'key': 'acceptedContentEncodings', 'type': '[str]'}, - } - - def __init__( - self, - **kwargs - ): - super(TargetDescription, self).__init__(**kwargs) - self.id = kwargs.get('id', None) - self.name = kwargs.get('name', None) - self.description = kwargs.get('description', None) - self.accepted_data_formats = kwargs.get('accepted_data_formats', None) - self.accepted_content_encodings = kwargs.get('accepted_content_encodings', None) - - -class WorkspaceListResult(msrest.serialization.Model): - """The response of a list Workspaces operation. - - :param value: Result of a list Workspaces operation. - :type value: list[~azure.mgmt.quantum.models.QuantumWorkspace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list - of Workspaces. - :type next_link: str - """ - - _attribute_map = { - 'value': {'key': 'value', 'type': '[QuantumWorkspace]'}, - 'next_link': {'key': 'nextLink', 'type': 'str'}, - } - - def __init__( - self, - **kwargs - ): - super(WorkspaceListResult, self).__init__(**kwargs) - self.value = kwargs.get('value', None) - self.next_link = kwargs.get('next_link', None) diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_models_py3.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_models_py3.py index f84895b188cf..55447f10a772 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_models_py3.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/models/_models_py3.py @@ -6,6 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import datetime from typing import Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError @@ -14,6 +15,80 @@ from ._azure_quantum_management_client_enums import * +class CheckNameAvailabilityParameters(msrest.serialization.Model): + """Details of check name availability request body. + + :ivar name: Name for checking availability. + :vartype name: str + :ivar type: The resource type of Quantum Workspace. + :vartype type: str + """ + + _attribute_map = { + 'name': {'key': 'name', 'type': 'str'}, + 'type': {'key': 'type', 'type': 'str'}, + } + + def __init__( + self, + *, + name: Optional[str] = None, + type: Optional[str] = "Microsoft.Quantum/Workspaces", + **kwargs + ): + """ + :keyword name: Name for checking availability. + :paramtype name: str + :keyword type: The resource type of Quantum Workspace. + :paramtype type: str + """ + super(CheckNameAvailabilityParameters, self).__init__(**kwargs) + self.name = name + self.type = type + + +class CheckNameAvailabilityResult(msrest.serialization.Model): + """Result of check name availability. + + Variables are only populated by the server, and will be ignored when sending a request. + + :ivar name_available: Indicator of availability of the Quantum Workspace resource name. + :vartype name_available: bool + :ivar reason: The reason of unavailability. + :vartype reason: str + :ivar message: The detailed info regarding the reason associated with the Namespace. + :vartype message: str + """ + + _validation = { + 'message': {'readonly': True}, + } + + _attribute_map = { + 'name_available': {'key': 'nameAvailable', 'type': 'bool'}, + 'reason': {'key': 'reason', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__( + self, + *, + name_available: Optional[bool] = None, + reason: Optional[str] = None, + **kwargs + ): + """ + :keyword name_available: Indicator of availability of the Quantum Workspace resource name. + :paramtype name_available: bool + :keyword reason: The reason of unavailability. + :paramtype reason: str + """ + super(CheckNameAvailabilityResult, self).__init__(**kwargs) + self.name_available = name_available + self.reason = reason + self.message = None + + class ErrorAdditionalInfo(msrest.serialization.Model): """The resource management error additional info. @@ -39,6 +114,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorAdditionalInfo, self).__init__(**kwargs) self.type = None self.info = None @@ -81,6 +158,8 @@ def __init__( self, **kwargs ): + """ + """ super(ErrorDetail, self).__init__(**kwargs) self.code = None self.message = None @@ -92,8 +171,8 @@ def __init__( class ErrorResponse(msrest.serialization.Model): """Common error response for all Azure Resource Manager APIs to return error details for failed operations. (This also follows the OData error response format.). - :param error: The error object. - :type error: ~azure.mgmt.quantum.models.ErrorDetail + :ivar error: The error object. + :vartype error: ~azure.mgmt.quantum.models.ErrorDetail """ _attribute_map = { @@ -106,6 +185,10 @@ def __init__( error: Optional["ErrorDetail"] = None, **kwargs ): + """ + :keyword error: The error object. + :paramtype error: ~azure.mgmt.quantum.models.ErrorDetail + """ super(ErrorResponse, self).__init__(**kwargs) self.error = error @@ -113,11 +196,11 @@ def __init__( class OfferingsListResult(msrest.serialization.Model): """The response of a list Providers operation. - :param value: Result of a list Providers operation. - :type value: list[~azure.mgmt.quantum.models.ProviderDescription] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of a list Providers operation. + :vartype value: list[~azure.mgmt.quantum.models.ProviderDescription] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Providers. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -132,6 +215,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of a list Providers operation. + :paramtype value: list[~azure.mgmt.quantum.models.ProviderDescription] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Providers. + :paramtype next_link: str + """ super(OfferingsListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link @@ -140,12 +230,12 @@ def __init__( class Operation(msrest.serialization.Model): """Operation provided by provider. - :param name: Name of the operation. - :type name: str - :param is_data_action: Indicates whether the operation is a data action. - :type is_data_action: bool - :param display: Properties of the operation. - :type display: ~azure.mgmt.quantum.models.OperationDisplay + :ivar name: Name of the operation. + :vartype name: str + :ivar is_data_action: Indicates whether the operation is a data action. + :vartype is_data_action: bool + :ivar display: Properties of the operation. + :vartype display: ~azure.mgmt.quantum.models.OperationDisplay """ _attribute_map = { @@ -162,6 +252,14 @@ def __init__( display: Optional["OperationDisplay"] = None, **kwargs ): + """ + :keyword name: Name of the operation. + :paramtype name: str + :keyword is_data_action: Indicates whether the operation is a data action. + :paramtype is_data_action: bool + :keyword display: Properties of the operation. + :paramtype display: ~azure.mgmt.quantum.models.OperationDisplay + """ super(Operation, self).__init__(**kwargs) self.name = name self.is_data_action = is_data_action @@ -171,14 +269,14 @@ def __init__( class OperationDisplay(msrest.serialization.Model): """Properties of the operation. - :param provider: Provider name. - :type provider: str - :param resource: Resource name. - :type resource: str - :param operation: Operation name. - :type operation: str - :param description: Description of the operation. - :type description: str + :ivar provider: Provider name. + :vartype provider: str + :ivar resource: Resource name. + :vartype resource: str + :ivar operation: Operation name. + :vartype operation: str + :ivar description: Description of the operation. + :vartype description: str """ _attribute_map = { @@ -197,6 +295,16 @@ def __init__( description: Optional[str] = None, **kwargs ): + """ + :keyword provider: Provider name. + :paramtype provider: str + :keyword resource: Resource name. + :paramtype resource: str + :keyword operation: Operation name. + :paramtype operation: str + :keyword description: Description of the operation. + :paramtype description: str + """ super(OperationDisplay, self).__init__(**kwargs) self.provider = provider self.resource = resource @@ -209,10 +317,10 @@ class OperationsList(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param next_link: Url to follow for getting next page of operations. - :type next_link: str - :param value: Required. Array of operations. - :type value: list[~azure.mgmt.quantum.models.Operation] + :ivar next_link: Url to follow for getting next page of operations. + :vartype next_link: str + :ivar value: Required. Array of operations. + :vartype value: list[~azure.mgmt.quantum.models.Operation] """ _validation = { @@ -231,6 +339,12 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword next_link: Url to follow for getting next page of operations. + :paramtype next_link: str + :keyword value: Required. Array of operations. + :paramtype value: list[~azure.mgmt.quantum.models.Operation] + """ super(OperationsList, self).__init__(**kwargs) self.next_link = next_link self.value = value @@ -239,10 +353,10 @@ def __init__( class PricingDetail(msrest.serialization.Model): """Detailed pricing information for an sku. - :param id: Unique id for this pricing information. - :type id: str - :param value: The unit cost of this sku. - :type value: str + :ivar id: Unique id for this pricing information. + :vartype id: str + :ivar value: The unit cost of this sku. + :vartype value: str """ _attribute_map = { @@ -257,6 +371,12 @@ def __init__( value: Optional[str] = None, **kwargs ): + """ + :keyword id: Unique id for this pricing information. + :paramtype id: str + :keyword value: The unit cost of this sku. + :paramtype value: str + """ super(PricingDetail, self).__init__(**kwargs) self.id = id self.value = value @@ -265,10 +385,10 @@ def __init__( class PricingDimension(msrest.serialization.Model): """Information about pricing dimension. - :param id: Unique id of this pricing dimension. - :type id: str - :param name: The display name of this pricing dimension. - :type name: str + :ivar id: Unique id of this pricing dimension. + :vartype id: str + :ivar name: The display name of this pricing dimension. + :vartype name: str """ _attribute_map = { @@ -283,6 +403,12 @@ def __init__( name: Optional[str] = None, **kwargs ): + """ + :keyword id: Unique id of this pricing dimension. + :paramtype id: str + :keyword name: The display name of this pricing dimension. + :paramtype name: str + """ super(PricingDimension, self).__init__(**kwargs) self.id = id self.name = name @@ -291,19 +417,19 @@ def __init__( class Provider(msrest.serialization.Model): """Information about a Provider. A Provider is an entity that offers Targets to run Azure Quantum Jobs. - :param provider_id: Unique id of this provider. - :type provider_id: str - :param provider_sku: The sku associated with pricing information for this provider. - :type provider_sku: str - :param instance_uri: A Uri identifying the specific instance of this provider. - :type instance_uri: str - :param application_name: The provider's marketplace application display name. - :type application_name: str - :param provisioning_state: Provisioning status field. Possible values include: "Succeeded", + :ivar provider_id: Unique id of this provider. + :vartype provider_id: str + :ivar provider_sku: The sku associated with pricing information for this provider. + :vartype provider_sku: str + :ivar instance_uri: A Uri identifying the specific instance of this provider. + :vartype instance_uri: str + :ivar application_name: The provider's marketplace application display name. + :vartype application_name: str + :ivar provisioning_state: Provisioning status field. Possible values include: "Succeeded", "Launching", "Updating", "Deleting", "Deleted", "Failed". - :type provisioning_state: str or ~azure.mgmt.quantum.models.Status - :param resource_usage_id: Id to track resource usage for the provider. - :type resource_usage_id: str + :vartype provisioning_state: str or ~azure.mgmt.quantum.models.Status + :ivar resource_usage_id: Id to track resource usage for the provider. + :vartype resource_usage_id: str """ _attribute_map = { @@ -326,6 +452,21 @@ def __init__( resource_usage_id: Optional[str] = None, **kwargs ): + """ + :keyword provider_id: Unique id of this provider. + :paramtype provider_id: str + :keyword provider_sku: The sku associated with pricing information for this provider. + :paramtype provider_sku: str + :keyword instance_uri: A Uri identifying the specific instance of this provider. + :paramtype instance_uri: str + :keyword application_name: The provider's marketplace application display name. + :paramtype application_name: str + :keyword provisioning_state: Provisioning status field. Possible values include: "Succeeded", + "Launching", "Updating", "Deleting", "Deleted", "Failed". + :paramtype provisioning_state: str or ~azure.mgmt.quantum.models.Status + :keyword resource_usage_id: Id to track resource usage for the provider. + :paramtype resource_usage_id: str + """ super(Provider, self).__init__(**kwargs) self.provider_id = provider_id self.provider_sku = provider_sku @@ -340,12 +481,12 @@ class ProviderDescription(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. - :param id: Unique provider's id. - :type id: str + :ivar id: Unique provider's id. + :vartype id: str :ivar name: Provider's display name. :vartype name: str - :param properties: A list of provider-specific properties. - :type properties: ~azure.mgmt.quantum.models.ProviderProperties + :ivar properties: A list of provider-specific properties. + :vartype properties: ~azure.mgmt.quantum.models.ProviderProperties """ _validation = { @@ -365,6 +506,12 @@ def __init__( properties: Optional["ProviderProperties"] = None, **kwargs ): + """ + :keyword id: Unique provider's id. + :paramtype id: str + :keyword properties: A list of provider-specific properties. + :paramtype properties: ~azure.mgmt.quantum.models.ProviderProperties + """ super(ProviderDescription, self).__init__(**kwargs) self.id = id self.name = None @@ -384,18 +531,18 @@ class ProviderProperties(msrest.serialization.Model): :vartype company: str :ivar default_endpoint: Provider's default endpoint. :vartype default_endpoint: str - :param aad: Azure Active Directory info. - :type aad: ~azure.mgmt.quantum.models.ProviderPropertiesAad - :param managed_application: Provider's Managed-Application info. - :type managed_application: ~azure.mgmt.quantum.models.ProviderPropertiesManagedApplication - :param targets: The list of targets available from this provider. - :type targets: list[~azure.mgmt.quantum.models.TargetDescription] - :param skus: The list of skus available from this provider. - :type skus: list[~azure.mgmt.quantum.models.SkuDescription] - :param quota_dimensions: The list of quota dimensions from the provider. - :type quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] - :param pricing_dimensions: The list of pricing dimensions from the provider. - :type pricing_dimensions: list[~azure.mgmt.quantum.models.PricingDimension] + :ivar aad: Azure Active Directory info. + :vartype aad: ~azure.mgmt.quantum.models.ProviderPropertiesAad + :ivar managed_application: Provider's Managed-Application info. + :vartype managed_application: ~azure.mgmt.quantum.models.ProviderPropertiesManagedApplication + :ivar targets: The list of targets available from this provider. + :vartype targets: list[~azure.mgmt.quantum.models.TargetDescription] + :ivar skus: The list of skus available from this provider. + :vartype skus: list[~azure.mgmt.quantum.models.SkuDescription] + :ivar quota_dimensions: The list of quota dimensions from the provider. + :vartype quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] + :ivar pricing_dimensions: The list of pricing dimensions from the provider. + :vartype pricing_dimensions: list[~azure.mgmt.quantum.models.PricingDimension] """ _validation = { @@ -429,6 +576,20 @@ def __init__( pricing_dimensions: Optional[List["PricingDimension"]] = None, **kwargs ): + """ + :keyword aad: Azure Active Directory info. + :paramtype aad: ~azure.mgmt.quantum.models.ProviderPropertiesAad + :keyword managed_application: Provider's Managed-Application info. + :paramtype managed_application: ~azure.mgmt.quantum.models.ProviderPropertiesManagedApplication + :keyword targets: The list of targets available from this provider. + :paramtype targets: list[~azure.mgmt.quantum.models.TargetDescription] + :keyword skus: The list of skus available from this provider. + :paramtype skus: list[~azure.mgmt.quantum.models.SkuDescription] + :keyword quota_dimensions: The list of quota dimensions from the provider. + :paramtype quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] + :keyword pricing_dimensions: The list of pricing dimensions from the provider. + :paramtype pricing_dimensions: list[~azure.mgmt.quantum.models.PricingDimension] + """ super(ProviderProperties, self).__init__(**kwargs) self.description = None self.provider_type = None @@ -467,6 +628,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProviderPropertiesAad, self).__init__(**kwargs) self.application_id = None self.tenant_id = None @@ -497,6 +660,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProviderPropertiesManagedApplication, self).__init__(**kwargs) self.publisher_id = None self.offer_id = None @@ -533,6 +698,8 @@ def __init__( self, **kwargs ): + """ + """ super(Resource, self).__init__(**kwargs) self.id = None self.name = None @@ -554,10 +721,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 = { @@ -582,6 +749,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 @@ -602,22 +775,24 @@ class QuantumWorkspace(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 - :param identity: Managed Identity information. - :type identity: ~azure.mgmt.quantum.models.QuantumWorkspaceIdentity - :param providers: List of Providers selected for this Workspace. - :type providers: list[~azure.mgmt.quantum.models.Provider] + :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 identity: Managed Identity information. + :vartype identity: ~azure.mgmt.quantum.models.QuantumWorkspaceIdentity + :ivar system_data: System metadata. + :vartype system_data: ~azure.mgmt.quantum.models.SystemData + :ivar providers: List of Providers selected for this Workspace. + :vartype providers: list[~azure.mgmt.quantum.models.Provider] :ivar usable: Whether the current workspace is ready to accept Jobs. Possible values include: "Yes", "No", "Partial". :vartype usable: str or ~azure.mgmt.quantum.models.UsableStatus :ivar provisioning_state: Provisioning status field. Possible values include: "Succeeded", "ProviderLaunching", "ProviderUpdating", "ProviderDeleting", "ProviderProvisioning", "Failed". :vartype provisioning_state: str or ~azure.mgmt.quantum.models.ProvisioningStatus - :param storage_account: ARM Resource Id of the storage account associated with this workspace. - :type storage_account: str + :ivar storage_account: ARM Resource Id of the storage account associated with this workspace. + :vartype storage_account: str :ivar endpoint_uri: The URI of the workspace endpoint. :vartype endpoint_uri: str """ @@ -627,6 +802,7 @@ class QuantumWorkspace(TrackedResource): 'name': {'readonly': True}, 'type': {'readonly': True}, 'location': {'required': True}, + 'system_data': {'readonly': True}, 'usable': {'readonly': True}, 'provisioning_state': {'readonly': True}, 'endpoint_uri': {'readonly': True}, @@ -639,6 +815,7 @@ class QuantumWorkspace(TrackedResource): 'tags': {'key': 'tags', 'type': '{str}'}, 'location': {'key': 'location', 'type': 'str'}, 'identity': {'key': 'identity', 'type': 'QuantumWorkspaceIdentity'}, + 'system_data': {'key': 'systemData', 'type': 'SystemData'}, 'providers': {'key': 'properties.providers', 'type': '[Provider]'}, 'usable': {'key': 'properties.usable', 'type': 'str'}, 'provisioning_state': {'key': 'properties.provisioningState', 'type': 'str'}, @@ -656,8 +833,22 @@ def __init__( storage_account: 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 identity: Managed Identity information. + :paramtype identity: ~azure.mgmt.quantum.models.QuantumWorkspaceIdentity + :keyword providers: List of Providers selected for this Workspace. + :paramtype providers: list[~azure.mgmt.quantum.models.Provider] + :keyword storage_account: ARM Resource Id of the storage account associated with this + workspace. + :paramtype storage_account: str + """ super(QuantumWorkspace, self).__init__(tags=tags, location=location, **kwargs) self.identity = identity + self.system_data = None self.providers = providers self.usable = None self.provisioning_state = None @@ -674,8 +865,8 @@ class QuantumWorkspaceIdentity(msrest.serialization.Model): :vartype principal_id: str :ivar tenant_id: The tenant ID of resource. :vartype tenant_id: str - :param type: The identity type. Possible values include: "SystemAssigned", "None". - :type type: str or ~azure.mgmt.quantum.models.ResourceIdentityType + :ivar type: The identity type. Possible values include: "SystemAssigned", "None". + :vartype type: str or ~azure.mgmt.quantum.models.ResourceIdentityType """ _validation = { @@ -695,6 +886,10 @@ def __init__( type: Optional[Union[str, "ResourceIdentityType"]] = None, **kwargs ): + """ + :keyword type: The identity type. Possible values include: "SystemAssigned", "None". + :paramtype type: str or ~azure.mgmt.quantum.models.ResourceIdentityType + """ super(QuantumWorkspaceIdentity, self).__init__(**kwargs) self.principal_id = None self.tenant_id = None @@ -704,23 +899,23 @@ def __init__( class QuotaDimension(msrest.serialization.Model): """Information about a specific quota dimension. - :param id: Unique id of this dimension. - :type id: str - :param scope: The scope of this quota dimension. - :type scope: str - :param period: The reset period of this quota dimension. - :type period: str - :param quota: The max limit of this dimension. - :type quota: float - :param name: The display name of this quota dimension. - :type name: str - :param description: A description about this quota dimension. - :type description: str - :param unit: The standard unit of measurement used for this quota dimension. - :type unit: str - :param unit_plural: The standard unit of measurement used for this quota dimension in plural + :ivar id: Unique id of this dimension. + :vartype id: str + :ivar scope: The scope of this quota dimension. + :vartype scope: str + :ivar period: The reset period of this quota dimension. + :vartype period: str + :ivar quota: The max limit of this dimension. + :vartype quota: float + :ivar name: The display name of this quota dimension. + :vartype name: str + :ivar description: A description about this quota dimension. + :vartype description: str + :ivar unit: The standard unit of measurement used for this quota dimension. + :vartype unit: str + :ivar unit_plural: The standard unit of measurement used for this quota dimension in plural form. - :type unit_plural: str + :vartype unit_plural: str """ _attribute_map = { @@ -747,6 +942,25 @@ def __init__( unit_plural: Optional[str] = None, **kwargs ): + """ + :keyword id: Unique id of this dimension. + :paramtype id: str + :keyword scope: The scope of this quota dimension. + :paramtype scope: str + :keyword period: The reset period of this quota dimension. + :paramtype period: str + :keyword quota: The max limit of this dimension. + :paramtype quota: float + :keyword name: The display name of this quota dimension. + :paramtype name: str + :keyword description: A description about this quota dimension. + :paramtype description: str + :keyword unit: The standard unit of measurement used for this quota dimension. + :paramtype unit: str + :keyword unit_plural: The standard unit of measurement used for this quota dimension in plural + form. + :paramtype unit_plural: str + """ super(QuotaDimension, self).__init__(**kwargs) self.id = id self.scope = scope @@ -761,24 +975,34 @@ def __init__( class SkuDescription(msrest.serialization.Model): """Information about a specific sku. - :param id: Unique sku id. - :type id: str - :param name: Display name of this sku. - :type name: str - :param description: Description about this sku. - :type description: str - :param targets: The list of targets available for this sku. - :type targets: list[str] - :param quota_dimensions: The list of quota dimensions for this sku. - :type quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] - :param pricing_details: The list of pricing details for the sku. - :type pricing_details: list[~azure.mgmt.quantum.models.PricingDetail] + :ivar id: Unique sku id. + :vartype id: str + :ivar name: Display name of this sku. + :vartype name: str + :ivar version: Display name of this sku. + :vartype version: str + :ivar description: Description about this sku. + :vartype description: str + :ivar restricted_access_uri: Uri to subscribe to the restricted access sku. + :vartype restricted_access_uri: str + :ivar auto_add: Flag to indicate whether the sku should be automatically added during workspace + creation. + :vartype auto_add: bool + :ivar targets: The list of targets available for this sku. + :vartype targets: list[str] + :ivar quota_dimensions: The list of quota dimensions for this sku. + :vartype quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] + :ivar pricing_details: The list of pricing details for the sku. + :vartype pricing_details: list[~azure.mgmt.quantum.models.PricingDetail] """ _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, 'name': {'key': 'name', 'type': 'str'}, + 'version': {'key': 'version', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, + 'restricted_access_uri': {'key': 'restrictedAccessUri', 'type': 'str'}, + 'auto_add': {'key': 'autoAdd', 'type': 'bool'}, 'targets': {'key': 'targets', 'type': '[str]'}, 'quota_dimensions': {'key': 'quotaDimensions', 'type': '[QuotaDimension]'}, 'pricing_details': {'key': 'pricingDetails', 'type': '[PricingDetail]'}, @@ -789,26 +1013,117 @@ def __init__( *, id: Optional[str] = None, name: Optional[str] = None, + version: Optional[str] = None, description: Optional[str] = None, + restricted_access_uri: Optional[str] = None, + auto_add: Optional[bool] = None, targets: Optional[List[str]] = None, quota_dimensions: Optional[List["QuotaDimension"]] = None, pricing_details: Optional[List["PricingDetail"]] = None, **kwargs ): + """ + :keyword id: Unique sku id. + :paramtype id: str + :keyword name: Display name of this sku. + :paramtype name: str + :keyword version: Display name of this sku. + :paramtype version: str + :keyword description: Description about this sku. + :paramtype description: str + :keyword restricted_access_uri: Uri to subscribe to the restricted access sku. + :paramtype restricted_access_uri: str + :keyword auto_add: Flag to indicate whether the sku should be automatically added during + workspace creation. + :paramtype auto_add: bool + :keyword targets: The list of targets available for this sku. + :paramtype targets: list[str] + :keyword quota_dimensions: The list of quota dimensions for this sku. + :paramtype quota_dimensions: list[~azure.mgmt.quantum.models.QuotaDimension] + :keyword pricing_details: The list of pricing details for the sku. + :paramtype pricing_details: list[~azure.mgmt.quantum.models.PricingDetail] + """ super(SkuDescription, self).__init__(**kwargs) self.id = id self.name = name + self.version = version self.description = description + self.restricted_access_uri = restricted_access_uri + self.auto_add = auto_add self.targets = targets self.quota_dimensions = quota_dimensions self.pricing_details = pricing_details +class SystemData(msrest.serialization.Model): + """Metadata pertaining to creation and last modification of the resource. + + :ivar created_by: The identity that created the resource. + :vartype created_by: str + :ivar created_by_type: The type of identity that created the resource. Possible values include: + "User", "Application", "ManagedIdentity", "Key". + :vartype created_by_type: str or ~azure.mgmt.quantum.models.CreatedByType + :ivar created_at: The timestamp of resource creation (UTC). + :vartype created_at: ~datetime.datetime + :ivar last_modified_by: The identity that last modified the resource. + :vartype last_modified_by: str + :ivar last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :vartype last_modified_by_type: str or ~azure.mgmt.quantum.models.CreatedByType + :ivar last_modified_at: The timestamp of resource last modification (UTC). + :vartype last_modified_at: ~datetime.datetime + """ + + _attribute_map = { + 'created_by': {'key': 'createdBy', 'type': 'str'}, + 'created_by_type': {'key': 'createdByType', 'type': 'str'}, + 'created_at': {'key': 'createdAt', 'type': 'iso-8601'}, + 'last_modified_by': {'key': 'lastModifiedBy', 'type': 'str'}, + 'last_modified_by_type': {'key': 'lastModifiedByType', 'type': 'str'}, + 'last_modified_at': {'key': 'lastModifiedAt', 'type': 'iso-8601'}, + } + + def __init__( + self, + *, + created_by: Optional[str] = None, + created_by_type: Optional[Union[str, "CreatedByType"]] = None, + created_at: Optional[datetime.datetime] = None, + last_modified_by: Optional[str] = None, + last_modified_by_type: Optional[Union[str, "CreatedByType"]] = None, + last_modified_at: Optional[datetime.datetime] = None, + **kwargs + ): + """ + :keyword created_by: The identity that created the resource. + :paramtype created_by: str + :keyword created_by_type: The type of identity that created the resource. Possible values + include: "User", "Application", "ManagedIdentity", "Key". + :paramtype created_by_type: str or ~azure.mgmt.quantum.models.CreatedByType + :keyword created_at: The timestamp of resource creation (UTC). + :paramtype created_at: ~datetime.datetime + :keyword last_modified_by: The identity that last modified the resource. + :paramtype last_modified_by: str + :keyword last_modified_by_type: The type of identity that last modified the resource. Possible + values include: "User", "Application", "ManagedIdentity", "Key". + :paramtype last_modified_by_type: str or ~azure.mgmt.quantum.models.CreatedByType + :keyword last_modified_at: The timestamp of resource last modification (UTC). + :paramtype last_modified_at: ~datetime.datetime + """ + super(SystemData, self).__init__(**kwargs) + self.created_by = created_by + self.created_by_type = created_by_type + self.created_at = created_at + self.last_modified_by = last_modified_by + self.last_modified_by_type = last_modified_by_type + self.last_modified_at = last_modified_at + + class TagsObject(msrest.serialization.Model): """Tags object for patch operations. - :param tags: A set of tags. Resource tags. - :type tags: dict[str, str] + :ivar tags: A set of tags. Resource tags. + :vartype tags: dict[str, str] """ _attribute_map = { @@ -821,6 +1136,10 @@ def __init__( tags: Optional[Dict[str, str]] = None, **kwargs ): + """ + :keyword tags: A set of tags. Resource tags. + :paramtype tags: dict[str, str] + """ super(TagsObject, self).__init__(**kwargs) self.tags = tags @@ -828,20 +1147,23 @@ def __init__( class TargetDescription(msrest.serialization.Model): """Information about a Target. A target is the component that can process a specific type of Job. - :param id: Unique target id. - :type id: str - :param name: Display name of this target. - :type name: str - :param description: A description about this target. - :type description: str - :param accepted_data_formats: List of data formats accepted by this target. - :type accepted_data_formats: list[str] - :param accepted_content_encodings: List of content encodings accepted by this target. - :type accepted_content_encodings: list[str] + :ivar id: Unique target id. + :vartype id: str + :ivar aliases: The list of aliases for the target. + :vartype aliases: list[str] + :ivar name: Display name of this target. + :vartype name: str + :ivar description: A description about this target. + :vartype description: str + :ivar accepted_data_formats: List of data formats accepted by this target. + :vartype accepted_data_formats: list[str] + :ivar accepted_content_encodings: List of content encodings accepted by this target. + :vartype accepted_content_encodings: list[str] """ _attribute_map = { 'id': {'key': 'id', 'type': 'str'}, + 'aliases': {'key': 'aliases', 'type': '[str]'}, 'name': {'key': 'name', 'type': 'str'}, 'description': {'key': 'description', 'type': 'str'}, 'accepted_data_formats': {'key': 'acceptedDataFormats', 'type': '[str]'}, @@ -852,14 +1174,30 @@ def __init__( self, *, id: Optional[str] = None, + aliases: Optional[List[str]] = None, name: Optional[str] = None, description: Optional[str] = None, accepted_data_formats: Optional[List[str]] = None, accepted_content_encodings: Optional[List[str]] = None, **kwargs ): + """ + :keyword id: Unique target id. + :paramtype id: str + :keyword aliases: The list of aliases for the target. + :paramtype aliases: list[str] + :keyword name: Display name of this target. + :paramtype name: str + :keyword description: A description about this target. + :paramtype description: str + :keyword accepted_data_formats: List of data formats accepted by this target. + :paramtype accepted_data_formats: list[str] + :keyword accepted_content_encodings: List of content encodings accepted by this target. + :paramtype accepted_content_encodings: list[str] + """ super(TargetDescription, self).__init__(**kwargs) self.id = id + self.aliases = aliases self.name = name self.description = description self.accepted_data_formats = accepted_data_formats @@ -869,11 +1207,11 @@ def __init__( class WorkspaceListResult(msrest.serialization.Model): """The response of a list Workspaces operation. - :param value: Result of a list Workspaces operation. - :type value: list[~azure.mgmt.quantum.models.QuantumWorkspace] - :param next_link: Link to the next set of results. Not empty if Value contains incomplete list + :ivar value: Result of a list Workspaces operation. + :vartype value: list[~azure.mgmt.quantum.models.QuantumWorkspace] + :ivar next_link: Link to the next set of results. Not empty if Value contains incomplete list of Workspaces. - :type next_link: str + :vartype next_link: str """ _attribute_map = { @@ -888,6 +1226,13 @@ def __init__( next_link: Optional[str] = None, **kwargs ): + """ + :keyword value: Result of a list Workspaces operation. + :paramtype value: list[~azure.mgmt.quantum.models.QuantumWorkspace] + :keyword next_link: Link to the next set of results. Not empty if Value contains incomplete + list of Workspaces. + :paramtype next_link: str + """ super(WorkspaceListResult, self).__init__(**kwargs) self.value = value self.next_link = next_link diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/__init__.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/__init__.py index be714f399997..7eae3e8df6c1 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/__init__.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/__init__.py @@ -9,9 +9,11 @@ from ._workspaces_operations import WorkspacesOperations from ._offerings_operations import OfferingsOperations from ._operations import Operations +from ._workspace_operations import WorkspaceOperations __all__ = [ 'WorkspacesOperations', 'OfferingsOperations', 'Operations', + 'WorkspaceOperations', ] diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_offerings_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_offerings_operations.py index 4f947bcc9c85..973e04087bb8 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_offerings_operations.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_offerings_operations.py @@ -5,23 +5,58 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_list_request( + subscription_id: str, + location_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Quantum/locations/{locationName}/offerings') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "locationName": _SERIALIZER.url("location_name", location_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class OfferingsOperations(object): """OfferingsOperations operations. @@ -45,12 +80,12 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, - location_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.OfferingsListResult"] + location_name: str, + **kwargs: Any + ) -> Iterable["_models.OfferingsListResult"]: """Returns the list of all provider offerings available for the given location. :param location_name: Location. @@ -65,35 +100,31 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'locationName': self._serialize.url("location_name", location_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + location_name=location_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('OfferingsListResult', pipeline_response) + deserialized = self._deserialize("OfferingsListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -106,12 +137,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_operations.py index e1c5ea4d3114..0bb87e296eac 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_operations.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/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 = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/providers/Microsoft.Quantum/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.OperationsList"] + **kwargs: Any + ) -> Iterable["_models.OperationsList"]: """Returns list of 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 = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') + + request = build_list_request( + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.get(url, query_parameters, header_parameters) else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('OperationsList', pipeline_response) + deserialized = self._deserialize("OperationsList", 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 ) diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_workspace_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_workspace_operations.py new file mode 100644 index 000000000000..438b2d74936c --- /dev/null +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_workspace_operations.py @@ -0,0 +1,147 @@ +# 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. +# -------------------------------------------------------------------------- +import functools +from typing import Any, Callable, Dict, Generic, Optional, TypeVar +import warnings + +from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error +from azure.core.pipeline import PipelineResponse +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from azure.mgmt.core.exceptions import ARMErrorFormat +from msrest import Serializer + +from .. import models as _models +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_check_name_availability_request( + subscription_id: str, + location_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Quantum/locations/{locationName}/checkNameAvailability') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "locationName": _SERIALIZER.url("location_name", location_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="POST", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + +class WorkspaceOperations(object): + """WorkspaceOperations operations. + + You should not instantiate this class directly. Instead, you should create a Client instance that + instantiates it for you and attaches it as an attribute. + + :ivar models: Alias to model classes used in this operation group. + :type models: ~azure.mgmt.quantum.models + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = _models + + def __init__(self, client, config, serializer, deserializer): + self._client = client + self._serialize = serializer + self._deserialize = deserializer + self._config = config + + @distributed_trace + def check_name_availability( + self, + location_name: str, + check_name_availability_parameters: "_models.CheckNameAvailabilityParameters", + **kwargs: Any + ) -> "_models.CheckNameAvailabilityResult": + """Check the availability of the resource name. + + :param location_name: Location. + :type location_name: str + :param check_name_availability_parameters: The name and type of the resource. + :type check_name_availability_parameters: + ~azure.mgmt.quantum.models.CheckNameAvailabilityParameters + :keyword callable cls: A custom type or function that will be passed the direct response + :return: CheckNameAvailabilityResult, or the result of cls(response) + :rtype: ~azure.mgmt.quantum.models.CheckNameAvailabilityResult + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType["_models.CheckNameAvailabilityResult"] + error_map = { + 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError + } + error_map.update(kwargs.pop('error_map', {})) + + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(check_name_availability_parameters, 'CheckNameAvailabilityParameters') + + request = build_check_name_availability_request( + subscription_id=self._config.subscription_id, + location_name=location_name, + content_type=content_type, + json=_json, + template_url=self.check_name_availability.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + + pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) + response = pipeline_response.http_response + + if response.status_code not in [200]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, pipeline_response) + raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + + deserialized = self._deserialize('CheckNameAvailabilityResult', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + check_name_availability.metadata = {'url': '/subscriptions/{subscriptionId}/providers/Microsoft.Quantum/locations/{locationName}/checkNameAvailability'} # type: ignore + diff --git a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_workspaces_operations.py b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_workspaces_operations.py index e0a88dfb1969..3dcc8181b3ee 100644 --- a/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_workspaces_operations.py +++ b/sdk/quantum/azure-mgmt-quantum/azure/mgmt/quantum/operations/_workspaces_operations.py @@ -5,25 +5,250 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import TYPE_CHECKING +import functools +from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.paging import ItemPaged from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse +from azure.core.pipeline.transport import HttpResponse from azure.core.polling import LROPoller, NoPolling, PollingMethod +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace from azure.mgmt.core.exceptions import ARMErrorFormat from azure.mgmt.core.polling.arm_polling import ARMPolling +from msrest import Serializer from .. import models as _models - -if TYPE_CHECKING: - # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - - T = TypeVar('T') - ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +from .._vendor import _convert_request, _format_url_section +T = TypeVar('T') +JSONType = Any +ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] + +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False + +def build_get_request( + resource_group_name: str, + subscription_id: str, + workspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_create_or_update_request_initial( + resource_group_name: str, + subscription_id: str, + workspace_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PUT", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_update_tags_request( + resource_group_name: str, + subscription_id: str, + workspace_name: str, + *, + json: JSONType = None, + content: Any = None, + **kwargs: Any +) -> HttpRequest: + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + if content_type is not None: + header_parameters['Content-Type'] = _SERIALIZER.header("content_type", content_type, 'str') + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="PATCH", + url=url, + params=query_parameters, + headers=header_parameters, + json=json, + content=content, + **kwargs + ) + + +def build_delete_request_initial( + resource_group_name: str, + subscription_id: str, + workspace_name: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="DELETE", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_subscription_request( + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/providers/Microsoft.Quantum/workspaces') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) + + +def build_list_by_resource_group_request( + resource_group_name: str, + subscription_id: str, + **kwargs: Any +) -> HttpRequest: + api_version = "2022-04-05-preview" + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces') + path_format_arguments = { + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # Construct parameters + query_parameters = kwargs.pop("params", {}) # type: Dict[str, Any] + query_parameters['api-version'] = _SERIALIZER.query("api_version", api_version, 'str') + + # Construct headers + header_parameters = kwargs.pop("headers", {}) # type: Dict[str, Any] + header_parameters['Accept'] = _SERIALIZER.header("accept", accept, 'str') + + return HttpRequest( + method="GET", + url=url, + params=query_parameters, + headers=header_parameters, + **kwargs + ) class WorkspacesOperations(object): """WorkspacesOperations operations. @@ -47,13 +272,13 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get( self, - resource_group_name, # type: str - workspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> "_models.QuantumWorkspace" + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> "_models.QuantumWorkspace": """Returns the Workspace resource associated with the given name. :param resource_group_name: The name of the resource group. @@ -70,33 +295,23 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_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( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_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('QuantumWorkspace', pipeline_response) @@ -105,54 +320,44 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + def _create_or_update_initial( self, - resource_group_name, # type: str - workspace_name, # type: str - quantum_workspace, # type: "_models.QuantumWorkspace" - **kwargs # type: Any - ): - # type: (...) -> "_models.QuantumWorkspace" + resource_group_name: str, + workspace_name: str, + quantum_workspace: "_models.QuantumWorkspace", + **kwargs: Any + ) -> "_models.QuantumWorkspace": cls = kwargs.pop('cls', None) # type: ClsType["_models.QuantumWorkspace"] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self._create_or_update_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_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(quantum_workspace, 'QuantumWorkspace') + + request = build_create_or_update_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self._create_or_update_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - body_content_kwargs = {} # type: Dict[str, Any] - body_content = self._serialize.body(quantum_workspace, 'QuantumWorkspace') - body_content_kwargs['content'] = body_content - request = self._client.put(url, query_parameters, header_parameters, **body_content_kwargs) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 201]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if response.status_code == 200: deserialized = self._deserialize('QuantumWorkspace', pipeline_response) @@ -164,16 +369,18 @@ def _create_or_update_initial( return cls(pipeline_response, deserialized, {}) return deserialized + _create_or_update_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + + @distributed_trace def begin_create_or_update( self, - resource_group_name, # type: str - workspace_name, # type: str - quantum_workspace, # type: "_models.QuantumWorkspace" - **kwargs # type: Any - ): - # type: (...) -> LROPoller["_models.QuantumWorkspace"] + resource_group_name: str, + workspace_name: str, + quantum_workspace: "_models.QuantumWorkspace", + **kwargs: Any + ) -> LROPoller["_models.QuantumWorkspace"]: """Creates or updates a workspace resource. :param resource_group_name: The name of the resource group. @@ -184,15 +391,19 @@ def begin_create_or_update( :type quantum_workspace: ~azure.mgmt.quantum.models.QuantumWorkspace :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. - :return: An instance of LROPoller that returns either QuantumWorkspace or the result of cls(response) + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. + :return: An instance of LROPoller that returns either QuantumWorkspace or the result of + cls(response) :rtype: ~azure.core.polling.LROPoller[~azure.mgmt.quantum.models.QuantumWorkspace] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType["_models.QuantumWorkspace"] lro_delay = kwargs.pop( 'polling_interval', @@ -204,27 +415,21 @@ def begin_create_or_update( resource_group_name=resource_group_name, workspace_name=workspace_name, quantum_workspace=quantum_workspace, + content_type=content_type, cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): + response = pipeline_response.http_response deserialized = self._deserialize('QuantumWorkspace', pipeline_response) - if cls: return cls(pipeline_response, deserialized, {}) return deserialized - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, lro_options={'final-state-via': 'azure-async-operation'}, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -236,16 +441,17 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_create_or_update.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + @distributed_trace def update_tags( self, - resource_group_name, # type: str - workspace_name, # type: str - workspace_tags, # type: "_models.TagsObject" - **kwargs # type: Any - ): - # type: (...) -> "_models.QuantumWorkspace" + resource_group_name: str, + workspace_name: str, + workspace_tags: "_models.TagsObject", + **kwargs: Any + ) -> "_models.QuantumWorkspace": """Updates an existing workspace's tags. :param resource_group_name: The name of the resource group. @@ -264,38 +470,28 @@ def update_tags( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.update_tags.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_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(workspace_tags, 'TagsObject') + + request = build_update_tags_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_name, + content_type=content_type, + json=_json, + template_url=self.update_tags.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(workspace_tags, 'TagsObject') - 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('QuantumWorkspace', pipeline_response) @@ -304,61 +500,52 @@ def update_tags( return cls(pipeline_response, deserialized, {}) return deserialized + update_tags.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + def _delete_initial( self, - resource_group_name, # type: str - workspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> None + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> None: cls = kwargs.pop('cls', None) # type: ClsType[None] error_map = { 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - - # Construct URL - url = self._delete_initial.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_delete_request_initial( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + workspace_name=workspace_name, + template_url=self._delete_initial.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) - request = self._client.delete(url, query_parameters, header_parameters) pipeline_response = self._client._pipeline.run(request, stream=False, **kwargs) response = pipeline_response.http_response if response.status_code not in [200, 202, 204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.ErrorResponse, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + raise HttpResponseError(response=response, error_format=ARMErrorFormat) if cls: return cls(pipeline_response, None, {}) _delete_initial.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + + @distributed_trace def begin_delete( self, - resource_group_name, # type: str - workspace_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> LROPoller[None] + resource_group_name: str, + workspace_name: str, + **kwargs: Any + ) -> LROPoller[None]: """Deletes a Workspace resource. :param resource_group_name: The name of the resource group. @@ -367,15 +554,17 @@ def begin_delete( :type workspace_name: str :keyword callable cls: A custom type or function that will be passed the direct response :keyword str continuation_token: A continuation token to restart a poller from a saved state. - :keyword polling: By default, your polling method will be ARMPolling. - Pass in False for this operation to not poll, or pass in your own initialized polling object for a personal polling strategy. + :keyword polling: By default, your polling method will be ARMPolling. Pass in False for this + operation to not poll, or pass in your own initialized polling object for a personal polling + strategy. :paramtype polling: bool or ~azure.core.polling.PollingMethod - :keyword int polling_interval: Default waiting time between two polls for LRO operations if no Retry-After header is present. + :keyword int polling_interval: Default waiting time between two polls for LRO operations if no + Retry-After header is present. :return: An instance of LROPoller that returns either None or the result of cls(response) :rtype: ~azure.core.polling.LROPoller[None] - :raises ~azure.core.exceptions.HttpResponseError: + :raises: ~azure.core.exceptions.HttpResponseError """ - polling = kwargs.pop('polling', True) # type: Union[bool, PollingMethod] + polling = kwargs.pop('polling', True) # type: Union[bool, azure.core.polling.PollingMethod] cls = kwargs.pop('cls', None) # type: ClsType[None] lro_delay = kwargs.pop( 'polling_interval', @@ -389,21 +578,14 @@ def begin_delete( cls=lambda x,y,z: x, **kwargs ) - kwargs.pop('error_map', None) - kwargs.pop('content_type', None) def get_long_running_output(pipeline_response): if cls: return cls(pipeline_response, None, {}) - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'workspaceName': self._serialize.url("workspace_name", workspace_name, 'str'), - } - if polling is True: polling_method = ARMPolling(lro_delay, path_format_arguments=path_format_arguments, **kwargs) + if polling is True: polling_method = ARMPolling(lro_delay, **kwargs) elif polling is False: polling_method = NoPolling() else: polling_method = polling if cont_token: @@ -415,13 +597,14 @@ def get_long_running_output(pipeline_response): ) else: return LROPoller(self._client, raw_result, get_long_running_output, polling_method) + begin_delete.metadata = {'url': '/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}'} # type: ignore + @distributed_trace def list_by_subscription( self, - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkspaceListResult"] + **kwargs: Any + ) -> Iterable["_models.WorkspaceListResult"]: """Gets the list of Workspaces within a Subscription. :keyword callable cls: A custom type or function that will be passed the direct response @@ -434,34 +617,29 @@ def list_by_subscription( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_subscription.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=self.list_by_subscription.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_subscription_request( + subscription_id=self._config.subscription_id, + template_url=next_link, + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + request.method = "GET" return request def extract_data(pipeline_response): - deserialized = self._deserialize('WorkspaceListResult', pipeline_response) + deserialized = self._deserialize("WorkspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -474,23 +652,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.Quantum/workspaces'} # type: ignore + @distributed_trace def list_by_resource_group( self, - resource_group_name, # type: str - **kwargs # type: Any - ): - # type: (...) -> Iterable["_models.WorkspaceListResult"] + resource_group_name: str, + **kwargs: Any + ) -> Iterable["_models.WorkspaceListResult"]: """Gets the list of Workspaces within a resource group. :param resource_group_name: The name of the resource group. @@ -505,35 +684,31 @@ def list_by_resource_group( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - api_version = "2019-11-04-preview" - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list_by_resource_group.metadata['url'] # type: ignore - path_format_arguments = { - 'resourceGroupName': self._serialize.url("resource_group_name", resource_group_name, 'str'), - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - query_parameters['api-version'] = self._serialize.query("api_version", api_version, 'str') - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_by_resource_group_request( + resource_group_name=resource_group_name, + subscription_id=self._config.subscription_id, + 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( + resource_group_name=resource_group_name, + 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('WorkspaceListResult', pipeline_response) + deserialized = self._deserialize("WorkspaceListResult", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -546,12 +721,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 )