Skip to content

Commit 397cff7

Browse files
author
SDKAuto
committed
CodeGen from PR 31747 in Azure/azure-rest-api-specs
Merge 452a61542c6594ac36fc6dfd629f1ba7f1b0200c into 5432f420df6106c439199a36c453472e4bfe8894
1 parent 4d9bf58 commit 397cff7

34 files changed

+9160
-1
lines changed
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
# Release History
2+
3+
## 1.0.0b1 (1970-01-01)
4+
5+
- Initial version

sdk/quantum/azure-quantum/LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
Copyright (c) Microsoft Corporation.
2+
3+
MIT License
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in all
13+
copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED *AS IS*, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21+
SOFTWARE.
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
include *.md
2+
include LICENSE
3+
include azure/quantum/py.typed
4+
recursive-include tests *.py
5+
recursive-include samples *.py *.md
6+
include azure/__init__.py
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
2+
3+
# Azure Quantum client library for Python
4+
<!-- write necessary description of service -->
5+
6+
## Getting started
7+
8+
### Install the package
9+
10+
```bash
11+
python -m pip install azure-quantum
12+
```
13+
14+
#### Prequisites
15+
16+
- Python 3.8 or later is required to use this package.
17+
- You need an [Azure subscription][azure_sub] to use this package.
18+
- An existing Azure Quantum instance.
19+
20+
## Contributing
21+
22+
This project welcomes contributions and suggestions. Most contributions require
23+
you to agree to a Contributor License Agreement (CLA) declaring that you have
24+
the right to, and actually do, grant us the rights to use your contribution.
25+
For details, visit https://cla.microsoft.com.
26+
27+
When you submit a pull request, a CLA-bot will automatically determine whether
28+
you need to provide a CLA and decorate the PR appropriately (e.g., label,
29+
comment). Simply follow the instructions provided by the bot. You will only
30+
need to do this once across all repos using our CLA.
31+
32+
This project has adopted the
33+
[Microsoft Open Source Code of Conduct][code_of_conduct]. For more information,
34+
see the Code of Conduct FAQ or contact [email protected] with any
35+
additional questions or comments.
36+
37+
<!-- LINKS -->
38+
[code_of_conduct]: https://opensource.microsoft.com/codeofconduct/
39+
[authenticate_with_token]: https://docs.microsoft.com/azure/cognitive-services/authentication?tabs=powershell#authenticate-with-an-authentication-token
40+
[azure_identity_credentials]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#credentials
41+
[azure_identity_pip]: https://pypi.org/project/azure-identity/
42+
[default_azure_credential]: https://github.com/Azure/azure-sdk-for-python/tree/main/sdk/identity/azure-identity#defaultazurecredential
43+
[pip]: https://pypi.org/project/pip/
44+
[azure_sub]: https://azure.microsoft.com/free/
45+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"commit": "5e37dde8684e842a6ed783315823c75ec9ebbb35",
3+
"repository_url": "https://github.com/Azure/azure-rest-api-specs",
4+
"typespec_src": "specification/quantum/Quantum.Workspace",
5+
"@azure-tools/typespec-python": "0.38.4"
6+
}
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
{
2+
"CrossLanguagePackageId": "Quantum.Workspace.Services",
3+
"CrossLanguageDefinitionId": {
4+
"azure.quantum.models.BlobDetails": "BlobDetails",
5+
"azure.quantum.models.CostEstimate": "CostEstimate",
6+
"azure.quantum.models.InnerError": "Azure.Core.Foundations.InnerError",
7+
"azure.quantum.models.ItemDetails": "ItemDetails",
8+
"azure.quantum.models.JobDetails": "JobDetails",
9+
"azure.quantum.models.JsonPatchObject": "JsonPatchObject",
10+
"azure.quantum.models.ProviderStatus": "ProviderStatus",
11+
"azure.quantum.models.QuantumComputingData": "QuantumComputingData",
12+
"azure.quantum.models.Quota": "Quota",
13+
"azure.quantum.models.SasUriResponse": "SasUriResponse",
14+
"azure.quantum.models.SessionDetails": "SessionDetails",
15+
"azure.quantum.models.TargetStatus": "TargetStatus",
16+
"azure.quantum.models.UsageEvent": "UsageEvent",
17+
"azure.quantum.models.WorkspaceItemError": "Errors.WorkspaceItemError",
18+
"azure.quantum.models.ItemType": "ItemType",
19+
"azure.quantum.models.SessionJobFailurePolicy": "SessionJobFailurePolicy",
20+
"azure.quantum.models.SessionStatus": "SessionStatus",
21+
"azure.quantum.models.JobType": "JobType",
22+
"azure.quantum.models.JobStatus": "JobStatus",
23+
"azure.quantum.models.JsonPatchOperation": "JsonPatchOperation",
24+
"azure.quantum.models.ProviderAvailability": "ProviderAvailability",
25+
"azure.quantum.models.TargetAvailability": "TargetAvailability",
26+
"azure.quantum.models.DimensionScope": "DimensionScope",
27+
"azure.quantum.models.MeterPeriod": "MeterPeriod",
28+
"azure.quantum.ServicesClient.jobs.create": "Quantum.Workspace.Operations.Jobs.create",
29+
"azure.quantum.ServicesClient.jobs.update": "Quantum.Workspace.Operations.Jobs.update",
30+
"azure.quantum.ServicesClient.jobs.cancel": "Quantum.Workspace.Operations.Jobs.cancel",
31+
"azure.quantum.ServicesClient.jobs.get": "Quantum.Workspace.Operations.Jobs.get",
32+
"azure.quantum.ServicesClient.jobs.list": "Quantum.Workspace.Operations.Jobs.list",
33+
"azure.quantum.ServicesClient.sessions.open": "Quantum.Workspace.Operations.Sessions.open",
34+
"azure.quantum.ServicesClient.sessions.close": "Quantum.Workspace.Operations.Sessions.close",
35+
"azure.quantum.ServicesClient.sessions.get": "Quantum.Workspace.Operations.Sessions.get",
36+
"azure.quantum.ServicesClient.sessions.list": "Quantum.Workspace.Operations.Sessions.list",
37+
"azure.quantum.ServicesClient.sessions.jobs_list": "Quantum.Workspace.Operations.Sessions.jobsList",
38+
"azure.quantum.ServicesClient.providers.list": "Quantum.Workspace.Operations.Providers.list",
39+
"azure.quantum.ServicesClient.storage.get_sas_uri": "Quantum.Workspace.Operations.Storage.getSasUri",
40+
"azure.quantum.ServicesClient.quotas.list": "Quantum.Workspace.Operations.Quotas.list",
41+
"azure.quantum.ServicesClient.top_level_items.list": "Quantum.Workspace.Operations.TopLevelItems.list"
42+
}
43+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
__path__ = __import__("pkgutil").extend_path(__path__, __name__) # type: ignore
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
# pylint: disable=wrong-import-position
9+
10+
from typing import TYPE_CHECKING
11+
12+
if TYPE_CHECKING:
13+
from ._patch import * # pylint: disable=unused-wildcard-import
14+
15+
from ._client import ServicesClient # type: ignore
16+
from ._version import VERSION
17+
18+
__version__ = VERSION
19+
20+
try:
21+
from ._patch import __all__ as _patch_all
22+
from ._patch import *
23+
except ImportError:
24+
_patch_all = []
25+
from ._patch import patch_sdk as _patch_sdk
26+
27+
__all__ = [
28+
"ServicesClient",
29+
]
30+
__all__.extend([p for p in _patch_all if p not in __all__]) # pyright: ignore
31+
32+
_patch_sdk()
Lines changed: 141 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,141 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from copy import deepcopy
10+
from typing import Any, TYPE_CHECKING, Union
11+
from typing_extensions import Self
12+
13+
from azure.core import PipelineClient
14+
from azure.core.credentials import AzureKeyCredential
15+
from azure.core.pipeline import policies
16+
from azure.core.rest import HttpRequest, HttpResponse
17+
18+
from ._configuration import ServicesClientConfiguration
19+
from ._serialization import Deserializer, Serializer
20+
from .operations import (
21+
JobsOperations,
22+
ProvidersOperations,
23+
QuotasOperations,
24+
SessionsOperations,
25+
StorageOperations,
26+
TopLevelItemsOperations,
27+
)
28+
29+
if TYPE_CHECKING:
30+
from azure.core.credentials import TokenCredential
31+
32+
33+
class ServicesClient:
34+
"""Azure Quantum Workspace Services.
35+
36+
:ivar jobs: JobsOperations operations
37+
:vartype jobs: azure.quantum.operations.JobsOperations
38+
:ivar sessions: SessionsOperations operations
39+
:vartype sessions: azure.quantum.operations.SessionsOperations
40+
:ivar providers: ProvidersOperations operations
41+
:vartype providers: azure.quantum.operations.ProvidersOperations
42+
:ivar storage: StorageOperations operations
43+
:vartype storage: azure.quantum.operations.StorageOperations
44+
:ivar quotas: QuotasOperations operations
45+
:vartype quotas: azure.quantum.operations.QuotasOperations
46+
:ivar top_level_items: TopLevelItemsOperations operations
47+
:vartype top_level_items: azure.quantum.operations.TopLevelItemsOperations
48+
:param region: The Azure region where the Azure Quantum Workspace is located. Required.
49+
:type region: str
50+
:param credential: Credential used to authenticate requests to the service. Is either a token
51+
credential type or a key credential type. Required.
52+
:type credential: ~azure.core.credentials.TokenCredential or
53+
~azure.core.credentials.AzureKeyCredential
54+
:keyword service_base_url: The Azure Quantum service base url. Default value is
55+
"quantum.azure.com".
56+
:paramtype service_base_url: str
57+
:keyword api_version: The API version to use for this operation. Default value is
58+
"2024-10-01-preview". Note that overriding this default value may result in unsupported
59+
behavior.
60+
:paramtype api_version: str
61+
"""
62+
63+
def __init__(
64+
self,
65+
region: str,
66+
credential: Union["TokenCredential", AzureKeyCredential],
67+
*,
68+
service_base_url: str = "quantum.azure.com",
69+
**kwargs: Any
70+
) -> None:
71+
_endpoint = "https://{region}.{serviceBaseUrl}"
72+
self._config = ServicesClientConfiguration(
73+
region=region, credential=credential, service_base_url=service_base_url, **kwargs
74+
)
75+
_policies = kwargs.pop("policies", None)
76+
if _policies is None:
77+
_policies = [
78+
policies.RequestIdPolicy(**kwargs),
79+
self._config.headers_policy,
80+
self._config.user_agent_policy,
81+
self._config.proxy_policy,
82+
policies.ContentDecodePolicy(**kwargs),
83+
self._config.redirect_policy,
84+
self._config.retry_policy,
85+
self._config.authentication_policy,
86+
self._config.custom_hook_policy,
87+
self._config.logging_policy,
88+
policies.DistributedTracingPolicy(**kwargs),
89+
policies.SensitiveHeaderCleanupPolicy(**kwargs) if self._config.redirect_policy else None,
90+
self._config.http_logging_policy,
91+
]
92+
self._client: PipelineClient = PipelineClient(base_url=_endpoint, policies=_policies, **kwargs)
93+
94+
self._serialize = Serializer()
95+
self._deserialize = Deserializer()
96+
self._serialize.client_side_validation = False
97+
self.jobs = JobsOperations(self._client, self._config, self._serialize, self._deserialize)
98+
self.sessions = SessionsOperations(self._client, self._config, self._serialize, self._deserialize)
99+
self.providers = ProvidersOperations(self._client, self._config, self._serialize, self._deserialize)
100+
self.storage = StorageOperations(self._client, self._config, self._serialize, self._deserialize)
101+
self.quotas = QuotasOperations(self._client, self._config, self._serialize, self._deserialize)
102+
self.top_level_items = TopLevelItemsOperations(self._client, self._config, self._serialize, self._deserialize)
103+
104+
def send_request(self, request: HttpRequest, *, stream: bool = False, **kwargs: Any) -> HttpResponse:
105+
"""Runs the network request through the client's chained policies.
106+
107+
>>> from azure.core.rest import HttpRequest
108+
>>> request = HttpRequest("GET", "https://www.example.org/")
109+
<HttpRequest [GET], url: 'https://www.example.org/'>
110+
>>> response = client.send_request(request)
111+
<HttpResponse: 200 OK>
112+
113+
For more information on this code flow, see https://aka.ms/azsdk/dpcodegen/python/send_request
114+
115+
:param request: The network request you want to make. Required.
116+
:type request: ~azure.core.rest.HttpRequest
117+
:keyword bool stream: Whether the response payload will be streamed. Defaults to False.
118+
:return: The response of your network call. Does not do error handling on your response.
119+
:rtype: ~azure.core.rest.HttpResponse
120+
"""
121+
122+
request_copy = deepcopy(request)
123+
path_format_arguments = {
124+
"region": self._serialize.url("self._config.region", self._config.region, "str"),
125+
"serviceBaseUrl": self._serialize.url(
126+
"self._config.service_base_url", self._config.service_base_url, "str"
127+
),
128+
}
129+
130+
request_copy.url = self._client.format_url(request_copy.url, **path_format_arguments)
131+
return self._client.send_request(request_copy, stream=stream, **kwargs) # type: ignore
132+
133+
def close(self) -> None:
134+
self._client.close()
135+
136+
def __enter__(self) -> Self:
137+
self._client.__enter__()
138+
return self
139+
140+
def __exit__(self, *exc_details: Any) -> None:
141+
self._client.__exit__(*exc_details)
Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# coding=utf-8
2+
# --------------------------------------------------------------------------
3+
# Copyright (c) Microsoft Corporation. All rights reserved.
4+
# Licensed under the MIT License. See License.txt in the project root for license information.
5+
# Code generated by Microsoft (R) Python Code Generator.
6+
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
7+
# --------------------------------------------------------------------------
8+
9+
from typing import Any, TYPE_CHECKING, Union
10+
11+
from azure.core.credentials import AzureKeyCredential
12+
from azure.core.pipeline import policies
13+
14+
from ._version import VERSION
15+
16+
if TYPE_CHECKING:
17+
from azure.core.credentials import TokenCredential
18+
19+
20+
class ServicesClientConfiguration: # pylint: disable=too-many-instance-attributes
21+
"""Configuration for ServicesClient.
22+
23+
Note that all parameters used to create this instance are saved as instance
24+
attributes.
25+
26+
:param region: The Azure region where the Azure Quantum Workspace is located. Required.
27+
:type region: str
28+
:param credential: Credential used to authenticate requests to the service. Is either a token
29+
credential type or a key credential type. Required.
30+
:type credential: ~azure.core.credentials.TokenCredential or
31+
~azure.core.credentials.AzureKeyCredential
32+
:param service_base_url: The Azure Quantum service base url. Default value is
33+
"quantum.azure.com".
34+
:type service_base_url: str
35+
:keyword api_version: The API version to use for this operation. Default value is
36+
"2024-10-01-preview". Note that overriding this default value may result in unsupported
37+
behavior.
38+
:paramtype api_version: str
39+
"""
40+
41+
def __init__(
42+
self,
43+
region: str,
44+
credential: Union["TokenCredential", AzureKeyCredential],
45+
service_base_url: str = "quantum.azure.com",
46+
**kwargs: Any,
47+
) -> None:
48+
api_version: str = kwargs.pop("api_version", "2024-10-01-preview")
49+
50+
if region is None:
51+
raise ValueError("Parameter 'region' must not be None.")
52+
if credential is None:
53+
raise ValueError("Parameter 'credential' must not be None.")
54+
55+
self.region = region
56+
self.credential = credential
57+
self.service_base_url = service_base_url
58+
self.api_version = api_version
59+
self.credential_scopes = kwargs.pop("credential_scopes", ["https://quantum.microsoft.com/.default"])
60+
kwargs.setdefault("sdk_moniker", "quantum/{}".format(VERSION))
61+
self.polling_interval = kwargs.get("polling_interval", 30)
62+
self._configure(**kwargs)
63+
64+
def _infer_policy(self, **kwargs):
65+
if hasattr(self.credential, "get_token"):
66+
return policies.BearerTokenCredentialPolicy(self.credential, *self.credential_scopes, **kwargs)
67+
if isinstance(self.credential, AzureKeyCredential):
68+
return policies.AzureKeyCredentialPolicy(self.credential, "x-ms-quantum-api-key", **kwargs)
69+
raise TypeError(f"Unsupported credential: {self.credential}")
70+
71+
def _configure(self, **kwargs: Any) -> None:
72+
self.user_agent_policy = kwargs.get("user_agent_policy") or policies.UserAgentPolicy(**kwargs)
73+
self.headers_policy = kwargs.get("headers_policy") or policies.HeadersPolicy(**kwargs)
74+
self.proxy_policy = kwargs.get("proxy_policy") or policies.ProxyPolicy(**kwargs)
75+
self.logging_policy = kwargs.get("logging_policy") or policies.NetworkTraceLoggingPolicy(**kwargs)
76+
self.http_logging_policy = kwargs.get("http_logging_policy") or policies.HttpLoggingPolicy(**kwargs)
77+
self.custom_hook_policy = kwargs.get("custom_hook_policy") or policies.CustomHookPolicy(**kwargs)
78+
self.redirect_policy = kwargs.get("redirect_policy") or policies.RedirectPolicy(**kwargs)
79+
self.retry_policy = kwargs.get("retry_policy") or policies.RetryPolicy(**kwargs)
80+
self.authentication_policy = kwargs.get("authentication_policy")
81+
if self.credential and not self.authentication_policy:
82+
self.authentication_policy = self._infer_policy(**kwargs)

0 commit comments

Comments
 (0)