diff --git a/sdk/quantum/azure-quantum/CHANGELOG.md b/sdk/quantum/azure-quantum/CHANGELOG.md new file mode 100644 index 000000000000..578ed6acf479 --- /dev/null +++ b/sdk/quantum/azure-quantum/CHANGELOG.md @@ -0,0 +1,5 @@ +# Release History + +## 0.1.0 (1970-01-01) + +* Initial Release diff --git a/sdk/quantum/azure-quantum/MANIFEST.in b/sdk/quantum/azure-quantum/MANIFEST.in new file mode 100644 index 000000000000..3db884ff9656 --- /dev/null +++ b/sdk/quantum/azure-quantum/MANIFEST.in @@ -0,0 +1,5 @@ +include _meta.json +recursive-include tests *.py *.yaml +include *.md +include azure/__init__.py + diff --git a/sdk/quantum/azure-quantum/README.md b/sdk/quantum/azure-quantum/README.md new file mode 100644 index 000000000000..0c666545f555 --- /dev/null +++ b/sdk/quantum/azure-quantum/README.md @@ -0,0 +1,27 @@ +# Microsoft Azure SDK for Python + +This is the Microsoft Azure MyService Management Client Library. +This package has been tested with Python 2.7, 3.5, 3.6, 3.7 and 3.8. +For a more complete view of Azure libraries, see the [azure sdk python release](https://aka.ms/azsdk/python/all). + + +# Usage + + +To learn how to use this package, see the [quickstart guide](https://aka.ms/azsdk/python/mgmt) + + + +For docs and references, see [Python SDK References](https://docs.microsoft.com/python/api/overview/azure/) +Code samples for this package can be found at [MyService Management](https://docs.microsoft.com/samples/browse/?languages=python&term=Getting%20started%20-%20Managing&terms=Getting%20started%20-%20Managing) on docs.microsoft.com. +Additional code samples for different Azure services are available at [Samples Repo](https://aka.ms/azsdk/python/mgmt/samples) + + +# Provide Feedback + +If you encounter any bugs or have suggestions, please file an issue in the +[Issues](https://github.com/Azure/azure-sdk-for-python/issues) +section of the project. + + +![Impressions](https://azure-sdk-impressions.azurewebsites.net/api/impressions/azure-sdk-for-python%2Fazure-quantum%2FREADME.png) diff --git a/sdk/quantum/azure-quantum/_meta.json b/sdk/quantum/azure-quantum/_meta.json new file mode 100644 index 000000000000..126f25b37a5e --- /dev/null +++ b/sdk/quantum/azure-quantum/_meta.json @@ -0,0 +1,8 @@ +{ + "autorest": "V2", + "use": "@microsoft.azure/autorest.python@~4.0.71", + "commit": "4df4b843dd2692aadd416dd9ede5979610c08be6", + "repository_url": "https://github.com/Azure/azure-rest-api-specs", + "autorest_command": "autorest specification/quantum/data-plane/readme.md --keep-version-file --multiapi --no-async --python --python-mode=update --python-sdks-folder=/home/vsts/work/1/s/azure-sdk-for-python/sdk --use=@microsoft.azure/autorest.python@~4.0.71 --version=V2", + "readme": "specification/quantum/data-plane/readme.md" +} \ No newline at end of file diff --git a/sdk/quantum/azure-quantum/azure/__init__.py b/sdk/quantum/azure-quantum/azure/__init__.py new file mode 100644 index 000000000000..0260537a02bb --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/__init__.py @@ -0,0 +1 @@ +__path__ = __import__('pkgutil').extend_path(__path__, __name__) \ No newline at end of file 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..f264bf38c5a9 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/_quantum_client.py @@ -0,0 +1,69 @@ +# 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 .operations import QuotasOperations +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 + :ivar quotas: Quotas operations + :vartype quotas: azure.quantum.operations.QuotasOperations + + :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) + self.quotas = QuotasOperations( + 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..64c829650182 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/__init__.py @@ -0,0 +1,58 @@ +# 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 Quota + 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 Quota + from ._models import RestError, RestErrorException + from ._models import SasUriResponse + from ._models import TargetStatus +from ._paged_models import JobDetailsPaged +from ._paged_models import ProviderStatusPaged +from ._paged_models import QuotaPaged +from ._quantum_client_enums import ( + JobStatus, + ProviderAvailability, + TargetAvailability, + DimensionScope, + MeterPeriod, +) + +__all__ = [ + 'BlobDetails', + 'ErrorData', + 'JobDetails', + 'ProviderStatus', + 'Quota', + 'RestError', 'RestErrorException', + 'SasUriResponse', + 'TargetStatus', + 'JobDetailsPaged', + 'ProviderStatusPaged', + 'QuotaPaged', + 'JobStatus', + 'ProviderAvailability', + 'TargetAvailability', + 'DimensionScope', + 'MeterPeriod', +] 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..4d98b3ab0595 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_models.py @@ -0,0 +1,342 @@ +# 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 Quota(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', '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 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 calendar year. 'None' is used for concurrent quotas. + Possible values include: 'None', 'Monthly' + :type period: str or ~azure.quantum.models.MeterPeriod + """ + + _attribute_map = { + 'dimension': {'key': 'dimension', 'type': 'str'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'provider_id': {'key': 'providerId', 'type': 'str'}, + 'utilization': {'key': 'utilization', 'type': 'float'}, + 'holds': {'key': 'holds', 'type': 'float'}, + 'limit': {'key': 'limit', 'type': 'float'}, + 'period': {'key': 'period', 'type': 'str'}, + } + + def __init__(self, **kwargs): + super(Quota, self).__init__(**kwargs) + self.dimension = kwargs.get('dimension', None) + self.scope = kwargs.get('scope', None) + self.provider_id = kwargs.get('provider_id', None) + self.utilization = kwargs.get('utilization', None) + self.holds = kwargs.get('holds', None) + self.limit = kwargs.get('limit', None) + self.period = kwargs.get('period', 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..320f6c43c58b --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_models_py3.py @@ -0,0 +1,342 @@ +# 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 Quota(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', '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 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 calendar year. 'None' is used for concurrent quotas. + Possible values include: 'None', 'Monthly' + :type period: str or ~azure.quantum.models.MeterPeriod + """ + + _attribute_map = { + 'dimension': {'key': 'dimension', 'type': 'str'}, + 'scope': {'key': 'scope', 'type': 'str'}, + 'provider_id': {'key': 'providerId', 'type': 'str'}, + 'utilization': {'key': 'utilization', 'type': 'float'}, + 'holds': {'key': 'holds', 'type': 'float'}, + 'limit': {'key': 'limit', 'type': 'float'}, + 'period': {'key': 'period', 'type': 'str'}, + } + + def __init__(self, *, dimension: str=None, scope=None, provider_id: str=None, utilization: float=None, holds: float=None, limit: float=None, period=None, **kwargs) -> None: + super(Quota, self).__init__(**kwargs) + self.dimension = dimension + self.scope = scope + self.provider_id = provider_id + self.utilization = utilization + self.holds = holds + self.limit = limit + self.period = period + + +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..13d69b6112d7 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_paged_models.py @@ -0,0 +1,53 @@ +# 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) +class QuotaPaged(Paged): + """ + A paging container for iterating over a list of :class:`Quota ` object + """ + + _attribute_map = { + 'next_link': {'key': 'nextLink', 'type': 'str'}, + 'current_page': {'key': 'value', 'type': '[Quota]'} + } + + def __init__(self, *args, **kwargs): + + super(QuotaPaged, 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..38fa76b478b6 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/models/_quantum_client_enums.py @@ -0,0 +1,47 @@ +# 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" + + +class DimensionScope(str, Enum): + + workspace = "Workspace" + subscription = "Subscription" + + +class MeterPeriod(str, Enum): + + none = "None" + monthly = "Monthly" 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..ab89de00a206 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/operations/__init__.py @@ -0,0 +1,22 @@ +# 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 +from ._quotas_operations import QuotasOperations + +__all__ = [ + 'JobsOperations', + 'ProvidersOperations', + 'StorageOperations', + 'QuotasOperations', +] 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/_quotas_operations.py b/sdk/quantum/azure-quantum/azure/quantum/operations/_quotas_operations.py new file mode 100644 index 000000000000..ab171c3cc214 --- /dev/null +++ b/sdk/quantum/azure-quantum/azure/quantum/operations/_quotas_operations.py @@ -0,0 +1,102 @@ +# coding=utf-8 +# -------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +# +# Code generated by Microsoft (R) AutoRest Code Generator. +# Changes may cause incorrect behavior and will be lost if the code is +# regenerated. +# -------------------------------------------------------------------------- + +import uuid +from msrest.pipeline import ClientRawResponse + +from .. import models + + +class QuotasOperations(object): + """QuotasOperations 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 quotas for the given workspace. + + :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 Quota + :rtype: ~azure.quantum.models.QuotaPaged[~azure.quantum.models.Quota] + :raises: + :class:`RestErrorException` + """ + 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]: + raise models.RestErrorException(self._deserialize, response) + + return response + + # Deserialize response + header_dict = None + if raw: + header_dict = {} + deserialized = models.QuotaPaged(internal_paging, self._deserialize.dependencies, header_dict) + + return deserialized + list.metadata = {'url': '/v1.0/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.Quantum/workspaces/{workspaceName}/quotas'} 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" + diff --git a/sdk/quantum/azure-quantum/sdk_packaging.toml b/sdk/quantum/azure-quantum/sdk_packaging.toml new file mode 100644 index 000000000000..e126da2c6cef --- /dev/null +++ b/sdk/quantum/azure-quantum/sdk_packaging.toml @@ -0,0 +1,8 @@ +[packaging] +package_name = "azure-quantum" +package_nspkg = "azure-nspkg" +package_pprint_name = "MyService Management" +package_doc_id = "" +is_stable = false +is_arm = true +need_msrestazure = true diff --git a/sdk/quantum/azure-quantum/setup.cfg b/sdk/quantum/azure-quantum/setup.cfg new file mode 100644 index 000000000000..3c6e79cf31da --- /dev/null +++ b/sdk/quantum/azure-quantum/setup.cfg @@ -0,0 +1,2 @@ +[bdist_wheel] +universal=1 diff --git a/sdk/quantum/azure-quantum/setup.py b/sdk/quantum/azure-quantum/setup.py new file mode 100644 index 000000000000..ffaedeb6abaf --- /dev/null +++ b/sdk/quantum/azure-quantum/setup.py @@ -0,0 +1,90 @@ +#!/usr/bin/env python + +#------------------------------------------------------------------------- +# Copyright (c) Microsoft Corporation. All rights reserved. +# Licensed under the MIT License. See License.txt in the project root for +# license information. +#-------------------------------------------------------------------------- + +import re +import os.path +from io import open +from setuptools import find_packages, setup + +# Change the PACKAGE_NAME only to change folder and different name +PACKAGE_NAME = "azure-quantum" +PACKAGE_PPRINT_NAME = "MyService Management" + +# a-b-c => a/b/c +package_folder_path = PACKAGE_NAME.replace('-', '/') +# a-b-c => a.b.c +namespace_name = PACKAGE_NAME.replace('-', '.') + +# azure v0.x is not compatible with this package +# azure v0.x used to have a __version__ attribute (newer versions don't) +try: + import azure + try: + ver = azure.__version__ + raise Exception( + 'This package is incompatible with azure=={}. '.format(ver) + + 'Uninstall it with "pip uninstall azure".' + ) + except AttributeError: + pass +except ImportError: + pass + +# Version extraction inspired from 'requests' +with open(os.path.join(package_folder_path, 'version.py') + if os.path.exists(os.path.join(package_folder_path, 'version.py')) + else os.path.join(package_folder_path, '_version.py'), 'r') as fd: + version = re.search(r'^VERSION\s*=\s*[\'"]([^\'"]*)[\'"]', + fd.read(), re.MULTILINE).group(1) + +if not version: + raise RuntimeError('Cannot find version information') + +with open('README.md', encoding='utf-8') as f: + readme = f.read() +with open('CHANGELOG.md', encoding='utf-8') as f: + changelog = f.read() + +setup( + name=PACKAGE_NAME, + version=version, + description='Microsoft Azure {} Client Library for Python'.format(PACKAGE_PPRINT_NAME), + long_description=readme + '\n\n' + changelog, + long_description_content_type='text/markdown', + license='MIT License', + author='Microsoft Corporation', + author_email='azpysdkhelp@microsoft.com', + url='https://github.com/Azure/azure-sdk-for-python', + classifiers=[ + 'Development Status :: 4 - Beta', + 'Programming Language :: Python', + 'Programming Language :: Python :: 2', + 'Programming Language :: Python :: 2.7', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Programming Language :: Python :: 3.7', + 'Programming Language :: Python :: 3.8', + 'Programming Language :: Python :: 3.9', + 'License :: OSI Approved :: MIT License', + ], + zip_safe=False, + packages=find_packages(exclude=[ + 'tests', + # Exclude packages that will be covered by PEP420 or nspkg + 'azure', + ]), + install_requires=[ + 'msrest>=0.6.21', + 'msrestazure>=0.4.32,<2.0.0', + 'azure-common~=1.1', + ], + extras_require={ + ":python_version<'3.0'": ['azure-nspkg'], + } +) diff --git a/sdk/quantum/ci.yml b/sdk/quantum/ci.yml new file mode 100644 index 000000000000..f67ff9e6a1e3 --- /dev/null +++ b/sdk/quantum/ci.yml @@ -0,0 +1,35 @@ +# DO NOT EDIT THIS FILE +# This file is generated automatically and any changes will be lost. + +trigger: + branches: + include: + - master + - main + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/quantum/ + +pr: + branches: + include: + - master + - main + - feature/* + - hotfix/* + - release/* + - restapi* + paths: + include: + - sdk/quantum/ + +extends: + template: ../../eng/pipelines/templates/stages/archetype-sdk-client.yml + parameters: + ServiceDirectory: quantum + Artifacts: + - name: azure-mgmt-quantum + safeName: azuremgmtquantum