diff --git a/sdk/quantum/azure-quantum/azure/quantum/__init__.py b/sdk/quantum/azure-quantum/azure/quantum/__init__.py new file mode 100644 index 000000000000..056c6b3491d2 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/__init__.py @@ -0,0 +1,19 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from ._configuration import QuantumClientConfiguration +from ._quantum_client import QuantumClient +__all__ = ['QuantumClient', 'QuantumClientConfiguration'] + +from .version import VERSION + +__version__ = VERSION + diff --git a/sdk/quantum/azure-quantum/azure/quantum/_configuration.py b/sdk/quantum/azure-quantum/azure/quantum/_configuration.py new file mode 100644 index 000000000000..3075aea4878e --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/_configuration.py @@ -0,0 +1,59 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- +from msrestazure import AzureConfiguration + +from .version import VERSION + + +class QuantumClientConfiguration(AzureConfiguration): + """Configuration for QuantumClient + Note that all parameters used to create this instance are saved as instance + attributes. + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :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 + """ + + def __init__( + self, credentials, subscription_id, resource_group_name, workspace_name, base_url=None): + + if credentials is None: + raise ValueError("Parameter 'credentials' must not be None.") + if subscription_id is None: + raise ValueError("Parameter 'subscription_id' must not be None.") + if resource_group_name is None: + raise ValueError("Parameter 'resource_group_name' must not be None.") + if workspace_name is None: + raise ValueError("Parameter 'workspace_name' must not be None.") + if not base_url: + base_url = 'https://quantum.azure.com' + + super(QuantumClientConfiguration, self).__init__(base_url) + + # Starting Autorest.Python 4.0.64, make connection pool activated by default + self.keep_alive = True + + self.add_user_agent('azure-quantum/{}'.format(VERSION)) + self.add_user_agent('Azure-SDK-For-Python') + + self.credentials = credentials + self.subscription_id = subscription_id + self.resource_group_name = resource_group_name + self.workspace_name = workspace_name diff --git a/sdk/quantum/azure-quantum/azure/quantum/_quantum_client.py b/sdk/quantum/azure-quantum/azure/quantum/_quantum_client.py new file mode 100644 index 000000000000..270b883bd55a --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/_quantum_client.py @@ -0,0 +1,64 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.service_client import SDKClient +from msrest import Serializer, Deserializer + +from ._configuration import QuantumClientConfiguration +from .operations import JobsOperations +from .operations import ProvidersOperations +from .operations import StorageOperations +from . import models + + +class QuantumClient(SDKClient): + """Azure Quantum REST API client + + :ivar config: Configuration for client. + :vartype config: QuantumClientConfiguration + + :ivar jobs: Jobs operations + :vartype jobs: azure.quantum.operations.JobsOperations + :ivar providers: Providers operations + :vartype providers: azure.quantum.operations.ProvidersOperations + :ivar storage: Storage operations + :vartype storage: azure.quantum.operations.StorageOperations + + :param credentials: Credentials needed for the client to connect to Azure. + :type credentials: :mod:`A msrestazure Credentials + object` + :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 + """ + + def __init__( + self, credentials, subscription_id, resource_group_name, workspace_name, base_url=None): + + self.config = QuantumClientConfiguration(credentials, subscription_id, resource_group_name, workspace_name, base_url) + super(QuantumClient, self).__init__(self.config.credentials, self.config) + + client_models = {k: v for k, v in models.__dict__.items() if isinstance(v, type)} + self.api_version = '2019-11-04-preview' + self._serialize = Serializer(client_models) + self._deserialize = Deserializer(client_models) + + 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) diff --git a/sdk/quantum/azure-quantum/azure/quantum/models/__init__.py b/sdk/quantum/azure-quantum/azure/quantum/models/__init__.py new file mode 100644 index 000000000000..c3d830cf855d --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/__init__.py @@ -0,0 +1,49 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +try: + from ._models_py3 import BlobDetails + from ._models_py3 import ErrorData + from ._models_py3 import JobDetails + from ._models_py3 import ProviderStatus + from ._models_py3 import RestError, RestErrorException + from ._models_py3 import SasUriResponse + from ._models_py3 import TargetStatus +except (SyntaxError, ImportError): + from ._models import BlobDetails + from ._models import ErrorData + from ._models import JobDetails + from ._models import ProviderStatus + from ._models import RestError, RestErrorException + from ._models import SasUriResponse + from ._models import TargetStatus +from ._paged_models import JobDetailsPaged +from ._paged_models import ProviderStatusPaged +from ._quantum_client_enums import ( + JobStatus, + ProviderAvailability, + TargetAvailability, +) + +__all__ = [ + 'BlobDetails', + 'ErrorData', + 'JobDetails', + 'ProviderStatus', + 'RestError', 'RestErrorException', + 'SasUriResponse', + 'TargetStatus', + 'JobDetailsPaged', + 'ProviderStatusPaged', + 'JobStatus', + 'ProviderAvailability', + 'TargetAvailability', +] diff --git a/sdk/quantum/azure-quantum/azure/quantum/models/_models.py b/sdk/quantum/azure-quantum/azure/quantum/models/_models.py new file mode 100644 index 000000000000..19155ee2de76 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_models.py @@ -0,0 +1,297 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class BlobDetails(Model): + """Blob details. + + 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 + """ + + _validation = { + 'container_name': {'required': True}, + } + + _attribute_map = { + 'container_name': {'key': 'containerName', 'type': 'str'}, + 'blob_name': {'key': 'blobName', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(BlobDetails, self).__init__(**kwargs) + self.container_name = kwargs.get('container_name', None) + self.blob_name = kwargs.get('blob_name', None) + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class ErrorData(Model): + """An error response from Azure. + + :param 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 + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(ErrorData, self).__init__(**kwargs) + self.code = kwargs.get('code', None) + self.message = kwargs.get('message', None) + + +class JobDetails(Model): + """Job details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 display purposes. + :type name: str + :param 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 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: object + :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 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 + :ivar status: The job status. Possible values include: 'Waiting', + 'Executing', 'Succeeded', 'Failed', 'Cancelled' + :vartype status: str or ~azure.quantum.models.JobStatus + :ivar creation_time: The creation time of the job. + :vartype creation_time: datetime + :ivar begin_execution_time: The time when the job began execution. + :vartype begin_execution_time: datetime + :ivar end_execution_time: The time when the job finished execution. + :vartype end_execution_time: datetime + :ivar cancellation_time: The time when a job was successfully cancelled. + :vartype cancellation_time: datetime + :ivar error_data: The error data for the job. This is expected only when + Status 'Failed'. + :vartype error_data: ~azure.quantum.models.ErrorData + """ + + _validation = { + 'container_uri': {'required': True}, + 'input_data_format': {'required': True}, + 'provider_id': {'required': True}, + 'target': {'required': True}, + 'status': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'begin_execution_time': {'readonly': True}, + 'end_execution_time': {'readonly': True}, + 'cancellation_time': {'readonly': True}, + 'error_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'container_uri': {'key': 'containerUri', 'type': 'str'}, + 'input_data_uri': {'key': 'inputDataUri', 'type': 'str'}, + 'input_data_format': {'key': 'inputDataFormat', 'type': 'str'}, + 'input_params': {'key': 'inputParams', 'type': 'object'}, + 'provider_id': {'key': 'providerId', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, + 'output_data_uri': {'key': 'outputDataUri', 'type': 'str'}, + 'output_data_format': {'key': 'outputDataFormat', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + 'begin_execution_time': {'key': 'beginExecutionTime', 'type': 'iso-8601'}, + 'end_execution_time': {'key': 'endExecutionTime', 'type': 'iso-8601'}, + 'cancellation_time': {'key': 'cancellationTime', 'type': 'iso-8601'}, + 'error_data': {'key': 'errorData', 'type': 'ErrorData'}, + } + + def __init__(self, **kwargs): + super(JobDetails, self).__init__(**kwargs) + self.id = kwargs.get('id', None) + self.name = kwargs.get('name', None) + self.container_uri = kwargs.get('container_uri', None) + self.input_data_uri = kwargs.get('input_data_uri', None) + self.input_data_format = kwargs.get('input_data_format', None) + self.input_params = kwargs.get('input_params', None) + self.provider_id = kwargs.get('provider_id', None) + self.target = kwargs.get('target', None) + self.metadata = kwargs.get('metadata', None) + self.output_data_uri = kwargs.get('output_data_uri', None) + self.output_data_format = kwargs.get('output_data_format', None) + self.status = None + self.creation_time = None + self.begin_execution_time = None + self.end_execution_time = None + self.cancellation_time = None + self.error_data = None + + +class ProviderStatus(Model): + """Providers status. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Provider id. + :vartype id: str + :ivar current_availability: Provider availability. Possible values + include: 'Available', 'Degraded', 'Unavailable' + :vartype current_availability: str or + ~azure.quantum.models.ProviderAvailability + :ivar targets: + :vartype targets: list[~azure.quantum.models.TargetStatus] + """ + + _validation = { + 'id': {'readonly': True}, + 'current_availability': {'readonly': True}, + 'targets': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'current_availability': {'key': 'currentAvailability', 'type': 'str'}, + 'targets': {'key': 'targets', 'type': '[TargetStatus]'}, + } + + def __init__(self, **kwargs): + super(ProviderStatus, self).__init__(**kwargs) + self.id = None + self.current_availability = None + self.targets = None + + +class RestError(Model): + """Error information returned by the API. + + :param error: + :type error: ~azure.quantum.models.ErrorData + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorData'}, + } + + def __init__(self, **kwargs): + super(RestError, self).__init__(**kwargs) + self.error = kwargs.get('error', None) + + +class RestErrorException(HttpOperationError): + """Server responsed with exception of type: 'RestError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(RestErrorException, self).__init__(deserialize, response, 'RestError', *args) + + +class SasUriResponse(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 + """ + + _attribute_map = { + 'sas_uri': {'key': 'sasUri', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(SasUriResponse, self).__init__(**kwargs) + self.sas_uri = kwargs.get('sas_uri', None) + + +class TargetStatus(Model): + """Target status. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Target id. + :vartype id: str + :ivar current_availability: Target availability. Possible values include: + 'Available', 'Degraded', 'Unavailable' + :vartype current_availability: str or + ~azure.quantum.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. + :vartype status_page: str + """ + + _validation = { + 'id': {'readonly': True}, + 'current_availability': {'readonly': True}, + 'average_queue_time': {'readonly': True}, + 'status_page': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'current_availability': {'key': 'currentAvailability', 'type': 'str'}, + 'average_queue_time': {'key': 'averageQueueTime', 'type': 'long'}, + 'status_page': {'key': 'statusPage', 'type': 'str'}, + } + + 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 diff --git a/sdk/quantum/azure-quantum/azure/quantum/models/_models_py3.py b/sdk/quantum/azure-quantum/azure/quantum/models/_models_py3.py new file mode 100644 index 000000000000..97fed106d09a --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_models_py3.py @@ -0,0 +1,297 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.serialization import Model +from msrest.exceptions import HttpOperationError + + +class BlobDetails(Model): + """Blob details. + + 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 + """ + + _validation = { + 'container_name': {'required': True}, + } + + _attribute_map = { + 'container_name': {'key': 'containerName', 'type': 'str'}, + 'blob_name': {'key': 'blobName', 'type': 'str'}, + } + + def __init__(self, *, container_name: str, blob_name: str=None, **kwargs) -> None: + super(BlobDetails, self).__init__(**kwargs) + self.container_name = container_name + self.blob_name = blob_name + + +class CloudError(Model): + """CloudError. + """ + + _attribute_map = { + } + + +class ErrorData(Model): + """An error response from Azure. + + :param 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 + """ + + _attribute_map = { + 'code': {'key': 'code', 'type': 'str'}, + 'message': {'key': 'message', 'type': 'str'}, + } + + def __init__(self, *, code: str=None, message: str=None, **kwargs) -> None: + super(ErrorData, self).__init__(**kwargs) + self.code = code + self.message = message + + +class JobDetails(Model): + """Job details. + + Variables are only populated by the server, and will be ignored when + sending a request. + + All required parameters must be populated in order to send to Azure. + + :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 display purposes. + :type name: str + :param 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 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: object + :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 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 + :ivar status: The job status. Possible values include: 'Waiting', + 'Executing', 'Succeeded', 'Failed', 'Cancelled' + :vartype status: str or ~azure.quantum.models.JobStatus + :ivar creation_time: The creation time of the job. + :vartype creation_time: datetime + :ivar begin_execution_time: The time when the job began execution. + :vartype begin_execution_time: datetime + :ivar end_execution_time: The time when the job finished execution. + :vartype end_execution_time: datetime + :ivar cancellation_time: The time when a job was successfully cancelled. + :vartype cancellation_time: datetime + :ivar error_data: The error data for the job. This is expected only when + Status 'Failed'. + :vartype error_data: ~azure.quantum.models.ErrorData + """ + + _validation = { + 'container_uri': {'required': True}, + 'input_data_format': {'required': True}, + 'provider_id': {'required': True}, + 'target': {'required': True}, + 'status': {'readonly': True}, + 'creation_time': {'readonly': True}, + 'begin_execution_time': {'readonly': True}, + 'end_execution_time': {'readonly': True}, + 'cancellation_time': {'readonly': True}, + 'error_data': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'name': {'key': 'name', 'type': 'str'}, + 'container_uri': {'key': 'containerUri', 'type': 'str'}, + 'input_data_uri': {'key': 'inputDataUri', 'type': 'str'}, + 'input_data_format': {'key': 'inputDataFormat', 'type': 'str'}, + 'input_params': {'key': 'inputParams', 'type': 'object'}, + 'provider_id': {'key': 'providerId', 'type': 'str'}, + 'target': {'key': 'target', 'type': 'str'}, + 'metadata': {'key': 'metadata', 'type': '{str}'}, + 'output_data_uri': {'key': 'outputDataUri', 'type': 'str'}, + 'output_data_format': {'key': 'outputDataFormat', 'type': 'str'}, + 'status': {'key': 'status', 'type': 'str'}, + 'creation_time': {'key': 'creationTime', 'type': 'iso-8601'}, + 'begin_execution_time': {'key': 'beginExecutionTime', 'type': 'iso-8601'}, + 'end_execution_time': {'key': 'endExecutionTime', 'type': 'iso-8601'}, + 'cancellation_time': {'key': 'cancellationTime', 'type': 'iso-8601'}, + 'error_data': {'key': 'errorData', 'type': 'ErrorData'}, + } + + def __init__(self, *, container_uri: str, input_data_format: str, provider_id: str, target: str, id: str=None, name: str=None, input_data_uri: str=None, input_params=None, metadata=None, output_data_uri: str=None, output_data_format: str=None, **kwargs) -> None: + super(JobDetails, self).__init__(**kwargs) + self.id = id + self.name = name + self.container_uri = container_uri + self.input_data_uri = input_data_uri + self.input_data_format = input_data_format + self.input_params = input_params + self.provider_id = provider_id + self.target = target + self.metadata = metadata + self.output_data_uri = output_data_uri + self.output_data_format = output_data_format + self.status = None + self.creation_time = None + self.begin_execution_time = None + self.end_execution_time = None + self.cancellation_time = None + self.error_data = None + + +class ProviderStatus(Model): + """Providers status. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Provider id. + :vartype id: str + :ivar current_availability: Provider availability. Possible values + include: 'Available', 'Degraded', 'Unavailable' + :vartype current_availability: str or + ~azure.quantum.models.ProviderAvailability + :ivar targets: + :vartype targets: list[~azure.quantum.models.TargetStatus] + """ + + _validation = { + 'id': {'readonly': True}, + 'current_availability': {'readonly': True}, + 'targets': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'current_availability': {'key': 'currentAvailability', 'type': 'str'}, + 'targets': {'key': 'targets', 'type': '[TargetStatus]'}, + } + + def __init__(self, **kwargs) -> None: + super(ProviderStatus, self).__init__(**kwargs) + self.id = None + self.current_availability = None + self.targets = None + + +class RestError(Model): + """Error information returned by the API. + + :param error: + :type error: ~azure.quantum.models.ErrorData + """ + + _attribute_map = { + 'error': {'key': 'error', 'type': 'ErrorData'}, + } + + def __init__(self, *, error=None, **kwargs) -> None: + super(RestError, self).__init__(**kwargs) + self.error = error + + +class RestErrorException(HttpOperationError): + """Server responsed with exception of type: 'RestError'. + + :param deserialize: A deserializer + :param response: Server response to be deserialized. + """ + + def __init__(self, deserialize, response, *args): + + super(RestErrorException, self).__init__(deserialize, response, 'RestError', *args) + + +class SasUriResponse(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 + """ + + _attribute_map = { + 'sas_uri': {'key': 'sasUri', 'type': 'str'}, + } + + def __init__(self, *, sas_uri: str=None, **kwargs) -> None: + super(SasUriResponse, self).__init__(**kwargs) + self.sas_uri = sas_uri + + +class TargetStatus(Model): + """Target status. + + Variables are only populated by the server, and will be ignored when + sending a request. + + :ivar id: Target id. + :vartype id: str + :ivar current_availability: Target availability. Possible values include: + 'Available', 'Degraded', 'Unavailable' + :vartype current_availability: str or + ~azure.quantum.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. + :vartype status_page: str + """ + + _validation = { + 'id': {'readonly': True}, + 'current_availability': {'readonly': True}, + 'average_queue_time': {'readonly': True}, + 'status_page': {'readonly': True}, + } + + _attribute_map = { + 'id': {'key': 'id', 'type': 'str'}, + 'current_availability': {'key': 'currentAvailability', 'type': 'str'}, + 'average_queue_time': {'key': 'averageQueueTime', 'type': 'long'}, + 'status_page': {'key': 'statusPage', 'type': 'str'}, + } + + def __init__(self, **kwargs) -> None: + super(TargetStatus, self).__init__(**kwargs) + self.id = None + self.current_availability = None + self.average_queue_time = None + self.status_page = None diff --git a/sdk/quantum/azure-quantum/azure/quantum/models/_paged_models.py b/sdk/quantum/azure-quantum/azure/quantum/models/_paged_models.py new file mode 100644 index 000000000000..eb9de1db34de --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_paged_models.py @@ -0,0 +1,40 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from msrest.paging import Paged + + +class JobDetailsPaged(Paged): + """ + A paging container for iterating over a list of :class:`JobDetails ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[JobDetails]'} + } + + def __init__(self, *args, **kwargs): + + super(JobDetailsPaged, self).__init__(*args, **kwargs) +class ProviderStatusPaged(Paged): + """ + A paging container for iterating over a list of :class:`ProviderStatus ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[ProviderStatus]'} + } + + def __init__(self, *args, **kwargs): + + super(ProviderStatusPaged, self).__init__(*args, **kwargs) diff --git a/sdk/quantum/azure-quantum/azure/quantum/models/_quantum_client_enums.py b/sdk/quantum/azure-quantum/azure/quantum/models/_quantum_client_enums.py new file mode 100644 index 000000000000..8106788169ff --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_quantum_client_enums.py @@ -0,0 +1,35 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from enum import Enum + + +class JobStatus(str, Enum): + + waiting = "Waiting" + executing = "Executing" + succeeded = "Succeeded" + failed = "Failed" + cancelled = "Cancelled" + + +class ProviderAvailability(str, Enum): + + available = "Available" + degraded = "Degraded" + unavailable = "Unavailable" + + +class TargetAvailability(str, Enum): + + available = "Available" + degraded = "Degraded" + unavailable = "Unavailable" diff --git a/sdk/quantum/azure-quantum/azure/quantum/operations/__init__.py b/sdk/quantum/azure-quantum/azure/quantum/operations/__init__.py new file mode 100644 index 000000000000..3cef83be62ef --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/operations/__init__.py @@ -0,0 +1,20 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +from ._jobs_operations import JobsOperations +from ._providers_operations import ProvidersOperations +from ._storage_operations import StorageOperations + +__all__ = [ + 'JobsOperations', + 'ProvidersOperations', + 'StorageOperations', +] diff --git a/sdk/quantum/azure-quantum/azure/quantum/operations/_jobs_operations.py b/sdk/quantum/azure-quantum/azure/quantum/operations/_jobs_operations.py new file mode 100644 index 000000000000..002ff139ff12 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/operations/_jobs_operations.py @@ -0,0 +1,279 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse +from msrestazure.azure_exceptions import CloudError + +from .. import models + + +class JobsOperations(object): + """JobsOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def list( + self, custom_headers=None, raw=False, **operation_config): + """List jobs. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of JobDetails + :rtype: + ~azure.quantum.models.JobDetailsPaged[~azure.quantum.models.JobDetails] + :raises: :class:`CloudError` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.list.metadata['url'] + 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 = {} + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + exp = CloudError(response) + exp.request_id = response.headers.get('x-ms-request-id') + raise exp + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.JobDetailsPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs'} + + def get( + self, job_id, custom_headers=None, raw=False, **operation_config): + """Get job by id. + + :param job_id: Id of the job. + :type job_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: JobDetails or ClientRawResponse if raw=true + :rtype: ~azure.quantum.models.JobDetails or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`RestErrorException` + """ + # Construct URL + url = self.get.metadata['url'] + 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 = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.RestErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JobDetails', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + get.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} + + def create( + self, job_id, job, custom_headers=None, raw=False, **operation_config): + """Create a job. + + :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 + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: JobDetails or ClientRawResponse if raw=true + :rtype: ~azure.quantum.models.JobDetails or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`RestErrorException` + """ + # Construct URL + url = self.create.metadata['url'] + 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 = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(job, 'JobDetails') + + # Construct and send request + request = self._client.put(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200, 201]: + raise models.RestErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('JobDetails', response) + if response.status_code == 201: + deserialized = self._deserialize('JobDetails', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + create.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} + + def cancel( + self, job_id, custom_headers=None, raw=False, **operation_config): + """Cancel a job. + + :param job_id: Id of the job. + :type job_id: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: None or ClientRawResponse if raw=true + :rtype: None or ~msrest.pipeline.ClientRawResponse + :raises: + :class:`RestErrorException` + """ + # Construct URL + url = self.cancel.metadata['url'] + 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 = {} + + # Construct headers + header_parameters = {} + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.delete(url, query_parameters, header_parameters) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [204]: + raise models.RestErrorException(self._deserialize, response) + + if raw: + client_raw_response = ClientRawResponse(None, response) + return client_raw_response + cancel.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/jobs/{jobId}'} diff --git a/sdk/quantum/azure-quantum/azure/quantum/operations/_providers_operations.py b/sdk/quantum/azure-quantum/azure/quantum/operations/_providers_operations.py new file mode 100644 index 000000000000..0d371a11deb6 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/operations/_providers_operations.py @@ -0,0 +1,103 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class ProvidersOperations(object): + """ProvidersOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def get_status( + self, custom_headers=None, raw=False, **operation_config): + """Get provider status. + + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: An iterator like instance of ProviderStatus + :rtype: + ~azure.quantum.models.ProviderStatusPaged[~azure.quantum.models.ProviderStatus] + :raises: + :class:`RestErrorException` + """ + def prepare_request(next_link=None): + if not next_link: + # Construct URL + url = self.get_status.metadata['url'] + 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 = {} + + else: + url = next_link + query_parameters = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct and send request + request = self._client.get(url, query_parameters, header_parameters) + return request + + def internal_paging(next_link=None): + request = prepare_request(next_link) + + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.RestErrorException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.ProviderStatusPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + get_status.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/providerStatus'} diff --git a/sdk/quantum/azure-quantum/azure/quantum/operations/_storage_operations.py b/sdk/quantum/azure-quantum/azure/quantum/operations/_storage_operations.py new file mode 100644 index 000000000000..f29a3a8d6e37 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/operations/_storage_operations.py @@ -0,0 +1,104 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class StorageOperations(object): + """StorageOperations operations. + + You should not instantiate directly this class, but create a Client instance that will create it for you and attach it as attribute. + + :param client: Client for service requests. + :param config: Configuration of service client. + :param serializer: An object model serializer. + :param deserializer: An object model deserializer. + """ + + models = models + + def __init__(self, client, config, serializer, deserializer): + + self._client = client + self._serialize = serializer + self._deserialize = deserializer + + self.config = config + + def sas_uri( + self, container_name, blob_name=None, custom_headers=None, raw=False, **operation_config): + """Gets a URL with SAS token for a container/blob in the storage account + associated with the workspace. The SAS URL can be used to upload job + input and/or download job output. + + :param container_name: The container name. + :type container_name: str + :param blob_name: The blob name. + :type blob_name: str + :param dict custom_headers: headers that will be added to the request + :param bool raw: returns the direct response alongside the + deserialized response + :param operation_config: :ref:`Operation configuration + overrides`. + :return: SasUriResponse or ClientRawResponse if raw=true + :rtype: ~azure.quantum.models.SasUriResponse or + ~msrest.pipeline.ClientRawResponse + :raises: + :class:`RestErrorException` + """ + blob_details = models.BlobDetails(container_name=container_name, blob_name=blob_name) + + # Construct URL + url = self.sas_uri.metadata['url'] + 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 = {} + + # Construct headers + header_parameters = {} + header_parameters['Accept'] = 'application/json' + header_parameters['Content-Type'] = 'application/json; charset=utf-8' + if self.config.generate_client_request_id: + header_parameters['x-ms-client-request-id'] = str(uuid.uuid1()) + if custom_headers: + header_parameters.update(custom_headers) + if self.config.accept_language is not None: + header_parameters['accept-language'] = self._serialize.header("self.config.accept_language", self.config.accept_language, 'str') + + # Construct body + body_content = self._serialize.body(blob_details, 'BlobDetails') + + # Construct and send request + request = self._client.post(url, query_parameters, header_parameters, body_content) + response = self._client.send(request, stream=False, **operation_config) + + if response.status_code not in [200]: + raise models.RestErrorException(self._deserialize, response) + + deserialized = None + if response.status_code == 200: + deserialized = self._deserialize('SasUriResponse', response) + + if raw: + client_raw_response = ClientRawResponse(deserialized, response) + return client_raw_response + + return deserialized + sas_uri.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/storage/sasUri'} diff --git a/sdk/quantum/azure-quantum/azure/quantum/version.py b/sdk/quantum/azure-quantum/azure/quantum/version.py new file mode 100644 index 000000000000..f85b9c124346 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/version.py @@ -0,0 +1,13 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +VERSION = "2019-11-04-preview" +