diff --git a/src/quantum/azext_quantum/commands.py b/src/quantum/azext_quantum/commands.py index 508c09b8abd..ff777ae5dc5 100644 --- a/src/quantum/azext_quantum/commands.py +++ b/src/quantum/azext_quantum/commands.py @@ -27,7 +27,7 @@ def one(provider, target): def transform_job(result): - result = OrderedDict([ + transformed_result = OrderedDict([ ('Name', result['name']), ('Id', result['id']), ('Status', result['status']), @@ -35,7 +35,17 @@ def transform_job(result): ('Submission time', result['creationTime']), ('Completion time', result['endExecutionTime']) ]) - return result + + # For backwards compatibility check if the field is present and only display if present + cost_estimate = result['costEstimate'] + if cost_estimate is not None: + amount = cost_estimate['estimatedTotal'] + currency = cost_estimate['currencyCode'] + if (amount is not None) and (currency is not None): + price = str(amount) + ' ' + currency + transformed_result['Price estimate'] = price + + return transformed_result def transform_jobs(results): diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/__init__.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/__init__.py index 7c807db08ca..bb04d45447a 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/__init__.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/__init__.py @@ -12,8 +12,7 @@ __version__ = VERSION __all__ = ['QuantumClient'] -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/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_configuration.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_configuration.py index fb869107d5c..99286d1c74b 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_configuration.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_configuration.py @@ -10,7 +10,6 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy from ._version import VERSION @@ -46,6 +45,7 @@ def __init__( **kwargs # type: Any ): # type: (...) -> None + super(QuantumClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -54,7 +54,6 @@ def __init__( raise ValueError("Parameter 'resource_group_name' must not be None.") if workspace_name is None: raise ValueError("Parameter 'workspace_name' must not be None.") - super(QuantumClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -73,7 +72,7 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.RetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.RedirectPolicy(**kwargs) diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_patch.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_patch.py new file mode 100644 index 00000000000..74e48ecd07c --- /dev/null +++ b/src/quantum/azext_quantum/vendored_sdks/azure_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/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_quantum_client.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_quantum_client.py index 5ca50ed3566..edc512ac850 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_quantum_client.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_quantum_client.py @@ -6,46 +6,45 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +from copy import deepcopy from typing import TYPE_CHECKING -from azure.mgmt.core import ARMPipelineClient +from azure.core import PipelineClient from msrest import Deserializer, Serializer +from . import models +from ._configuration import QuantumClientConfiguration +from .operations import JobsOperations, ProvidersOperations, QuotasOperations, StorageOperations + 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 QuantumClientConfiguration -from .operations import JobsOperations -from .operations import ProvidersOperations -from .operations import StorageOperations -from .operations import QuotasOperations -from . import models - + from azure.core.rest import HttpRequest, HttpResponse class QuantumClient(object): """Azure Quantum REST API client. :ivar jobs: JobsOperations operations - :vartype jobs: azure.quantum.operations.JobsOperations + :vartype jobs: azure.quantum._client.operations.JobsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.quantum.operations.ProvidersOperations + :vartype providers: azure.quantum._client.operations.ProvidersOperations :ivar storage: StorageOperations operations - :vartype storage: azure.quantum.operations.StorageOperations + :vartype storage: azure.quantum._client.operations.StorageOperations :ivar quotas: QuotasOperations operations - :vartype quotas: azure.quantum.operations.QuotasOperations + :vartype quotas: azure.quantum._client.operations.QuotasOperations :param credential: Credential needed for the client to connect to Azure. :type credential: ~azure.core.credentials.TokenCredential - :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :type subscription_id: str :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param workspace_name: Name of the workspace. :type workspace_name: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://quantum.azure.com'. + :type base_url: str """ def __init__( @@ -54,48 +53,49 @@ def __init__( subscription_id, # type: str resource_group_name, # type: str workspace_name, # type: str - base_url=None, # type: Optional[str] + base_url="https://quantum.azure.com", # type: str **kwargs # type: Any ): # type: (...) -> None - if not base_url: - base_url = 'https://quantum.azure.com' - self._config = QuantumClientConfiguration(credential, subscription_id, resource_group_name, workspace_name, **kwargs) - self._client = ARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._config = QuantumClientConfiguration(credential=credential, subscription_id=subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, **kwargs) + self._client = PipelineClient(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.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage = StorageOperations(self._client, self._config, self._serialize, self._deserialize) + self.quotas = QuotasOperations(self._client, self._config, self._serialize, self._deserialize) + - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.storage = StorageOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quotas = QuotasOperations( - 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 # type: Any + ): + # type: (...) -> 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'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, '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/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_vendor.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/_vendor.py new file mode 100644 index 00000000000..138f663c53a --- /dev/null +++ b/src/quantum/azext_quantum/vendored_sdks/azure_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/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/__init__.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/__init__.py index 62ba6ee4cca..76a60c6f7cc 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/__init__.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/__init__.py @@ -8,3 +8,8 @@ from ._quantum_client import QuantumClient __all__ = ['QuantumClient'] + +# `._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/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_configuration.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_configuration.py index d0850c7d599..0645ba9c519 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_configuration.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_configuration.py @@ -10,7 +10,6 @@ from azure.core.configuration import Configuration from azure.core.pipeline import policies -from azure.mgmt.core.policies import ARMHttpLoggingPolicy from .._version import VERSION @@ -43,6 +42,7 @@ def __init__( workspace_name: str, **kwargs: Any ) -> None: + super(QuantumClientConfiguration, self).__init__(**kwargs) if credential is None: raise ValueError("Parameter 'credential' must not be None.") if subscription_id is None: @@ -51,7 +51,6 @@ def __init__( raise ValueError("Parameter 'resource_group_name' must not be None.") if workspace_name is None: raise ValueError("Parameter 'workspace_name' must not be None.") - super(QuantumClientConfiguration, self).__init__(**kwargs) self.credential = credential self.subscription_id = subscription_id @@ -69,7 +68,7 @@ def _configure( self.headers_policy = kwargs.get('headers_policy') or policies.HeadersPolicy(**kwargs) self.proxy_policy = kwargs.get('proxy_policy') or policies.ProxyPolicy(**kwargs) self.logging_policy = kwargs.get('logging_policy') or policies.NetworkTraceLoggingPolicy(**kwargs) - self.http_logging_policy = kwargs.get('http_logging_policy') or ARMHttpLoggingPolicy(**kwargs) + self.http_logging_policy = kwargs.get('http_logging_policy') or policies.HttpLoggingPolicy(**kwargs) self.retry_policy = kwargs.get('retry_policy') or policies.AsyncRetryPolicy(**kwargs) self.custom_hook_policy = kwargs.get('custom_hook_policy') or policies.CustomHookPolicy(**kwargs) self.redirect_policy = kwargs.get('redirect_policy') or policies.AsyncRedirectPolicy(**kwargs) diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_patch.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_patch.py new file mode 100644 index 00000000000..74e48ecd07c --- /dev/null +++ b/src/quantum/azext_quantum/vendored_sdks/azure_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/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_quantum_client.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_quantum_client.py index 49042acd5ed..daa1d3a4d2d 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_quantum_client.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/_quantum_client.py @@ -6,44 +6,43 @@ # 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.mgmt.core import AsyncARMPipelineClient +from azure.core import AsyncPipelineClient +from azure.core.rest import AsyncHttpResponse, HttpRequest from msrest import Deserializer, Serializer +from .. import models +from ._configuration import QuantumClientConfiguration +from .operations import JobsOperations, ProvidersOperations, QuotasOperations, StorageOperations + if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from azure.core.credentials_async import AsyncTokenCredential -from ._configuration import QuantumClientConfiguration -from .operations import JobsOperations -from .operations import ProvidersOperations -from .operations import StorageOperations -from .operations import QuotasOperations -from .. import models - - -class QuantumClient(object): +class QuantumClient: """Azure Quantum REST API client. :ivar jobs: JobsOperations operations - :vartype jobs: azure.quantum.aio.operations.JobsOperations + :vartype jobs: azure.quantum._client.aio.operations.JobsOperations :ivar providers: ProvidersOperations operations - :vartype providers: azure.quantum.aio.operations.ProvidersOperations + :vartype providers: azure.quantum._client.aio.operations.ProvidersOperations :ivar storage: StorageOperations operations - :vartype storage: azure.quantum.aio.operations.StorageOperations + :vartype storage: azure.quantum._client.aio.operations.StorageOperations :ivar quotas: QuotasOperations operations - :vartype quotas: azure.quantum.aio.operations.QuotasOperations + :vartype quotas: azure.quantum._client.aio.operations.QuotasOperations :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. This is a GUID-formatted string (e.g. 00000000-0000-0000-0000-000000000000). + :param subscription_id: The Azure subscription ID. This is a GUID-formatted string (e.g. + 00000000-0000-0000-0000-000000000000). :type subscription_id: str :param resource_group_name: Name of an Azure resource group. :type resource_group_name: str :param workspace_name: Name of the workspace. :type workspace_name: str - :param str base_url: Service URL + :param base_url: Service URL. Default value is 'https://quantum.azure.com'. + :type base_url: str """ def __init__( @@ -52,46 +51,47 @@ def __init__( subscription_id: str, resource_group_name: str, workspace_name: str, - base_url: Optional[str] = None, + base_url: str = "https://quantum.azure.com", **kwargs: Any ) -> None: - if not base_url: - base_url = 'https://quantum.azure.com' - self._config = QuantumClientConfiguration(credential, subscription_id, resource_group_name, workspace_name, **kwargs) - self._client = AsyncARMPipelineClient(base_url=base_url, config=self._config, **kwargs) + self._config = QuantumClientConfiguration(credential=credential, subscription_id=subscription_id, resource_group_name=resource_group_name, workspace_name=workspace_name, **kwargs) + self._client = AsyncPipelineClient(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.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize) + self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize) + self.storage = StorageOperations(self._client, self._config, self._serialize, self._deserialize) + self.quotas = QuotasOperations(self._client, self._config, self._serialize, self._deserialize) - self.jobs = JobsOperations( - self._client, self._config, self._serialize, self._deserialize) - self.providers = ProvidersOperations( - self._client, self._config, self._serialize, self._deserialize) - self.storage = StorageOperations( - self._client, self._config, self._serialize, self._deserialize) - self.quotas = QuotasOperations( - 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'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, '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/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_jobs_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_jobs_operations.py index ca45bc2c96a..4487a6e5b43 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_jobs_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_jobs_operations.py @@ -5,17 +5,21 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, AsyncIterable, Callable, Dict, Generic, Optional, TypeVar, Union +import functools +from typing import Any, AsyncIterable, Callable, Dict, Generic, List, 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.mgmt.core.exceptions import ARMErrorFormat +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 ... import models as _models - +from ..._vendor import _convert_request +from ...operations._jobs_operations import build_cancel_request, build_create_request, build_get_request, build_list_request, build_patch_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -26,7 +30,7 @@ class JobsOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +54,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobDetailsList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.JobDetailsList] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.JobDetailsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobDetailsList"] @@ -57,34 +62,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_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('JobDetailsList', pipeline_response) + deserialized = self._deserialize("JobDetailsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -98,15 +102,17 @@ async def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) list.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs'} # type: ignore + @distributed_trace_async async def get( self, job_id: str, @@ -118,7 +124,7 @@ async def get( :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobDetails, or the result of cls(response) - :rtype: ~azure.quantum.models.JobDetails + :rtype: ~azure.quantum._client.models.JobDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobDetails"] @@ -126,33 +132,25 @@ async def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + 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.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('JobDetails', pipeline_response) @@ -160,8 +158,11 @@ async def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace_async async def create( self, job_id: str, @@ -173,10 +174,10 @@ async def create( :param job_id: Id of the job. :type job_id: str :param job: The complete metadata of the job to submit. - :type job: ~azure.quantum.models.JobDetails + :type job: ~azure.quantum._client.models.JobDetails :keyword callable cls: A custom type or function that will be passed the direct response :return: JobDetails, or the result of cls(response) - :rtype: ~azure.quantum.models.JobDetails + :rtype: ~azure.quantum._client.models.JobDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobDetails"] @@ -184,38 +185,30 @@ async def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + 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(job, 'JobDetails') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + content_type=content_type, + json=_json, + template_url=self.create.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(job, 'JobDetails') - 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.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) if response.status_code == 200: deserialized = self._deserialize('JobDetails', pipeline_response) @@ -227,8 +220,11 @@ async def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace_async async def cancel( self, job_id: str, @@ -248,35 +244,88 @@ async def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + template_url=self.cancel.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 [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) cancel.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + + + @distributed_trace_async + async def patch( + self, + job_id: str, + patch_job: List["_models.JsonPatchDocument"], + **kwargs: Any + ) -> Optional["_models.JobDetails"]: + """Patch a job. + + :param job_id: Id of the job. + :type job_id: str + :param patch_job: The json patch document containing the patch operations. + :type patch_job: list[~azure.quantum._client.models.JsonPatchDocument] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobDetails, or the result of cls(response) + :rtype: ~azure.quantum._client.models.JobDetails or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.JobDetails"]] + 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(patch_job, '[JsonPatchDocument]') + + request = build_patch_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + content_type=content_type, + json=_json, + template_url=self.patch.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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JobDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_providers_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_providers_operations.py index 1c0fd00deb6..29903fa6ebd 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_providers_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_providers_operations.py @@ -5,17 +5,21 @@ # 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.mgmt.core.exceptions import ARMErrorFormat +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 ... import models as _models - +from ..._vendor import _convert_request +from ...operations._providers_operations import build_get_status_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -26,7 +30,7 @@ class ProvidersOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def get_status( self, **kwargs: Any @@ -49,7 +54,8 @@ def get_status( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderStatusList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.ProviderStatusList] + :rtype: + ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.ProviderStatusList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderStatusList"] @@ -57,34 +63,33 @@ def get_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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.get_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_status_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + template_url=self.get_status.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_get_status_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_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('ProviderStatusList', pipeline_response) + deserialized = self._deserialize("ProviderStatusList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +102,13 @@ async def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.RestError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_quotas_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_quotas_operations.py index 86fd89f355b..a40009ffc13 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_quotas_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_quotas_operations.py @@ -5,17 +5,21 @@ # 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.mgmt.core.exceptions import ARMErrorFormat +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 ... import models as _models - +from ..._vendor import _convert_request +from ...operations._quotas_operations import build_list_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -26,7 +30,7 @@ class QuotasOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -41,6 +45,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs: Any @@ -49,7 +54,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either QuotaList or the result of cls(response) - :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.QuotaList] + :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.QuotaList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaList"] @@ -57,34 +62,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_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('QuotaList', pipeline_response) + deserialized = self._deserialize("QuotaList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -97,12 +101,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.RestError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) return pipeline_response + return AsyncItemPaged( get_next, extract_data ) diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_storage_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_storage_operations.py index f8775451dfd..840a6db8e6b 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_storage_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/aio/operations/_storage_operations.py @@ -5,16 +5,19 @@ # Code generated by Microsoft (R) AutoRest Code Generator. # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- +import functools from typing import Any, Callable, Dict, Generic, Optional, TypeVar import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import AsyncHttpResponse, HttpRequest -from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.core.pipeline.transport import AsyncHttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator_async import distributed_trace_async from ... import models as _models - +from ..._vendor import _convert_request +from ...operations._storage_operations import build_sas_uri_request T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]] @@ -25,7 +28,7 @@ class StorageOperations: instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -40,6 +43,7 @@ def __init__(self, client, config, serializer, deserializer) -> None: self._deserialize = deserializer self._config = config + @distributed_trace_async async def sas_uri( self, blob_details: "_models.BlobDetails", @@ -49,10 +53,10 @@ async def sas_uri( workspace. The SAS URL can be used to upload job input and/or download job output. :param blob_details: The details (name and container) of the blob to store or download data. - :type blob_details: ~azure.quantum.models.BlobDetails + :type blob_details: ~azure.quantum._client.models.BlobDetails :keyword callable cls: A custom type or function that will be passed the direct response :return: SasUriResponse, or the result of cls(response) - :rtype: ~azure.quantum.models.SasUriResponse + :rtype: ~azure.quantum._client.models.SasUriResponse :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SasUriResponse"] @@ -60,37 +64,29 @@ async def sas_uri( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.sas_uri.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(blob_details, 'BlobDetails') - # 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_sas_uri_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + content_type=content_type, + json=_json, + template_url=self.sas_uri.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(blob_details, 'BlobDetails') - body_content_kwargs['content'] = body_content - request = self._client.post(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.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('SasUriResponse', pipeline_response) @@ -98,4 +94,6 @@ async def sas_uri( return cls(pipeline_response, deserialized, {}) return deserialized + sas_uri.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/storage/sasUri'} # type: ignore + diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/__init__.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/__init__.py index 4a92608bc70..404fadad3fd 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/__init__.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/__init__.py @@ -8,9 +8,11 @@ try: from ._models_py3 import BlobDetails + from ._models_py3 import CostEstimate from ._models_py3 import ErrorData from ._models_py3 import JobDetails from ._models_py3 import JobDetailsList + from ._models_py3 import JsonPatchDocument from ._models_py3 import ProviderStatus from ._models_py3 import ProviderStatusList from ._models_py3 import Quota @@ -18,11 +20,14 @@ from ._models_py3 import RestError from ._models_py3 import SasUriResponse from ._models_py3 import TargetStatus + from ._models_py3 import UsageEvent except (SyntaxError, ImportError): from ._models import BlobDetails # type: ignore + from ._models import CostEstimate # type: ignore from ._models import ErrorData # type: ignore from ._models import JobDetails # type: ignore from ._models import JobDetailsList # type: ignore + from ._models import JsonPatchDocument # type: ignore from ._models import ProviderStatus # type: ignore from ._models import ProviderStatusList # type: ignore from ._models import Quota # type: ignore @@ -30,10 +35,12 @@ from ._models import RestError # type: ignore from ._models import SasUriResponse # type: ignore from ._models import TargetStatus # type: ignore + from ._models import UsageEvent # type: ignore from ._quantum_client_enums import ( DimensionScope, JobStatus, + JsonPatchOperation, MeterPeriod, ProviderAvailability, TargetAvailability, @@ -41,9 +48,11 @@ __all__ = [ 'BlobDetails', + 'CostEstimate', 'ErrorData', 'JobDetails', 'JobDetailsList', + 'JsonPatchDocument', 'ProviderStatus', 'ProviderStatusList', 'Quota', @@ -51,8 +60,10 @@ 'RestError', 'SasUriResponse', 'TargetStatus', + 'UsageEvent', 'DimensionScope', 'JobStatus', + 'JsonPatchOperation', 'MeterPeriod', 'ProviderAvailability', 'TargetAvailability', diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models.py index c1fca9bdaf5..90ed0a6f64d 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models.py @@ -15,10 +15,10 @@ class BlobDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param container_name: Required. The container name. - :type container_name: str - :param blob_name: The blob name. - :type blob_name: str + :ivar container_name: Required. The container name. + :vartype container_name: str + :ivar blob_name: The blob name. + :vartype blob_name: str """ _validation = { @@ -34,20 +34,61 @@ def __init__( self, **kwargs ): + """ + :keyword container_name: Required. The container name. + :paramtype container_name: str + :keyword blob_name: The blob name. + :paramtype blob_name: str + """ super(BlobDetails, self).__init__(**kwargs) self.container_name = kwargs['container_name'] self.blob_name = kwargs.get('blob_name', None) +class CostEstimate(msrest.serialization.Model): + """The job cost billed by the provider. The final cost on your bill might be slightly different due to added taxes and currency conversion rates. + + :ivar currency_code: The currency code. + :vartype currency_code: str + :ivar events: List of usage events. + :vartype events: list[~azure.quantum._client.models.UsageEvent] + :ivar estimated_total: The estimated total. + :vartype estimated_total: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'events': {'key': 'events', 'type': '[UsageEvent]'}, + 'estimated_total': {'key': 'estimatedTotal', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword currency_code: The currency code. + :paramtype currency_code: str + :keyword events: List of usage events. + :paramtype events: list[~azure.quantum._client.models.UsageEvent] + :keyword estimated_total: The estimated total. + :paramtype estimated_total: float + """ + super(CostEstimate, self).__init__(**kwargs) + self.currency_code = kwargs.get('currency_code', None) + self.events = kwargs.get('events', None) + self.estimated_total = kwargs.get('estimated_total', None) + + class ErrorData(msrest.serialization.Model): """An error response from Azure. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for displaying in a - user interface. - :type message: str + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for displaying in a user + interface. + :vartype message: str """ _attribute_map = { @@ -59,6 +100,14 @@ def __init__( self, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for displaying in a + user interface. + :paramtype message: str + """ super(ErrorData, self).__init__(**kwargs) self.code = kwargs.get('code', None) self.message = kwargs.get('message', None) @@ -71,38 +120,38 @@ class JobDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: The job id. - :type id: str - :param name: The job name. Is not required for the name to be unique and it's only used for + :ivar id: The job id. + :vartype id: str + :ivar name: The job name. Is not required for the name to be unique and it's only used for display purposes. - :type name: str - :param container_uri: Required. The blob container SAS uri, the container is used to host job + :vartype name: str + :ivar container_uri: Required. The blob container SAS uri, the container is used to host job data. - :type container_uri: str - :param input_data_uri: The input blob SAS uri, if specified, it will override the default input + :vartype container_uri: str + :ivar input_data_uri: The input blob SAS uri, if specified, it will override the default input blob in the container. - :type input_data_uri: str - :param input_data_format: Required. The format of the input data. - :type input_data_format: str - :param input_params: The input parameters for the job. JSON object used by the target solver. - It is expected that the size of this object is small and only used to specify parameters for - the execution target, not the input data. - :type input_params: any - :param provider_id: Required. The unique identifier for the provider. - :type provider_id: str - :param target: Required. The target identifier to run the job. - :type target: str - :param metadata: The job metadata. Metadata provides client the ability to store - client-specific information. - :type metadata: dict[str, str] - :param output_data_uri: The output blob SAS uri. When a job finishes successfully, results will + :vartype input_data_uri: str + :ivar input_data_format: Required. The format of the input data. + :vartype input_data_format: str + :ivar input_params: The input parameters for the job. JSON object used by the target solver. It + is expected that the size of this object is small and only used to specify parameters for the + execution target, not the input data. + :vartype input_params: any + :ivar provider_id: Required. The unique identifier for the provider. + :vartype provider_id: str + :ivar target: Required. The target identifier to run the job. + :vartype target: str + :ivar metadata: The job metadata. Metadata provides client the ability to store client-specific + information. + :vartype metadata: dict[str, str] + :ivar output_data_uri: The output blob SAS uri. When a job finishes successfully, results will be uploaded to this blob. - :type output_data_uri: str - :param output_data_format: The format of the output data. - :type output_data_format: str + :vartype output_data_uri: str + :ivar output_data_format: The format of the output data. + :vartype output_data_format: str :ivar status: The job status. Possible values include: "Waiting", "Executing", "Succeeded", "Failed", "Cancelled". - :vartype status: str or ~azure.quantum.models.JobStatus + :vartype status: str or ~azure.quantum._client.models.JobStatus :ivar creation_time: The creation time of the job. :vartype creation_time: ~datetime.datetime :ivar begin_execution_time: The time when the job began execution. @@ -111,8 +160,13 @@ class JobDetails(msrest.serialization.Model): :vartype end_execution_time: ~datetime.datetime :ivar cancellation_time: The time when a job was successfully cancelled. :vartype cancellation_time: ~datetime.datetime + :ivar cost_estimate: The job cost billed by the provider. The final cost on your bill might be + slightly different due to added taxes and currency conversion rates. + :vartype cost_estimate: ~azure.quantum._client.models.CostEstimate :ivar error_data: The error data for the job. This is expected only when Status 'Failed'. - :vartype error_data: ~azure.quantum.models.ErrorData + :vartype error_data: ~azure.quantum._client.models.ErrorData + :ivar tags: A set of tags. List of user-supplied tags associated with the job. + :vartype tags: list[str] """ _validation = { @@ -125,6 +179,7 @@ class JobDetails(msrest.serialization.Model): 'begin_execution_time': {'readonly': True}, 'end_execution_time': {'readonly': True}, 'cancellation_time': {'readonly': True}, + 'cost_estimate': {'readonly': True}, 'error_data': {'readonly': True}, } @@ -145,13 +200,48 @@ class JobDetails(msrest.serialization.Model): 'begin_execution_time': {'key': 'beginExecutionTime', 'type': 'iso-8601'}, 'end_execution_time': {'key': 'endExecutionTime', 'type': 'iso-8601'}, 'cancellation_time': {'key': 'cancellationTime', 'type': 'iso-8601'}, + 'cost_estimate': {'key': 'costEstimate', 'type': 'CostEstimate'}, 'error_data': {'key': 'errorData', 'type': 'ErrorData'}, + 'tags': {'key': 'tags', 'type': '[str]'}, } def __init__( self, **kwargs ): + """ + :keyword id: The job id. + :paramtype id: str + :keyword name: The job name. Is not required for the name to be unique and it's only used for + display purposes. + :paramtype name: str + :keyword container_uri: Required. The blob container SAS uri, the container is used to host job + data. + :paramtype container_uri: str + :keyword input_data_uri: The input blob SAS uri, if specified, it will override the default + input blob in the container. + :paramtype input_data_uri: str + :keyword input_data_format: Required. The format of the input data. + :paramtype input_data_format: str + :keyword input_params: The input parameters for the job. JSON object used by the target solver. + It is expected that the size of this object is small and only used to specify parameters for + the execution target, not the input data. + :paramtype input_params: any + :keyword provider_id: Required. The unique identifier for the provider. + :paramtype provider_id: str + :keyword target: Required. The target identifier to run the job. + :paramtype target: str + :keyword metadata: The job metadata. Metadata provides client the ability to store + client-specific information. + :paramtype metadata: dict[str, str] + :keyword output_data_uri: The output blob SAS uri. When a job finishes successfully, results + will be uploaded to this blob. + :paramtype output_data_uri: str + :keyword output_data_format: The format of the output data. + :paramtype output_data_format: str + :keyword tags: A set of tags. List of user-supplied tags associated with the job. + :paramtype tags: list[str] + """ super(JobDetails, self).__init__(**kwargs) self.id = kwargs.get('id', None) self.name = kwargs.get('name', None) @@ -169,7 +259,9 @@ def __init__( self.begin_execution_time = None self.end_execution_time = None self.cancellation_time = None + self.cost_estimate = None self.error_data = None + self.tags = kwargs.get('tags', None) class JobDetailsList(msrest.serialization.Model): @@ -178,9 +270,9 @@ class JobDetailsList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: - :vartype value: list[~azure.quantum.models.JobDetails] - :param count: Total records count number. - :type count: long + :vartype value: list[~azure.quantum._client.models.JobDetails] + :ivar count: Total records count number. + :vartype count: long :ivar next_link: Link to the next page of results. :vartype next_link: str """ @@ -200,12 +292,66 @@ def __init__( self, **kwargs ): + """ + :keyword count: Total records count number. + :paramtype count: long + """ super(JobDetailsList, self).__init__(**kwargs) self.value = None self.count = kwargs.get('count', None) self.next_link = None +class JsonPatchDocument(msrest.serialization.Model): + """A JSONPatch document as defined by RFC 6902. + + All required parameters must be populated in order to send to Azure. + + :ivar op: Required. The operation to be performed. Possible values include: "add", "remove", + "replace", "move", "copy", "test". + :vartype op: str or ~azure.quantum._client.models.JsonPatchOperation + :ivar path: Required. A JSON-Pointer. + :vartype path: str + :ivar value: A value to be used in the operation on the path. + :vartype value: any + :ivar from_property: Optional field used in copy and move operations. + :vartype from_property: str + """ + + _validation = { + 'op': {'required': True}, + 'path': {'required': True}, + } + + _attribute_map = { + 'op': {'key': 'op', 'type': 'str'}, + 'path': {'key': 'path', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'object'}, + 'from_property': {'key': 'from', 'type': 'str'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword op: Required. The operation to be performed. Possible values include: "add", "remove", + "replace", "move", "copy", "test". + :paramtype op: str or ~azure.quantum._client.models.JsonPatchOperation + :keyword path: Required. A JSON-Pointer. + :paramtype path: str + :keyword value: A value to be used in the operation on the path. + :paramtype value: any + :keyword from_property: Optional field used in copy and move operations. + :paramtype from_property: str + """ + super(JsonPatchDocument, self).__init__(**kwargs) + self.op = kwargs['op'] + self.path = kwargs['path'] + self.value = kwargs.get('value', None) + self.from_property = kwargs.get('from_property', None) + + class ProviderStatus(msrest.serialization.Model): """Providers status. @@ -215,9 +361,9 @@ class ProviderStatus(msrest.serialization.Model): :vartype id: str :ivar current_availability: Provider availability. Possible values include: "Available", "Degraded", "Unavailable". - :vartype current_availability: str or ~azure.quantum.models.ProviderAvailability + :vartype current_availability: str or ~azure.quantum._client.models.ProviderAvailability :ivar targets: - :vartype targets: list[~azure.quantum.models.TargetStatus] + :vartype targets: list[~azure.quantum._client.models.TargetStatus] """ _validation = { @@ -236,6 +382,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProviderStatus, self).__init__(**kwargs) self.id = None self.current_availability = None @@ -248,7 +396,7 @@ class ProviderStatusList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: - :vartype value: list[~azure.quantum.models.ProviderStatus] + :vartype value: list[~azure.quantum._client.models.ProviderStatus] :ivar next_link: Link to the next page of results. :vartype next_link: str """ @@ -267,6 +415,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProviderStatusList, self).__init__(**kwargs) self.value = None self.next_link = None @@ -275,24 +425,24 @@ def __init__( class Quota(msrest.serialization.Model): """Quota information. - :param dimension: The name of the dimension associated with the quota. - :type dimension: str - :param scope: The scope at which the quota is applied. Possible values include: "Workspace", + :ivar dimension: The name of the dimension associated with the quota. + :vartype dimension: str + :ivar scope: The scope at which the quota is applied. Possible values include: "Workspace", "Subscription". - :type scope: str or ~azure.quantum.models.DimensionScope - :param provider_id: The unique identifier for the provider. - :type provider_id: str - :param utilization: The amount of the usage that has been applied for the current period. - :type utilization: float - :param holds: The amount of the usage that has been reserved but not applied for the current + :vartype scope: str or ~azure.quantum._client.models.DimensionScope + :ivar provider_id: The unique identifier for the provider. + :vartype provider_id: str + :ivar utilization: The amount of the usage that has been applied for the current period. + :vartype utilization: float + :ivar holds: The amount of the usage that has been reserved but not applied for the current period. - :type holds: float - :param limit: The maximum amount of usage allowed for the current period. - :type limit: float - :param period: The time period in which the quota's underlying meter is accumulated. Based on + :vartype holds: float + :ivar limit: The maximum amount of usage allowed for the current period. + :vartype limit: float + :ivar period: The time period in which the quota's underlying meter is accumulated. Based on calendar year. 'None' is used for concurrent quotas. Possible values include: "None", "Monthly". - :type period: str or ~azure.quantum.models.MeterPeriod + :vartype period: str or ~azure.quantum._client.models.MeterPeriod """ _attribute_map = { @@ -309,6 +459,26 @@ def __init__( self, **kwargs ): + """ + :keyword dimension: The name of the dimension associated with the quota. + :paramtype dimension: str + :keyword scope: The scope at which the quota is applied. Possible values include: "Workspace", + "Subscription". + :paramtype scope: str or ~azure.quantum._client.models.DimensionScope + :keyword provider_id: The unique identifier for the provider. + :paramtype provider_id: str + :keyword utilization: The amount of the usage that has been applied for the current period. + :paramtype utilization: float + :keyword holds: The amount of the usage that has been reserved but not applied for the current + period. + :paramtype holds: float + :keyword limit: The maximum amount of usage allowed for the current period. + :paramtype limit: float + :keyword period: The time period in which the quota's underlying meter is accumulated. Based on + calendar year. 'None' is used for concurrent quotas. Possible values include: "None", + "Monthly". + :paramtype period: str or ~azure.quantum._client.models.MeterPeriod + """ super(Quota, self).__init__(**kwargs) self.dimension = kwargs.get('dimension', None) self.scope = kwargs.get('scope', None) @@ -325,7 +495,7 @@ class QuotaList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: - :vartype value: list[~azure.quantum.models.Quota] + :vartype value: list[~azure.quantum._client.models.Quota] :ivar next_link: Link to the next page of results. :vartype next_link: str """ @@ -344,6 +514,8 @@ def __init__( self, **kwargs ): + """ + """ super(QuotaList, self).__init__(**kwargs) self.value = None self.next_link = None @@ -352,8 +524,8 @@ def __init__( class RestError(msrest.serialization.Model): """Error information returned by the API. - :param error: An error response from Azure. - :type error: ~azure.quantum.models.ErrorData + :ivar error: An error response from Azure. + :vartype error: ~azure.quantum._client.models.ErrorData """ _attribute_map = { @@ -364,6 +536,10 @@ def __init__( self, **kwargs ): + """ + :keyword error: An error response from Azure. + :paramtype error: ~azure.quantum._client.models.ErrorData + """ super(RestError, self).__init__(**kwargs) self.error = kwargs.get('error', None) @@ -371,8 +547,8 @@ def __init__( class SasUriResponse(msrest.serialization.Model): """Get SAS URL operation response. - :param sas_uri: A URL with a SAS token to upload a blob for execution in the given workspace. - :type sas_uri: str + :ivar sas_uri: A URL with a SAS token to upload a blob for execution in the given workspace. + :vartype sas_uri: str """ _attribute_map = { @@ -383,6 +559,10 @@ def __init__( self, **kwargs ): + """ + :keyword sas_uri: A URL with a SAS token to upload a blob for execution in the given workspace. + :paramtype sas_uri: str + """ super(SasUriResponse, self).__init__(**kwargs) self.sas_uri = kwargs.get('sas_uri', None) @@ -396,7 +576,7 @@ class TargetStatus(msrest.serialization.Model): :vartype id: str :ivar current_availability: Target availability. Possible values include: "Available", "Degraded", "Unavailable". - :vartype current_availability: str or ~azure.quantum.models.TargetAvailability + :vartype current_availability: str or ~azure.quantum._client.models.TargetAvailability :ivar average_queue_time: Average queue time in seconds. :vartype average_queue_time: long :ivar status_page: A page with detailed status of the provider. @@ -421,8 +601,63 @@ def __init__( self, **kwargs ): + """ + """ super(TargetStatus, self).__init__(**kwargs) self.id = None self.current_availability = None self.average_queue_time = None self.status_page = None + + +class UsageEvent(msrest.serialization.Model): + """Usage event details. + + :ivar dimension_id: The dimension id. + :vartype dimension_id: str + :ivar dimension_name: The dimension name. + :vartype dimension_name: str + :ivar measure_unit: The unit of measure. + :vartype measure_unit: str + :ivar amount_billed: The amount billed. + :vartype amount_billed: float + :ivar amount_consumed: The amount consumed. + :vartype amount_consumed: float + :ivar unit_price: The unit price. + :vartype unit_price: float + """ + + _attribute_map = { + 'dimension_id': {'key': 'dimensionId', 'type': 'str'}, + 'dimension_name': {'key': 'dimensionName', 'type': 'str'}, + 'measure_unit': {'key': 'measureUnit', 'type': 'str'}, + 'amount_billed': {'key': 'amountBilled', 'type': 'float'}, + 'amount_consumed': {'key': 'amountConsumed', 'type': 'float'}, + 'unit_price': {'key': 'unitPrice', 'type': 'float'}, + } + + def __init__( + self, + **kwargs + ): + """ + :keyword dimension_id: The dimension id. + :paramtype dimension_id: str + :keyword dimension_name: The dimension name. + :paramtype dimension_name: str + :keyword measure_unit: The unit of measure. + :paramtype measure_unit: str + :keyword amount_billed: The amount billed. + :paramtype amount_billed: float + :keyword amount_consumed: The amount consumed. + :paramtype amount_consumed: float + :keyword unit_price: The unit price. + :paramtype unit_price: float + """ + super(UsageEvent, self).__init__(**kwargs) + self.dimension_id = kwargs.get('dimension_id', None) + self.dimension_name = kwargs.get('dimension_name', None) + self.measure_unit = kwargs.get('measure_unit', None) + self.amount_billed = kwargs.get('amount_billed', None) + self.amount_consumed = kwargs.get('amount_consumed', None) + self.unit_price = kwargs.get('unit_price', None) diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models_py3.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models_py3.py index 22a56ba18c2..e8d9ab67fe1 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models_py3.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_models_py3.py @@ -6,7 +6,7 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from typing import Any, Dict, Optional, Union +from typing import Any, Dict, List, Optional, Union from azure.core.exceptions import HttpResponseError import msrest.serialization @@ -19,10 +19,10 @@ class BlobDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param container_name: Required. The container name. - :type container_name: str - :param blob_name: The blob name. - :type blob_name: str + :ivar container_name: Required. The container name. + :vartype container_name: str + :ivar blob_name: The blob name. + :vartype blob_name: str """ _validation = { @@ -41,20 +41,65 @@ def __init__( blob_name: Optional[str] = None, **kwargs ): + """ + :keyword container_name: Required. The container name. + :paramtype container_name: str + :keyword blob_name: The blob name. + :paramtype blob_name: str + """ super(BlobDetails, self).__init__(**kwargs) self.container_name = container_name self.blob_name = blob_name +class CostEstimate(msrest.serialization.Model): + """The job cost billed by the provider. The final cost on your bill might be slightly different due to added taxes and currency conversion rates. + + :ivar currency_code: The currency code. + :vartype currency_code: str + :ivar events: List of usage events. + :vartype events: list[~azure.quantum._client.models.UsageEvent] + :ivar estimated_total: The estimated total. + :vartype estimated_total: float + """ + + _attribute_map = { + 'currency_code': {'key': 'currencyCode', 'type': 'str'}, + 'events': {'key': 'events', 'type': '[UsageEvent]'}, + 'estimated_total': {'key': 'estimatedTotal', 'type': 'float'}, + } + + def __init__( + self, + *, + currency_code: Optional[str] = None, + events: Optional[List["UsageEvent"]] = None, + estimated_total: Optional[float] = None, + **kwargs + ): + """ + :keyword currency_code: The currency code. + :paramtype currency_code: str + :keyword events: List of usage events. + :paramtype events: list[~azure.quantum._client.models.UsageEvent] + :keyword estimated_total: The estimated total. + :paramtype estimated_total: float + """ + super(CostEstimate, self).__init__(**kwargs) + self.currency_code = currency_code + self.events = events + self.estimated_total = estimated_total + + class ErrorData(msrest.serialization.Model): """An error response from Azure. - :param code: An identifier for the error. Codes are invariant and are intended to be consumed + :ivar code: An identifier for the error. Codes are invariant and are intended to be consumed programmatically. - :type code: str - :param message: A message describing the error, intended to be suitable for displaying in a - user interface. - :type message: str + :vartype code: str + :ivar message: A message describing the error, intended to be suitable for displaying in a user + interface. + :vartype message: str """ _attribute_map = { @@ -69,6 +114,14 @@ def __init__( message: Optional[str] = None, **kwargs ): + """ + :keyword code: An identifier for the error. Codes are invariant and are intended to be consumed + programmatically. + :paramtype code: str + :keyword message: A message describing the error, intended to be suitable for displaying in a + user interface. + :paramtype message: str + """ super(ErrorData, self).__init__(**kwargs) self.code = code self.message = message @@ -81,38 +134,38 @@ class JobDetails(msrest.serialization.Model): All required parameters must be populated in order to send to Azure. - :param id: The job id. - :type id: str - :param name: The job name. Is not required for the name to be unique and it's only used for + :ivar id: The job id. + :vartype id: str + :ivar name: The job name. Is not required for the name to be unique and it's only used for display purposes. - :type name: str - :param container_uri: Required. The blob container SAS uri, the container is used to host job + :vartype name: str + :ivar container_uri: Required. The blob container SAS uri, the container is used to host job data. - :type container_uri: str - :param input_data_uri: The input blob SAS uri, if specified, it will override the default input + :vartype container_uri: str + :ivar input_data_uri: The input blob SAS uri, if specified, it will override the default input blob in the container. - :type input_data_uri: str - :param input_data_format: Required. The format of the input data. - :type input_data_format: str - :param input_params: The input parameters for the job. JSON object used by the target solver. - It is expected that the size of this object is small and only used to specify parameters for - the execution target, not the input data. - :type input_params: any - :param provider_id: Required. The unique identifier for the provider. - :type provider_id: str - :param target: Required. The target identifier to run the job. - :type target: str - :param metadata: The job metadata. Metadata provides client the ability to store - client-specific information. - :type metadata: dict[str, str] - :param output_data_uri: The output blob SAS uri. When a job finishes successfully, results will + :vartype input_data_uri: str + :ivar input_data_format: Required. The format of the input data. + :vartype input_data_format: str + :ivar input_params: The input parameters for the job. JSON object used by the target solver. It + is expected that the size of this object is small and only used to specify parameters for the + execution target, not the input data. + :vartype input_params: any + :ivar provider_id: Required. The unique identifier for the provider. + :vartype provider_id: str + :ivar target: Required. The target identifier to run the job. + :vartype target: str + :ivar metadata: The job metadata. Metadata provides client the ability to store client-specific + information. + :vartype metadata: dict[str, str] + :ivar output_data_uri: The output blob SAS uri. When a job finishes successfully, results will be uploaded to this blob. - :type output_data_uri: str - :param output_data_format: The format of the output data. - :type output_data_format: str + :vartype output_data_uri: str + :ivar output_data_format: The format of the output data. + :vartype output_data_format: str :ivar status: The job status. Possible values include: "Waiting", "Executing", "Succeeded", "Failed", "Cancelled". - :vartype status: str or ~azure.quantum.models.JobStatus + :vartype status: str or ~azure.quantum._client.models.JobStatus :ivar creation_time: The creation time of the job. :vartype creation_time: ~datetime.datetime :ivar begin_execution_time: The time when the job began execution. @@ -121,8 +174,13 @@ class JobDetails(msrest.serialization.Model): :vartype end_execution_time: ~datetime.datetime :ivar cancellation_time: The time when a job was successfully cancelled. :vartype cancellation_time: ~datetime.datetime + :ivar cost_estimate: The job cost billed by the provider. The final cost on your bill might be + slightly different due to added taxes and currency conversion rates. + :vartype cost_estimate: ~azure.quantum._client.models.CostEstimate :ivar error_data: The error data for the job. This is expected only when Status 'Failed'. - :vartype error_data: ~azure.quantum.models.ErrorData + :vartype error_data: ~azure.quantum._client.models.ErrorData + :ivar tags: A set of tags. List of user-supplied tags associated with the job. + :vartype tags: list[str] """ _validation = { @@ -135,6 +193,7 @@ class JobDetails(msrest.serialization.Model): 'begin_execution_time': {'readonly': True}, 'end_execution_time': {'readonly': True}, 'cancellation_time': {'readonly': True}, + 'cost_estimate': {'readonly': True}, 'error_data': {'readonly': True}, } @@ -155,7 +214,9 @@ class JobDetails(msrest.serialization.Model): 'begin_execution_time': {'key': 'beginExecutionTime', 'type': 'iso-8601'}, 'end_execution_time': {'key': 'endExecutionTime', 'type': 'iso-8601'}, 'cancellation_time': {'key': 'cancellationTime', 'type': 'iso-8601'}, + 'cost_estimate': {'key': 'costEstimate', 'type': 'CostEstimate'}, 'error_data': {'key': 'errorData', 'type': 'ErrorData'}, + 'tags': {'key': 'tags', 'type': '[str]'}, } def __init__( @@ -172,8 +233,42 @@ def __init__( metadata: Optional[Dict[str, str]] = None, output_data_uri: Optional[str] = None, output_data_format: Optional[str] = None, + tags: Optional[List[str]] = None, **kwargs ): + """ + :keyword id: The job id. + :paramtype id: str + :keyword name: The job name. Is not required for the name to be unique and it's only used for + display purposes. + :paramtype name: str + :keyword container_uri: Required. The blob container SAS uri, the container is used to host job + data. + :paramtype container_uri: str + :keyword input_data_uri: The input blob SAS uri, if specified, it will override the default + input blob in the container. + :paramtype input_data_uri: str + :keyword input_data_format: Required. The format of the input data. + :paramtype input_data_format: str + :keyword input_params: The input parameters for the job. JSON object used by the target solver. + It is expected that the size of this object is small and only used to specify parameters for + the execution target, not the input data. + :paramtype input_params: any + :keyword provider_id: Required. The unique identifier for the provider. + :paramtype provider_id: str + :keyword target: Required. The target identifier to run the job. + :paramtype target: str + :keyword metadata: The job metadata. Metadata provides client the ability to store + client-specific information. + :paramtype metadata: dict[str, str] + :keyword output_data_uri: The output blob SAS uri. When a job finishes successfully, results + will be uploaded to this blob. + :paramtype output_data_uri: str + :keyword output_data_format: The format of the output data. + :paramtype output_data_format: str + :keyword tags: A set of tags. List of user-supplied tags associated with the job. + :paramtype tags: list[str] + """ super(JobDetails, self).__init__(**kwargs) self.id = id self.name = name @@ -191,7 +286,9 @@ def __init__( self.begin_execution_time = None self.end_execution_time = None self.cancellation_time = None + self.cost_estimate = None self.error_data = None + self.tags = tags class JobDetailsList(msrest.serialization.Model): @@ -200,9 +297,9 @@ class JobDetailsList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: - :vartype value: list[~azure.quantum.models.JobDetails] - :param count: Total records count number. - :type count: long + :vartype value: list[~azure.quantum._client.models.JobDetails] + :ivar count: Total records count number. + :vartype count: long :ivar next_link: Link to the next page of results. :vartype next_link: str """ @@ -224,12 +321,71 @@ def __init__( count: Optional[int] = None, **kwargs ): + """ + :keyword count: Total records count number. + :paramtype count: long + """ super(JobDetailsList, self).__init__(**kwargs) self.value = None self.count = count self.next_link = None +class JsonPatchDocument(msrest.serialization.Model): + """A JSONPatch document as defined by RFC 6902. + + All required parameters must be populated in order to send to Azure. + + :ivar op: Required. The operation to be performed. Possible values include: "add", "remove", + "replace", "move", "copy", "test". + :vartype op: str or ~azure.quantum._client.models.JsonPatchOperation + :ivar path: Required. A JSON-Pointer. + :vartype path: str + :ivar value: A value to be used in the operation on the path. + :vartype value: any + :ivar from_property: Optional field used in copy and move operations. + :vartype from_property: str + """ + + _validation = { + 'op': {'required': True}, + 'path': {'required': True}, + } + + _attribute_map = { + 'op': {'key': 'op', 'type': 'str'}, + 'path': {'key': 'path', 'type': 'str'}, + 'value': {'key': 'value', 'type': 'object'}, + 'from_property': {'key': 'from', 'type': 'str'}, + } + + def __init__( + self, + *, + op: Union[str, "JsonPatchOperation"], + path: str, + value: Optional[Any] = None, + from_property: Optional[str] = None, + **kwargs + ): + """ + :keyword op: Required. The operation to be performed. Possible values include: "add", "remove", + "replace", "move", "copy", "test". + :paramtype op: str or ~azure.quantum._client.models.JsonPatchOperation + :keyword path: Required. A JSON-Pointer. + :paramtype path: str + :keyword value: A value to be used in the operation on the path. + :paramtype value: any + :keyword from_property: Optional field used in copy and move operations. + :paramtype from_property: str + """ + super(JsonPatchDocument, self).__init__(**kwargs) + self.op = op + self.path = path + self.value = value + self.from_property = from_property + + class ProviderStatus(msrest.serialization.Model): """Providers status. @@ -239,9 +395,9 @@ class ProviderStatus(msrest.serialization.Model): :vartype id: str :ivar current_availability: Provider availability. Possible values include: "Available", "Degraded", "Unavailable". - :vartype current_availability: str or ~azure.quantum.models.ProviderAvailability + :vartype current_availability: str or ~azure.quantum._client.models.ProviderAvailability :ivar targets: - :vartype targets: list[~azure.quantum.models.TargetStatus] + :vartype targets: list[~azure.quantum._client.models.TargetStatus] """ _validation = { @@ -260,6 +416,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProviderStatus, self).__init__(**kwargs) self.id = None self.current_availability = None @@ -272,7 +430,7 @@ class ProviderStatusList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: - :vartype value: list[~azure.quantum.models.ProviderStatus] + :vartype value: list[~azure.quantum._client.models.ProviderStatus] :ivar next_link: Link to the next page of results. :vartype next_link: str """ @@ -291,6 +449,8 @@ def __init__( self, **kwargs ): + """ + """ super(ProviderStatusList, self).__init__(**kwargs) self.value = None self.next_link = None @@ -299,24 +459,24 @@ def __init__( class Quota(msrest.serialization.Model): """Quota information. - :param dimension: The name of the dimension associated with the quota. - :type dimension: str - :param scope: The scope at which the quota is applied. Possible values include: "Workspace", + :ivar dimension: The name of the dimension associated with the quota. + :vartype dimension: str + :ivar scope: The scope at which the quota is applied. Possible values include: "Workspace", "Subscription". - :type scope: str or ~azure.quantum.models.DimensionScope - :param provider_id: The unique identifier for the provider. - :type provider_id: str - :param utilization: The amount of the usage that has been applied for the current period. - :type utilization: float - :param holds: The amount of the usage that has been reserved but not applied for the current + :vartype scope: str or ~azure.quantum._client.models.DimensionScope + :ivar provider_id: The unique identifier for the provider. + :vartype provider_id: str + :ivar utilization: The amount of the usage that has been applied for the current period. + :vartype utilization: float + :ivar holds: The amount of the usage that has been reserved but not applied for the current period. - :type holds: float - :param limit: The maximum amount of usage allowed for the current period. - :type limit: float - :param period: The time period in which the quota's underlying meter is accumulated. Based on + :vartype holds: float + :ivar limit: The maximum amount of usage allowed for the current period. + :vartype limit: float + :ivar period: The time period in which the quota's underlying meter is accumulated. Based on calendar year. 'None' is used for concurrent quotas. Possible values include: "None", "Monthly". - :type period: str or ~azure.quantum.models.MeterPeriod + :vartype period: str or ~azure.quantum._client.models.MeterPeriod """ _attribute_map = { @@ -341,6 +501,26 @@ def __init__( period: Optional[Union[str, "MeterPeriod"]] = None, **kwargs ): + """ + :keyword dimension: The name of the dimension associated with the quota. + :paramtype dimension: str + :keyword scope: The scope at which the quota is applied. Possible values include: "Workspace", + "Subscription". + :paramtype scope: str or ~azure.quantum._client.models.DimensionScope + :keyword provider_id: The unique identifier for the provider. + :paramtype provider_id: str + :keyword utilization: The amount of the usage that has been applied for the current period. + :paramtype utilization: float + :keyword holds: The amount of the usage that has been reserved but not applied for the current + period. + :paramtype holds: float + :keyword limit: The maximum amount of usage allowed for the current period. + :paramtype limit: float + :keyword period: The time period in which the quota's underlying meter is accumulated. Based on + calendar year. 'None' is used for concurrent quotas. Possible values include: "None", + "Monthly". + :paramtype period: str or ~azure.quantum._client.models.MeterPeriod + """ super(Quota, self).__init__(**kwargs) self.dimension = dimension self.scope = scope @@ -357,7 +537,7 @@ class QuotaList(msrest.serialization.Model): Variables are only populated by the server, and will be ignored when sending a request. :ivar value: - :vartype value: list[~azure.quantum.models.Quota] + :vartype value: list[~azure.quantum._client.models.Quota] :ivar next_link: Link to the next page of results. :vartype next_link: str """ @@ -376,6 +556,8 @@ def __init__( self, **kwargs ): + """ + """ super(QuotaList, self).__init__(**kwargs) self.value = None self.next_link = None @@ -384,8 +566,8 @@ def __init__( class RestError(msrest.serialization.Model): """Error information returned by the API. - :param error: An error response from Azure. - :type error: ~azure.quantum.models.ErrorData + :ivar error: An error response from Azure. + :vartype error: ~azure.quantum._client.models.ErrorData """ _attribute_map = { @@ -398,6 +580,10 @@ def __init__( error: Optional["ErrorData"] = None, **kwargs ): + """ + :keyword error: An error response from Azure. + :paramtype error: ~azure.quantum._client.models.ErrorData + """ super(RestError, self).__init__(**kwargs) self.error = error @@ -405,8 +591,8 @@ def __init__( class SasUriResponse(msrest.serialization.Model): """Get SAS URL operation response. - :param sas_uri: A URL with a SAS token to upload a blob for execution in the given workspace. - :type sas_uri: str + :ivar sas_uri: A URL with a SAS token to upload a blob for execution in the given workspace. + :vartype sas_uri: str """ _attribute_map = { @@ -419,6 +605,10 @@ def __init__( sas_uri: Optional[str] = None, **kwargs ): + """ + :keyword sas_uri: A URL with a SAS token to upload a blob for execution in the given workspace. + :paramtype sas_uri: str + """ super(SasUriResponse, self).__init__(**kwargs) self.sas_uri = sas_uri @@ -432,7 +622,7 @@ class TargetStatus(msrest.serialization.Model): :vartype id: str :ivar current_availability: Target availability. Possible values include: "Available", "Degraded", "Unavailable". - :vartype current_availability: str or ~azure.quantum.models.TargetAvailability + :vartype current_availability: str or ~azure.quantum._client.models.TargetAvailability :ivar average_queue_time: Average queue time in seconds. :vartype average_queue_time: long :ivar status_page: A page with detailed status of the provider. @@ -457,8 +647,70 @@ def __init__( self, **kwargs ): + """ + """ super(TargetStatus, self).__init__(**kwargs) self.id = None self.current_availability = None self.average_queue_time = None self.status_page = None + + +class UsageEvent(msrest.serialization.Model): + """Usage event details. + + :ivar dimension_id: The dimension id. + :vartype dimension_id: str + :ivar dimension_name: The dimension name. + :vartype dimension_name: str + :ivar measure_unit: The unit of measure. + :vartype measure_unit: str + :ivar amount_billed: The amount billed. + :vartype amount_billed: float + :ivar amount_consumed: The amount consumed. + :vartype amount_consumed: float + :ivar unit_price: The unit price. + :vartype unit_price: float + """ + + _attribute_map = { + 'dimension_id': {'key': 'dimensionId', 'type': 'str'}, + 'dimension_name': {'key': 'dimensionName', 'type': 'str'}, + 'measure_unit': {'key': 'measureUnit', 'type': 'str'}, + 'amount_billed': {'key': 'amountBilled', 'type': 'float'}, + 'amount_consumed': {'key': 'amountConsumed', 'type': 'float'}, + 'unit_price': {'key': 'unitPrice', 'type': 'float'}, + } + + def __init__( + self, + *, + dimension_id: Optional[str] = None, + dimension_name: Optional[str] = None, + measure_unit: Optional[str] = None, + amount_billed: Optional[float] = None, + amount_consumed: Optional[float] = None, + unit_price: Optional[float] = None, + **kwargs + ): + """ + :keyword dimension_id: The dimension id. + :paramtype dimension_id: str + :keyword dimension_name: The dimension name. + :paramtype dimension_name: str + :keyword measure_unit: The unit of measure. + :paramtype measure_unit: str + :keyword amount_billed: The amount billed. + :paramtype amount_billed: float + :keyword amount_consumed: The amount consumed. + :paramtype amount_consumed: float + :keyword unit_price: The unit price. + :paramtype unit_price: float + """ + super(UsageEvent, self).__init__(**kwargs) + self.dimension_id = dimension_id + self.dimension_name = dimension_name + self.measure_unit = measure_unit + self.amount_billed = amount_billed + self.amount_consumed = amount_consumed + self.unit_price = unit_price diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_quantum_client_enums.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_quantum_client_enums.py index 7d883d845c0..86e843202f4 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_quantum_client_enums.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/models/_quantum_client_enums.py @@ -6,34 +6,19 @@ # Changes may cause incorrect behavior and will be lost if the code is regenerated. # -------------------------------------------------------------------------- -from enum import Enum, EnumMeta +from enum import Enum from six import with_metaclass +from azure.core import CaseInsensitiveEnumMeta -class _CaseInsensitiveEnumMeta(EnumMeta): - def __getitem__(self, name): - return super().__getitem__(name.upper()) - def __getattr__(cls, name): - """Return the enum member matching `name` - We use __getattr__ instead of descriptors or inserting into the enum - class' __dict__ in order to support `name` and `value` being both - properties for enum members (which live in the class' __dict__) and - enum members themselves. - """ - try: - return cls._member_map_[name.upper()] - except KeyError: - raise AttributeError(name) - - -class DimensionScope(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class DimensionScope(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The scope at which the quota is applied. """ WORKSPACE = "Workspace" SUBSCRIPTION = "Subscription" -class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JobStatus(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The job status. """ @@ -43,7 +28,18 @@ class JobStatus(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): FAILED = "Failed" CANCELLED = "Cancelled" -class MeterPeriod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class JsonPatchOperation(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): + """The operation to be performed. + """ + + ADD = "add" + REMOVE = "remove" + REPLACE = "replace" + MOVE = "move" + COPY = "copy" + TEST = "test" + +class MeterPeriod(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """The time period in which the quota's underlying meter is accumulated. Based on calendar year. 'None' is used for concurrent quotas. """ @@ -51,7 +47,7 @@ class MeterPeriod(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): NONE = "None" MONTHLY = "Monthly" -class ProviderAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class ProviderAvailability(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Provider availability. """ @@ -59,7 +55,7 @@ class ProviderAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): DEGRADED = "Degraded" UNAVAILABLE = "Unavailable" -class TargetAvailability(with_metaclass(_CaseInsensitiveEnumMeta, str, Enum)): +class TargetAvailability(with_metaclass(CaseInsensitiveEnumMeta, str, Enum)): """Target availability. """ diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_jobs_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_jobs_operations.py index e83215c590c..879019fa527 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_jobs_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_jobs_operations.py @@ -5,24 +5,197 @@ # 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 TYPE_CHECKING 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.mgmt.core.exceptions import ARMErrorFormat +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports - from typing import Any, Callable, Dict, Generic, Iterable, Optional, TypeVar, Union - + from typing import Any, Callable, Dict, Generic, Iterable, List, Optional, TypeVar, Union T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + + +def build_get_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + job_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + + +def build_create_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + job_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + + +def build_cancel_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + job_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + + +def build_patch_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + job_id, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + "jobId": _SERIALIZER.url("job_id", job_id, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + +# fmt: on class JobsOperations(object): """JobsOperations operations. @@ -30,7 +203,7 @@ class JobsOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -45,6 +218,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +228,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either JobDetailsList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.quantum.models.JobDetailsList] + :rtype: ~azure.core.paging.ItemPaged[~azure.quantum._client.models.JobDetailsList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobDetailsList"] @@ -62,34 +236,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_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('JobDetailsList', pipeline_response) + deserialized = self._deserialize("JobDetailsList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -103,15 +276,17 @@ def get_next(next_link=None): if response.status_code not in [200]: map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, error_format=ARMErrorFormat) + raise HttpResponseError(response=response) return pipeline_response + return ItemPaged( get_next, extract_data ) list.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs'} # type: ignore + @distributed_trace def get( self, job_id, # type: str @@ -124,7 +299,7 @@ def get( :type job_id: str :keyword callable cls: A custom type or function that will be passed the direct response :return: JobDetails, or the result of cls(response) - :rtype: ~azure.quantum.models.JobDetails + :rtype: ~azure.quantum._client.models.JobDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobDetails"] @@ -132,33 +307,25 @@ def get( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.get.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_get_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + 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.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('JobDetails', pipeline_response) @@ -166,8 +333,11 @@ def get( return cls(pipeline_response, deserialized, {}) return deserialized + get.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def create( self, job_id, # type: str @@ -180,10 +350,10 @@ def create( :param job_id: Id of the job. :type job_id: str :param job: The complete metadata of the job to submit. - :type job: ~azure.quantum.models.JobDetails + :type job: ~azure.quantum._client.models.JobDetails :keyword callable cls: A custom type or function that will be passed the direct response :return: JobDetails, or the result of cls(response) - :rtype: ~azure.quantum.models.JobDetails + :rtype: ~azure.quantum._client.models.JobDetails :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.JobDetails"] @@ -191,38 +361,30 @@ def create( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.create.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + 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(job, 'JobDetails') + + request = build_create_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + content_type=content_type, + json=_json, + template_url=self.create.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(job, 'JobDetails') - 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.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) if response.status_code == 200: deserialized = self._deserialize('JobDetails', pipeline_response) @@ -234,8 +396,11 @@ def create( return cls(pipeline_response, deserialized, {}) return deserialized + create.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + + @distributed_trace def cancel( self, job_id, # type: str @@ -256,35 +421,89 @@ def cancel( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - - # Construct URL - url = self.cancel.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - 'jobId': self._serialize.url("job_id", job_id, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') + + request = build_cancel_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + template_url=self.cancel.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 [204]: map_error(status_code=response.status_code, response=response, error_map=error_map) - error = self._deserialize.failsafe_deserialize(_models.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) if cls: return cls(pipeline_response, None, {}) cancel.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + + + @distributed_trace + def patch( + self, + job_id, # type: str + patch_job, # type: List["_models.JsonPatchDocument"] + **kwargs # type: Any + ): + # type: (...) -> Optional["_models.JobDetails"] + """Patch a job. + + :param job_id: Id of the job. + :type job_id: str + :param patch_job: The json patch document containing the patch operations. + :type patch_job: list[~azure.quantum._client.models.JsonPatchDocument] + :keyword callable cls: A custom type or function that will be passed the direct response + :return: JobDetails, or the result of cls(response) + :rtype: ~azure.quantum._client.models.JobDetails or None + :raises: ~azure.core.exceptions.HttpResponseError + """ + cls = kwargs.pop('cls', None) # type: ClsType[Optional["_models.JobDetails"]] + 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(patch_job, '[JsonPatchDocument]') + + request = build_patch_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + job_id=job_id, + content_type=content_type, + json=_json, + template_url=self.patch.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, 204]: + map_error(status_code=response.status_code, response=response, error_map=error_map) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JobDetails', pipeline_response) + + if cls: + return cls(pipeline_response, deserialized, {}) + + return deserialized + + patch.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} # type: ignore + diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_providers_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_providers_operations.py index 114b91916f4..e18defa0514 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_providers_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_providers_operations.py @@ -5,24 +5,61 @@ # 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 TYPE_CHECKING 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.mgmt.core.exceptions import ARMErrorFormat +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_get_status_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/providerStatus') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + +# fmt: on class ProvidersOperations(object): """ProvidersOperations operations. @@ -30,7 +67,7 @@ class ProvidersOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -45,6 +82,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def get_status( self, **kwargs # type: Any @@ -54,7 +92,7 @@ def get_status( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either ProviderStatusList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.quantum.models.ProviderStatusList] + :rtype: ~azure.core.paging.ItemPaged[~azure.quantum._client.models.ProviderStatusList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.ProviderStatusList"] @@ -62,34 +100,33 @@ def get_status( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - 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.get_status.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_get_status_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + template_url=self.get_status.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_get_status_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_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('ProviderStatusList', pipeline_response) + deserialized = self._deserialize("ProviderStatusList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +139,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.RestError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_quotas_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_quotas_operations.py index 863524d4df4..8ebd532d227 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_quotas_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_quotas_operations.py @@ -5,24 +5,61 @@ # 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 TYPE_CHECKING 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.mgmt.core.exceptions import ARMErrorFormat +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section 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]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_list_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/quotas') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + +# fmt: on class QuotasOperations(object): """QuotasOperations operations. @@ -30,7 +67,7 @@ class QuotasOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -45,6 +82,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def list( self, **kwargs # type: Any @@ -54,7 +92,7 @@ def list( :keyword callable cls: A custom type or function that will be passed the direct response :return: An iterator like instance of either QuotaList or the result of cls(response) - :rtype: ~azure.core.paging.ItemPaged[~azure.quantum.models.QuotaList] + :rtype: ~azure.core.paging.ItemPaged[~azure.quantum._client.models.QuotaList] :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.QuotaList"] @@ -62,34 +100,33 @@ def list( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - accept = "application/json" - def prepare_request(next_link=None): - # Construct headers - header_parameters = {} # type: Dict[str, Any] - header_parameters['Accept'] = self._serialize.header("accept", accept, 'str') - if not next_link: - # Construct URL - url = self.list.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] - - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + template_url=self.list.metadata['url'], + ) + request = _convert_request(request) + request.url = self._client.format_url(request.url) + else: - url = next_link - query_parameters = {} # type: Dict[str, Any] - request = self._client.get(url, query_parameters, header_parameters) + + request = build_list_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_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('QuotaList', pipeline_response) + deserialized = self._deserialize("QuotaList", pipeline_response) list_of_elem = deserialized.value if cls: list_of_elem = cls(list_of_elem) @@ -102,12 +139,13 @@ def get_next(next_link=None): response = pipeline_response.http_response if response.status_code not in [200]: - error = self._deserialize.failsafe_deserialize(_models.RestError, response) map_error(status_code=response.status_code, response=response, error_map=error_map) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) return pipeline_response + return ItemPaged( get_next, extract_data ) diff --git a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_storage_operations.py b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_storage_operations.py index 0d9e08fcdcf..9133b65a449 100644 --- a/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_storage_operations.py +++ b/src/quantum/azext_quantum/vendored_sdks/azure_quantum/operations/_storage_operations.py @@ -5,23 +5,64 @@ # 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 TYPE_CHECKING import warnings from azure.core.exceptions import ClientAuthenticationError, HttpResponseError, ResourceExistsError, ResourceNotFoundError, map_error from azure.core.pipeline import PipelineResponse -from azure.core.pipeline.transport import HttpRequest, HttpResponse -from azure.mgmt.core.exceptions import ARMErrorFormat +from azure.core.pipeline.transport import HttpResponse +from azure.core.rest import HttpRequest +from azure.core.tracing.decorator import distributed_trace +from msrest import Serializer from .. import models as _models +from .._vendor import _convert_request, _format_url_section if TYPE_CHECKING: # pylint: disable=unused-import,ungrouped-imports from typing import Any, Callable, Dict, Generic, Optional, TypeVar - T = TypeVar('T') ClsType = Optional[Callable[[PipelineResponse[HttpRequest, HttpResponse], T, Dict[str, Any]], Any]] +_SERIALIZER = Serializer() +_SERIALIZER.client_side_validation = False +# fmt: off + +def build_sas_uri_request( + subscription_id, # type: str + resource_group_name, # type: str + workspace_name, # type: str + **kwargs # type: Any +): + # type: (...) -> HttpRequest + content_type = kwargs.pop('content_type', None) # type: Optional[str] + + accept = "application/json" + # Construct URL + url = kwargs.pop("template_url", '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/storage/sasUri') + path_format_arguments = { + "subscriptionId": _SERIALIZER.url("subscription_id", subscription_id, 'str'), + "resourceGroupName": _SERIALIZER.url("resource_group_name", resource_group_name, 'str'), + "workspaceName": _SERIALIZER.url("workspace_name", workspace_name, 'str'), + } + + url = _format_url_section(url, **path_format_arguments) + + # 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, + headers=header_parameters, + **kwargs + ) + +# fmt: on class StorageOperations(object): """StorageOperations operations. @@ -29,7 +70,7 @@ class StorageOperations(object): instantiates it for you and attaches it as an attribute. :ivar models: Alias to model classes used in this operation group. - :type models: ~azure.quantum.models + :type models: ~azure.quantum._client.models :param client: Client for service requests. :param config: Configuration of service client. :param serializer: An object model serializer. @@ -44,6 +85,7 @@ def __init__(self, client, config, serializer, deserializer): self._deserialize = deserializer self._config = config + @distributed_trace def sas_uri( self, blob_details, # type: "_models.BlobDetails" @@ -54,10 +96,10 @@ def sas_uri( workspace. The SAS URL can be used to upload job input and/or download job output. :param blob_details: The details (name and container) of the blob to store or download data. - :type blob_details: ~azure.quantum.models.BlobDetails + :type blob_details: ~azure.quantum._client.models.BlobDetails :keyword callable cls: A custom type or function that will be passed the direct response :return: SasUriResponse, or the result of cls(response) - :rtype: ~azure.quantum.models.SasUriResponse + :rtype: ~azure.quantum._client.models.SasUriResponse :raises: ~azure.core.exceptions.HttpResponseError """ cls = kwargs.pop('cls', None) # type: ClsType["_models.SasUriResponse"] @@ -65,37 +107,29 @@ def sas_uri( 401: ClientAuthenticationError, 404: ResourceNotFoundError, 409: ResourceExistsError } error_map.update(kwargs.pop('error_map', {})) - content_type = kwargs.pop("content_type", "application/json") - accept = "application/json" - - # Construct URL - url = self.sas_uri.metadata['url'] # type: ignore - path_format_arguments = { - 'subscriptionId': self._serialize.url("self._config.subscription_id", self._config.subscription_id, 'str'), - 'resourceGroupName': self._serialize.url("self._config.resource_group_name", self._config.resource_group_name, 'str'), - 'workspaceName': self._serialize.url("self._config.workspace_name", self._config.workspace_name, 'str'), - } - url = self._client.format_url(url, **path_format_arguments) - # Construct parameters - query_parameters = {} # type: Dict[str, Any] + content_type = kwargs.pop('content_type', "application/json") # type: Optional[str] + + _json = self._serialize.body(blob_details, 'BlobDetails') - # 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_sas_uri_request( + subscription_id=self._config.subscription_id, + resource_group_name=self._config.resource_group_name, + workspace_name=self._config.workspace_name, + content_type=content_type, + json=_json, + template_url=self.sas_uri.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(blob_details, 'BlobDetails') - body_content_kwargs['content'] = body_content - request = self._client.post(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.RestError, response) - raise HttpResponseError(response=response, model=error, error_format=ARMErrorFormat) + error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response) + raise HttpResponseError(response=response, model=error) deserialized = self._deserialize('SasUriResponse', pipeline_response) @@ -103,4 +137,6 @@ def sas_uri( return cls(pipeline_response, deserialized, {}) return deserialized + sas_uri.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/storage/sasUri'} # type: ignore + diff --git a/src/quantum/eng/Generate-DataPlane-Client.ps1 b/src/quantum/eng/Generate-DataPlane-Client.ps1 new file mode 100644 index 00000000000..faef9257499 --- /dev/null +++ b/src/quantum/eng/Generate-DataPlane-Client.ps1 @@ -0,0 +1,69 @@ +# -------------------------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for license information. +# -------------------------------------------------------------------------------------------- + +<# +.SYNOPSIS +(Re)Generate the underlying Azure Quantum Python data-Plane client for the CLI based on the latest published Swagger. +.DESCRIPTION +(Re)Generate the underlying Azure Quantum Python data-Plane client for the CLI based on the latest published Swagger. +.PARAMETER SwaggerRepoUrl +The URL of the git repo that contains the Swagger and AutoRest ReadMe.md configurations (defaults to "https://github.com/Azure/azure-rest-api-specs") +.PARAMETER SwaggerRepoBranch +The name of the swagger repo branch (defaults to "main") +.PARAMETER SwaggerTagVersion +The Swagger version to be used (defaults to "", which will use the default tag from the main ReadMe.md) + +.EXAMPLE +./eng/Generate-DataPlane-Client.ps1 + +# Regenerate the data-plane client using the latest published Swagger from the official repo + +.EXAMPLE +./eng/Generate-DataPlane-Client.ps1 -SwaggerRepoBranch "feature/quantum/update-clients" + +# Regenerate the data-plane client using the Swagger from the official repo, but from a feature branch + +.EXAMPLE +./eng/Generate-DataPlane-Client.ps1 -SwaggerTagVersion "package-2019-11-04-preview" + +# Regenerate the data-plane client using the an older version of the Swagger + +#> + +[CmdletBinding()] +Param ( + [string] $SwaggerRepoUrl = "https://github.com/Azure/azure-rest-api-specs", + [string] $SwaggerRepoBranch = "main", + [string] $SwaggerTagVersion +) + +$OutputFolder = Join-Path $PSScriptRoot "../azext_quantum/vendored_sdks/azure_quantum/" + +$AutoRestConfig = "$SwaggerRepoUrl/blob/$SwaggerRepoBranch/specification/quantum/data-plane/readme.md" + +Write-Verbose "Installing latest AutoRest client" +npm install -g autorest@latest | Write-Verbose + +if ([string]::IsNullOrEmpty($SwaggerTagVersion)) +{ + Write-Verbose "Generating the client based on:`nConfig: $AutoRestConfig" + autorest $AutoRestConfig ` + --verbose ` + --python ` + --python-mode=cli ` + --output-folder=$OutputFolder ` + | Write-Verbose +} +else +{ + Write-Verbose "Generating the client based on:`nConfig: $AutoRestConfig`nTag: $SwaggerTagVersion" + autorest $AutoRestConfig ` + --verbose ` + --python ` + --python-mode=cli ` + --tag=$SwaggerTagVersion ` + --output-folder=$OutputFolder ` + | Write-Verbose +}