azure-quantum 3.5.1.dev1__py3-none-any.whl → 3.6.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (39) hide show
  1. azure/quantum/_client/__init__.py +2 -2
  2. azure/quantum/_client/_client.py +18 -57
  3. azure/quantum/_client/_configuration.py +13 -22
  4. azure/quantum/_client/_patch.py +7 -6
  5. azure/quantum/_client/_utils/__init__.py +6 -0
  6. azure/quantum/_client/{_model_base.py → _utils/model_base.py} +210 -45
  7. azure/quantum/_client/{_serialization.py → _utils/serialization.py} +74 -151
  8. azure/quantum/_client/_validation.py +66 -0
  9. azure/quantum/_client/_version.py +1 -1
  10. azure/quantum/_client/aio/__init__.py +29 -0
  11. azure/quantum/_client/aio/_client.py +110 -0
  12. azure/quantum/_client/aio/_configuration.py +75 -0
  13. azure/quantum/_client/aio/_patch.py +21 -0
  14. azure/quantum/_client/aio/operations/__init__.py +25 -0
  15. azure/quantum/_client/aio/operations/_operations.py +1988 -0
  16. azure/quantum/_client/aio/operations/_patch.py +21 -0
  17. azure/quantum/_client/models/__init__.py +8 -4
  18. azure/quantum/_client/models/_enums.py +28 -23
  19. azure/quantum/_client/models/_models.py +198 -106
  20. azure/quantum/_client/models/_patch.py +7 -6
  21. azure/quantum/_client/operations/__init__.py +2 -12
  22. azure/quantum/_client/operations/_operations.py +900 -715
  23. azure/quantum/_client/operations/_patch.py +7 -6
  24. azure/quantum/_constants.py +6 -1
  25. azure/quantum/_mgmt_client.py +19 -9
  26. azure/quantum/_workspace_connection_params.py +27 -2
  27. azure/quantum/job/base_job.py +8 -0
  28. azure/quantum/job/job.py +13 -4
  29. azure/quantum/job/session.py +11 -0
  30. azure/quantum/target/rigetti/target.py +1 -6
  31. azure/quantum/target/target.py +5 -1
  32. azure/quantum/target/target_factory.py +14 -7
  33. azure/quantum/version.py +1 -1
  34. azure/quantum/workspace.py +35 -31
  35. {azure_quantum-3.5.1.dev1.dist-info → azure_quantum-3.6.1.dist-info}/METADATA +2 -6
  36. azure_quantum-3.6.1.dist-info/RECORD +74 -0
  37. {azure_quantum-3.5.1.dev1.dist-info → azure_quantum-3.6.1.dist-info}/WHEEL +1 -1
  38. azure_quantum-3.5.1.dev1.dist-info/RECORD +0 -65
  39. {azure_quantum-3.5.1.dev1.dist-info → azure_quantum-3.6.1.dist-info}/top_level.txt +0 -0
@@ -0,0 +1,1988 @@
1
+ # pylint: disable=too-many-lines
2
+ # coding=utf-8
3
+ # --------------------------------------------------------------------------
4
+ # Copyright (c) Microsoft Corporation. All rights reserved.
5
+ # Licensed under the MIT License. See License.txt in the project root for license information.
6
+ # Code generated by Microsoft (R) Python Code Generator.
7
+ # Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
+ # --------------------------------------------------------------------------
9
+ from collections.abc import MutableMapping
10
+ from io import IOBase
11
+ import json
12
+ from typing import Any, Callable, IO, Optional, TypeVar, Union, overload
13
+ import urllib.parse
14
+
15
+ from azure.core import AsyncPipelineClient
16
+ from azure.core.async_paging import AsyncItemPaged, AsyncList
17
+ from azure.core.exceptions import (
18
+ ClientAuthenticationError,
19
+ HttpResponseError,
20
+ ResourceExistsError,
21
+ ResourceNotFoundError,
22
+ ResourceNotModifiedError,
23
+ StreamClosedError,
24
+ StreamConsumedError,
25
+ map_error,
26
+ )
27
+ from azure.core.pipeline import PipelineResponse
28
+ from azure.core.rest import AsyncHttpResponse, HttpRequest
29
+ from azure.core.tracing.decorator import distributed_trace
30
+ from azure.core.tracing.decorator_async import distributed_trace_async
31
+ from azure.core.utils import case_insensitive_dict
32
+
33
+ from ... import models as _models
34
+ from ..._utils.model_base import SdkJSONEncoder, _deserialize
35
+ from ..._utils.serialization import Deserializer, Serializer
36
+ from ..._validation import api_version_validation
37
+ from ...operations._operations import (
38
+ build_services_jobs_cancel_request,
39
+ build_services_jobs_create_request,
40
+ build_services_jobs_delete_request,
41
+ build_services_jobs_get_request,
42
+ build_services_jobs_list_request,
43
+ build_services_jobs_update_request,
44
+ build_services_providers_list_request,
45
+ build_services_quotas_list_request,
46
+ build_services_sessions_close_request,
47
+ build_services_sessions_get_request,
48
+ build_services_sessions_jobs_list_request,
49
+ build_services_sessions_listv2_request,
50
+ build_services_sessions_open_request,
51
+ build_services_storage_get_sas_uri_request,
52
+ build_services_top_level_items_listv2_request,
53
+ )
54
+ from .._configuration import WorkspaceClientConfiguration
55
+
56
+ T = TypeVar("T")
57
+ ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, dict[str, Any]], Any]]
58
+ JSON = MutableMapping[str, Any]
59
+
60
+
61
+ class ServicesOperations:
62
+ """
63
+ .. warning::
64
+ **DO NOT** instantiate this class directly.
65
+
66
+ Instead, you should access the following operations through
67
+ :class:`~azure.quantum.aio.WorkspaceClient`'s
68
+ :attr:`services` attribute.
69
+ """
70
+
71
+ def __init__(self, *args, **kwargs) -> None:
72
+ input_args = list(args)
73
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
74
+ self._config: WorkspaceClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
75
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
76
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
77
+
78
+ self.top_level_items = ServicesTopLevelItemsOperations(
79
+ self._client, self._config, self._serialize, self._deserialize
80
+ )
81
+ self.jobs = ServicesJobsOperations(self._client, self._config, self._serialize, self._deserialize)
82
+ self.providers = ServicesProvidersOperations(self._client, self._config, self._serialize, self._deserialize)
83
+ self.quotas = ServicesQuotasOperations(self._client, self._config, self._serialize, self._deserialize)
84
+ self.sessions = ServicesSessionsOperations(self._client, self._config, self._serialize, self._deserialize)
85
+ self.storage = ServicesStorageOperations(self._client, self._config, self._serialize, self._deserialize)
86
+
87
+
88
+ class ServicesTopLevelItemsOperations:
89
+ """
90
+ .. warning::
91
+ **DO NOT** instantiate this class directly.
92
+
93
+ Instead, you should access the following operations through
94
+ :class:`~azure.quantum.aio.WorkspaceClient`'s
95
+ :attr:`top_level_items` attribute.
96
+ """
97
+
98
+ def __init__(self, *args, **kwargs) -> None:
99
+ input_args = list(args)
100
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
101
+ self._config: WorkspaceClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
102
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
103
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
104
+
105
+ @distributed_trace
106
+ @api_version_validation(
107
+ method_added_on="2024-10-01-preview",
108
+ params_added_on={
109
+ "2024-10-01-preview": [
110
+ "api_version",
111
+ "subscription_id",
112
+ "resource_group_name",
113
+ "workspace_name",
114
+ "filter",
115
+ "skip",
116
+ "top",
117
+ "orderby",
118
+ "accept",
119
+ ]
120
+ },
121
+ api_versions_list=["2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
122
+ )
123
+ def listv2(
124
+ self,
125
+ subscription_id: str,
126
+ resource_group_name: str,
127
+ workspace_name: str,
128
+ *,
129
+ filter: Optional[str] = None,
130
+ skip: Optional[int] = None,
131
+ top: Optional[int] = None,
132
+ orderby: Optional[str] = None,
133
+ **kwargs: Any
134
+ ) -> AsyncItemPaged["_models.ItemDetails"]:
135
+ """List top-level items.
136
+
137
+ :param subscription_id: The Azure subscription ID. Required.
138
+ :type subscription_id: str
139
+ :param resource_group_name: Name of the Azure resource group. Required.
140
+ :type resource_group_name: str
141
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
142
+ :type workspace_name: str
143
+ :keyword filter: Filter the result list using the given expression. Default value is None.
144
+ :paramtype filter: str
145
+ :keyword skip: The number of result items to skip. Default value is None.
146
+ :paramtype skip: int
147
+ :keyword top: The number of jobs taken. Default value is None.
148
+ :paramtype top: int
149
+ :keyword orderby: The order of returned items. Default value is None.
150
+ :paramtype orderby: str
151
+ :return: An iterator like instance of ItemDetails
152
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.ItemDetails]
153
+ :raises ~azure.core.exceptions.HttpResponseError:
154
+ """
155
+ _headers = kwargs.pop("headers", {}) or {}
156
+ _params = kwargs.pop("params", {}) or {}
157
+
158
+ cls: ClsType[list[_models.ItemDetails]] = kwargs.pop("cls", None)
159
+
160
+ error_map: MutableMapping = {
161
+ 401: ClientAuthenticationError,
162
+ 404: ResourceNotFoundError,
163
+ 409: ResourceExistsError,
164
+ 304: ResourceNotModifiedError,
165
+ }
166
+ error_map.update(kwargs.pop("error_map", {}) or {})
167
+
168
+ def prepare_request(next_link=None):
169
+ if not next_link:
170
+
171
+ _request = build_services_top_level_items_listv2_request(
172
+ subscription_id=subscription_id,
173
+ resource_group_name=resource_group_name,
174
+ workspace_name=workspace_name,
175
+ filter=filter,
176
+ skip=skip,
177
+ top=top,
178
+ orderby=orderby,
179
+ api_version=self._config.api_version,
180
+ headers=_headers,
181
+ params=_params,
182
+ )
183
+ path_format_arguments = {
184
+ "endpoint": self._serialize.url(
185
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
186
+ ),
187
+ }
188
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
189
+
190
+ else:
191
+ # make call to next link with the client's api-version
192
+ _parsed_next_link = urllib.parse.urlparse(next_link)
193
+ _next_request_params = case_insensitive_dict(
194
+ {
195
+ key: [urllib.parse.quote(v) for v in value]
196
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
197
+ }
198
+ )
199
+ _next_request_params["api-version"] = self._config.api_version
200
+ _request = HttpRequest(
201
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
202
+ )
203
+ path_format_arguments = {
204
+ "endpoint": self._serialize.url(
205
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
206
+ ),
207
+ }
208
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
209
+
210
+ return _request
211
+
212
+ async def extract_data(pipeline_response):
213
+ deserialized = pipeline_response.http_response.json()
214
+ list_of_elem = _deserialize(list[_models.ItemDetails], deserialized.get("value", []))
215
+ if cls:
216
+ list_of_elem = cls(list_of_elem) # type: ignore
217
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
218
+
219
+ async def get_next(next_link=None):
220
+ _request = prepare_request(next_link)
221
+
222
+ _stream = False
223
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
224
+ _request, stream=_stream, **kwargs
225
+ )
226
+ response = pipeline_response.http_response
227
+
228
+ if response.status_code not in [200]:
229
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
230
+ raise HttpResponseError(response=response)
231
+
232
+ return pipeline_response
233
+
234
+ return AsyncItemPaged(get_next, extract_data)
235
+
236
+
237
+ class ServicesJobsOperations:
238
+ """
239
+ .. warning::
240
+ **DO NOT** instantiate this class directly.
241
+
242
+ Instead, you should access the following operations through
243
+ :class:`~azure.quantum.aio.WorkspaceClient`'s
244
+ :attr:`jobs` attribute.
245
+ """
246
+
247
+ def __init__(self, *args, **kwargs) -> None:
248
+ input_args = list(args)
249
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
250
+ self._config: WorkspaceClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
251
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
252
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
253
+
254
+ @overload
255
+ async def create(
256
+ self,
257
+ subscription_id: str,
258
+ resource_group_name: str,
259
+ workspace_name: str,
260
+ job_id: str,
261
+ resource: _models.JobDetails,
262
+ *,
263
+ content_type: str = "application/json",
264
+ **kwargs: Any
265
+ ) -> _models.JobDetails:
266
+ """Create a new job.
267
+
268
+ :param subscription_id: The Azure subscription ID. Required.
269
+ :type subscription_id: str
270
+ :param resource_group_name: Name of the Azure resource group. Required.
271
+ :type resource_group_name: str
272
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
273
+ :type workspace_name: str
274
+ :param job_id: Id of the job. Required.
275
+ :type job_id: str
276
+ :param resource: The resource instance. Required.
277
+ :type resource: ~azure.quantum.models.JobDetails
278
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
279
+ Default value is "application/json".
280
+ :paramtype content_type: str
281
+ :return: JobDetails. The JobDetails is compatible with MutableMapping
282
+ :rtype: ~azure.quantum.models.JobDetails
283
+ :raises ~azure.core.exceptions.HttpResponseError:
284
+ """
285
+
286
+ @overload
287
+ async def create(
288
+ self,
289
+ subscription_id: str,
290
+ resource_group_name: str,
291
+ workspace_name: str,
292
+ job_id: str,
293
+ resource: JSON,
294
+ *,
295
+ content_type: str = "application/json",
296
+ **kwargs: Any
297
+ ) -> _models.JobDetails:
298
+ """Create a new job.
299
+
300
+ :param subscription_id: The Azure subscription ID. Required.
301
+ :type subscription_id: str
302
+ :param resource_group_name: Name of the Azure resource group. Required.
303
+ :type resource_group_name: str
304
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
305
+ :type workspace_name: str
306
+ :param job_id: Id of the job. Required.
307
+ :type job_id: str
308
+ :param resource: The resource instance. Required.
309
+ :type resource: JSON
310
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
311
+ Default value is "application/json".
312
+ :paramtype content_type: str
313
+ :return: JobDetails. The JobDetails is compatible with MutableMapping
314
+ :rtype: ~azure.quantum.models.JobDetails
315
+ :raises ~azure.core.exceptions.HttpResponseError:
316
+ """
317
+
318
+ @overload
319
+ async def create(
320
+ self,
321
+ subscription_id: str,
322
+ resource_group_name: str,
323
+ workspace_name: str,
324
+ job_id: str,
325
+ resource: IO[bytes],
326
+ *,
327
+ content_type: str = "application/json",
328
+ **kwargs: Any
329
+ ) -> _models.JobDetails:
330
+ """Create a new job.
331
+
332
+ :param subscription_id: The Azure subscription ID. Required.
333
+ :type subscription_id: str
334
+ :param resource_group_name: Name of the Azure resource group. Required.
335
+ :type resource_group_name: str
336
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
337
+ :type workspace_name: str
338
+ :param job_id: Id of the job. Required.
339
+ :type job_id: str
340
+ :param resource: The resource instance. Required.
341
+ :type resource: IO[bytes]
342
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
343
+ Default value is "application/json".
344
+ :paramtype content_type: str
345
+ :return: JobDetails. The JobDetails is compatible with MutableMapping
346
+ :rtype: ~azure.quantum.models.JobDetails
347
+ :raises ~azure.core.exceptions.HttpResponseError:
348
+ """
349
+
350
+ @distributed_trace_async
351
+ async def create(
352
+ self,
353
+ subscription_id: str,
354
+ resource_group_name: str,
355
+ workspace_name: str,
356
+ job_id: str,
357
+ resource: Union[_models.JobDetails, JSON, IO[bytes]],
358
+ **kwargs: Any
359
+ ) -> _models.JobDetails:
360
+ """Create a new job.
361
+
362
+ :param subscription_id: The Azure subscription ID. Required.
363
+ :type subscription_id: str
364
+ :param resource_group_name: Name of the Azure resource group. Required.
365
+ :type resource_group_name: str
366
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
367
+ :type workspace_name: str
368
+ :param job_id: Id of the job. Required.
369
+ :type job_id: str
370
+ :param resource: The resource instance. Is one of the following types: JobDetails, JSON,
371
+ IO[bytes] Required.
372
+ :type resource: ~azure.quantum.models.JobDetails or JSON or IO[bytes]
373
+ :return: JobDetails. The JobDetails is compatible with MutableMapping
374
+ :rtype: ~azure.quantum.models.JobDetails
375
+ :raises ~azure.core.exceptions.HttpResponseError:
376
+ """
377
+ error_map: MutableMapping = {
378
+ 401: ClientAuthenticationError,
379
+ 404: ResourceNotFoundError,
380
+ 409: ResourceExistsError,
381
+ 304: ResourceNotModifiedError,
382
+ }
383
+ error_map.update(kwargs.pop("error_map", {}) or {})
384
+
385
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
386
+ _params = kwargs.pop("params", {}) or {}
387
+
388
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
389
+ cls: ClsType[_models.JobDetails] = kwargs.pop("cls", None)
390
+
391
+ content_type = content_type or "application/json"
392
+ _content = None
393
+ if isinstance(resource, (IOBase, bytes)):
394
+ _content = resource
395
+ else:
396
+ _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
397
+
398
+ _request = build_services_jobs_create_request(
399
+ subscription_id=subscription_id,
400
+ resource_group_name=resource_group_name,
401
+ workspace_name=workspace_name,
402
+ job_id=job_id,
403
+ content_type=content_type,
404
+ api_version=self._config.api_version,
405
+ content=_content,
406
+ headers=_headers,
407
+ params=_params,
408
+ )
409
+ path_format_arguments = {
410
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
411
+ }
412
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
413
+
414
+ _stream = kwargs.pop("stream", False)
415
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
416
+ _request, stream=_stream, **kwargs
417
+ )
418
+
419
+ response = pipeline_response.http_response
420
+
421
+ if response.status_code not in [200, 201]:
422
+ if _stream:
423
+ try:
424
+ await response.read() # Load the body in memory and close the socket
425
+ except (StreamConsumedError, StreamClosedError):
426
+ pass
427
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
428
+ raise HttpResponseError(response=response)
429
+
430
+ if _stream:
431
+ deserialized = response.iter_bytes()
432
+ else:
433
+ deserialized = _deserialize(_models.JobDetails, response.json())
434
+
435
+ if cls:
436
+ return cls(pipeline_response, deserialized, {}) # type: ignore
437
+
438
+ return deserialized # type: ignore
439
+
440
+ @overload
441
+ async def update(
442
+ self,
443
+ subscription_id: str,
444
+ resource_group_name: str,
445
+ workspace_name: str,
446
+ job_id: str,
447
+ resource: _models.JobUpdateOptions,
448
+ *,
449
+ content_type: str = "application/merge-patch+json",
450
+ **kwargs: Any
451
+ ) -> _models.JobUpdateOptions:
452
+ """Update job properties.
453
+
454
+ :param subscription_id: The Azure subscription ID. Required.
455
+ :type subscription_id: str
456
+ :param resource_group_name: Name of the Azure resource group. Required.
457
+ :type resource_group_name: str
458
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
459
+ :type workspace_name: str
460
+ :param job_id: Id of the job. Required.
461
+ :type job_id: str
462
+ :param resource: The resource instance. Required.
463
+ :type resource: ~azure.quantum.models.JobUpdateOptions
464
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
465
+ Default value is "application/merge-patch+json".
466
+ :paramtype content_type: str
467
+ :return: JobUpdateOptions. The JobUpdateOptions is compatible with MutableMapping
468
+ :rtype: ~azure.quantum.models.JobUpdateOptions
469
+ :raises ~azure.core.exceptions.HttpResponseError:
470
+ """
471
+
472
+ @overload
473
+ async def update(
474
+ self,
475
+ subscription_id: str,
476
+ resource_group_name: str,
477
+ workspace_name: str,
478
+ job_id: str,
479
+ resource: JSON,
480
+ *,
481
+ content_type: str = "application/merge-patch+json",
482
+ **kwargs: Any
483
+ ) -> _models.JobUpdateOptions:
484
+ """Update job properties.
485
+
486
+ :param subscription_id: The Azure subscription ID. Required.
487
+ :type subscription_id: str
488
+ :param resource_group_name: Name of the Azure resource group. Required.
489
+ :type resource_group_name: str
490
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
491
+ :type workspace_name: str
492
+ :param job_id: Id of the job. Required.
493
+ :type job_id: str
494
+ :param resource: The resource instance. Required.
495
+ :type resource: JSON
496
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
497
+ Default value is "application/merge-patch+json".
498
+ :paramtype content_type: str
499
+ :return: JobUpdateOptions. The JobUpdateOptions is compatible with MutableMapping
500
+ :rtype: ~azure.quantum.models.JobUpdateOptions
501
+ :raises ~azure.core.exceptions.HttpResponseError:
502
+ """
503
+
504
+ @overload
505
+ async def update(
506
+ self,
507
+ subscription_id: str,
508
+ resource_group_name: str,
509
+ workspace_name: str,
510
+ job_id: str,
511
+ resource: IO[bytes],
512
+ *,
513
+ content_type: str = "application/merge-patch+json",
514
+ **kwargs: Any
515
+ ) -> _models.JobUpdateOptions:
516
+ """Update job properties.
517
+
518
+ :param subscription_id: The Azure subscription ID. Required.
519
+ :type subscription_id: str
520
+ :param resource_group_name: Name of the Azure resource group. Required.
521
+ :type resource_group_name: str
522
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
523
+ :type workspace_name: str
524
+ :param job_id: Id of the job. Required.
525
+ :type job_id: str
526
+ :param resource: The resource instance. Required.
527
+ :type resource: IO[bytes]
528
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
529
+ Default value is "application/merge-patch+json".
530
+ :paramtype content_type: str
531
+ :return: JobUpdateOptions. The JobUpdateOptions is compatible with MutableMapping
532
+ :rtype: ~azure.quantum.models.JobUpdateOptions
533
+ :raises ~azure.core.exceptions.HttpResponseError:
534
+ """
535
+
536
+ @distributed_trace_async
537
+ @api_version_validation(
538
+ method_added_on="2025-09-01-preview",
539
+ params_added_on={
540
+ "2025-09-01-preview": [
541
+ "api_version",
542
+ "subscription_id",
543
+ "resource_group_name",
544
+ "workspace_name",
545
+ "job_id",
546
+ "content_type",
547
+ "accept",
548
+ ]
549
+ },
550
+ api_versions_list=["2025-09-01-preview", "2025-12-01-preview"],
551
+ )
552
+ async def update(
553
+ self,
554
+ subscription_id: str,
555
+ resource_group_name: str,
556
+ workspace_name: str,
557
+ job_id: str,
558
+ resource: Union[_models.JobUpdateOptions, JSON, IO[bytes]],
559
+ **kwargs: Any
560
+ ) -> _models.JobUpdateOptions:
561
+ """Update job properties.
562
+
563
+ :param subscription_id: The Azure subscription ID. Required.
564
+ :type subscription_id: str
565
+ :param resource_group_name: Name of the Azure resource group. Required.
566
+ :type resource_group_name: str
567
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
568
+ :type workspace_name: str
569
+ :param job_id: Id of the job. Required.
570
+ :type job_id: str
571
+ :param resource: The resource instance. Is one of the following types: JobUpdateOptions, JSON,
572
+ IO[bytes] Required.
573
+ :type resource: ~azure.quantum.models.JobUpdateOptions or JSON or IO[bytes]
574
+ :return: JobUpdateOptions. The JobUpdateOptions is compatible with MutableMapping
575
+ :rtype: ~azure.quantum.models.JobUpdateOptions
576
+ :raises ~azure.core.exceptions.HttpResponseError:
577
+ """
578
+ error_map: MutableMapping = {
579
+ 401: ClientAuthenticationError,
580
+ 404: ResourceNotFoundError,
581
+ 409: ResourceExistsError,
582
+ 304: ResourceNotModifiedError,
583
+ }
584
+ error_map.update(kwargs.pop("error_map", {}) or {})
585
+
586
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
587
+ _params = kwargs.pop("params", {}) or {}
588
+
589
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
590
+ cls: ClsType[_models.JobUpdateOptions] = kwargs.pop("cls", None)
591
+
592
+ content_type = content_type or "application/merge-patch+json"
593
+ _content = None
594
+ if isinstance(resource, (IOBase, bytes)):
595
+ _content = resource
596
+ else:
597
+ _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
598
+
599
+ _request = build_services_jobs_update_request(
600
+ subscription_id=subscription_id,
601
+ resource_group_name=resource_group_name,
602
+ workspace_name=workspace_name,
603
+ job_id=job_id,
604
+ content_type=content_type,
605
+ api_version=self._config.api_version,
606
+ content=_content,
607
+ headers=_headers,
608
+ params=_params,
609
+ )
610
+ path_format_arguments = {
611
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
612
+ }
613
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
614
+
615
+ _stream = kwargs.pop("stream", False)
616
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
617
+ _request, stream=_stream, **kwargs
618
+ )
619
+
620
+ response = pipeline_response.http_response
621
+
622
+ if response.status_code not in [200]:
623
+ if _stream:
624
+ try:
625
+ await response.read() # Load the body in memory and close the socket
626
+ except (StreamConsumedError, StreamClosedError):
627
+ pass
628
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
629
+ raise HttpResponseError(response=response)
630
+
631
+ if _stream:
632
+ deserialized = response.iter_bytes()
633
+ else:
634
+ deserialized = _deserialize(_models.JobUpdateOptions, response.json())
635
+
636
+ if cls:
637
+ return cls(pipeline_response, deserialized, {}) # type: ignore
638
+
639
+ return deserialized # type: ignore
640
+
641
+ @distributed_trace_async
642
+ async def delete(
643
+ self, subscription_id: str, resource_group_name: str, workspace_name: str, job_id: str, **kwargs: Any
644
+ ) -> None:
645
+ """Delete a job by its id. Use for cancellation in versions before 2025-12-01-preview.
646
+
647
+ :param subscription_id: The Azure subscription ID. Required.
648
+ :type subscription_id: str
649
+ :param resource_group_name: Name of the Azure resource group. Required.
650
+ :type resource_group_name: str
651
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
652
+ :type workspace_name: str
653
+ :param job_id: Id of the job. Required.
654
+ :type job_id: str
655
+ :return: None
656
+ :rtype: None
657
+ :raises ~azure.core.exceptions.HttpResponseError:
658
+ """
659
+ error_map: MutableMapping = {
660
+ 401: ClientAuthenticationError,
661
+ 404: ResourceNotFoundError,
662
+ 409: ResourceExistsError,
663
+ 304: ResourceNotModifiedError,
664
+ }
665
+ error_map.update(kwargs.pop("error_map", {}) or {})
666
+
667
+ _headers = kwargs.pop("headers", {}) or {}
668
+ _params = kwargs.pop("params", {}) or {}
669
+
670
+ cls: ClsType[None] = kwargs.pop("cls", None)
671
+
672
+ _request = build_services_jobs_delete_request(
673
+ subscription_id=subscription_id,
674
+ resource_group_name=resource_group_name,
675
+ workspace_name=workspace_name,
676
+ job_id=job_id,
677
+ api_version=self._config.api_version,
678
+ headers=_headers,
679
+ params=_params,
680
+ )
681
+ path_format_arguments = {
682
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
683
+ }
684
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
685
+
686
+ _stream = False
687
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
688
+ _request, stream=_stream, **kwargs
689
+ )
690
+
691
+ response = pipeline_response.http_response
692
+
693
+ if response.status_code not in [204]:
694
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
695
+ raise HttpResponseError(response=response)
696
+
697
+ if cls:
698
+ return cls(pipeline_response, None, {}) # type: ignore
699
+
700
+ @distributed_trace_async
701
+ @api_version_validation(
702
+ method_added_on="2025-12-01-preview",
703
+ params_added_on={
704
+ "2025-12-01-preview": [
705
+ "api_version",
706
+ "subscription_id",
707
+ "resource_group_name",
708
+ "workspace_name",
709
+ "job_id",
710
+ "accept",
711
+ ]
712
+ },
713
+ api_versions_list=["2025-12-01-preview"],
714
+ )
715
+ async def cancel(
716
+ self, subscription_id: str, resource_group_name: str, workspace_name: str, job_id: str, **kwargs: Any
717
+ ) -> _models.JobDetails:
718
+ """Request the cancellation of an existing job.
719
+
720
+ :param subscription_id: The Azure subscription ID. Required.
721
+ :type subscription_id: str
722
+ :param resource_group_name: Name of the Azure resource group. Required.
723
+ :type resource_group_name: str
724
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
725
+ :type workspace_name: str
726
+ :param job_id: Id of the job. Required.
727
+ :type job_id: str
728
+ :return: JobDetails. The JobDetails is compatible with MutableMapping
729
+ :rtype: ~azure.quantum.models.JobDetails
730
+ :raises ~azure.core.exceptions.HttpResponseError:
731
+ """
732
+ error_map: MutableMapping = {
733
+ 401: ClientAuthenticationError,
734
+ 404: ResourceNotFoundError,
735
+ 409: ResourceExistsError,
736
+ 304: ResourceNotModifiedError,
737
+ }
738
+ error_map.update(kwargs.pop("error_map", {}) or {})
739
+
740
+ _headers = kwargs.pop("headers", {}) or {}
741
+ _params = kwargs.pop("params", {}) or {}
742
+
743
+ cls: ClsType[_models.JobDetails] = kwargs.pop("cls", None)
744
+
745
+ _request = build_services_jobs_cancel_request(
746
+ subscription_id=subscription_id,
747
+ resource_group_name=resource_group_name,
748
+ workspace_name=workspace_name,
749
+ job_id=job_id,
750
+ api_version=self._config.api_version,
751
+ headers=_headers,
752
+ params=_params,
753
+ )
754
+ path_format_arguments = {
755
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
756
+ }
757
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
758
+
759
+ _stream = kwargs.pop("stream", False)
760
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
761
+ _request, stream=_stream, **kwargs
762
+ )
763
+
764
+ response = pipeline_response.http_response
765
+
766
+ if response.status_code not in [200]:
767
+ if _stream:
768
+ try:
769
+ await response.read() # Load the body in memory and close the socket
770
+ except (StreamConsumedError, StreamClosedError):
771
+ pass
772
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
773
+ raise HttpResponseError(response=response)
774
+
775
+ if _stream:
776
+ deserialized = response.iter_bytes()
777
+ else:
778
+ deserialized = _deserialize(_models.JobDetails, response.json())
779
+
780
+ if cls:
781
+ return cls(pipeline_response, deserialized, {}) # type: ignore
782
+
783
+ return deserialized # type: ignore
784
+
785
+ @distributed_trace_async
786
+ async def get(
787
+ self, subscription_id: str, resource_group_name: str, workspace_name: str, job_id: str, **kwargs: Any
788
+ ) -> _models.JobDetails:
789
+ """Get job by its id.
790
+
791
+ :param subscription_id: The Azure subscription ID. Required.
792
+ :type subscription_id: str
793
+ :param resource_group_name: Name of the Azure resource group. Required.
794
+ :type resource_group_name: str
795
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
796
+ :type workspace_name: str
797
+ :param job_id: Id of the job. Required.
798
+ :type job_id: str
799
+ :return: JobDetails. The JobDetails is compatible with MutableMapping
800
+ :rtype: ~azure.quantum.models.JobDetails
801
+ :raises ~azure.core.exceptions.HttpResponseError:
802
+ """
803
+ error_map: MutableMapping = {
804
+ 401: ClientAuthenticationError,
805
+ 404: ResourceNotFoundError,
806
+ 409: ResourceExistsError,
807
+ 304: ResourceNotModifiedError,
808
+ }
809
+ error_map.update(kwargs.pop("error_map", {}) or {})
810
+
811
+ _headers = kwargs.pop("headers", {}) or {}
812
+ _params = kwargs.pop("params", {}) or {}
813
+
814
+ cls: ClsType[_models.JobDetails] = kwargs.pop("cls", None)
815
+
816
+ _request = build_services_jobs_get_request(
817
+ subscription_id=subscription_id,
818
+ resource_group_name=resource_group_name,
819
+ workspace_name=workspace_name,
820
+ job_id=job_id,
821
+ api_version=self._config.api_version,
822
+ headers=_headers,
823
+ params=_params,
824
+ )
825
+ path_format_arguments = {
826
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
827
+ }
828
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
829
+
830
+ _stream = kwargs.pop("stream", False)
831
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
832
+ _request, stream=_stream, **kwargs
833
+ )
834
+
835
+ response = pipeline_response.http_response
836
+
837
+ if response.status_code not in [200]:
838
+ if _stream:
839
+ try:
840
+ await response.read() # Load the body in memory and close the socket
841
+ except (StreamConsumedError, StreamClosedError):
842
+ pass
843
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
844
+ raise HttpResponseError(response=response)
845
+
846
+ if _stream:
847
+ deserialized = response.iter_bytes()
848
+ else:
849
+ deserialized = _deserialize(_models.JobDetails, response.json())
850
+
851
+ if cls:
852
+ return cls(pipeline_response, deserialized, {}) # type: ignore
853
+
854
+ return deserialized # type: ignore
855
+
856
+ @distributed_trace
857
+ @api_version_validation(
858
+ params_added_on={"2024-10-01-preview": ["filter", "skip", "top", "orderby"]},
859
+ api_versions_list=["2024-03-01-preview", "2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
860
+ )
861
+ def list(
862
+ self,
863
+ subscription_id: str,
864
+ resource_group_name: str,
865
+ workspace_name: str,
866
+ *,
867
+ filter: Optional[str] = None,
868
+ skip: Optional[int] = None,
869
+ top: Optional[int] = None,
870
+ orderby: Optional[str] = None,
871
+ **kwargs: Any
872
+ ) -> AsyncItemPaged["_models.JobDetails"]:
873
+ """List all jobs.
874
+
875
+ :param subscription_id: The Azure subscription ID. Required.
876
+ :type subscription_id: str
877
+ :param resource_group_name: Name of the Azure resource group. Required.
878
+ :type resource_group_name: str
879
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
880
+ :type workspace_name: str
881
+ :keyword filter: Filter the result list using the given expression. Default value is None.
882
+ :paramtype filter: str
883
+ :keyword skip: The number of result items to skip. Default value is None.
884
+ :paramtype skip: int
885
+ :keyword top: The number of jobs taken. Default value is None.
886
+ :paramtype top: int
887
+ :keyword orderby: The order of returned items. Default value is None.
888
+ :paramtype orderby: str
889
+ :return: An iterator like instance of JobDetails
890
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.JobDetails]
891
+ :raises ~azure.core.exceptions.HttpResponseError:
892
+ """
893
+ _headers = kwargs.pop("headers", {}) or {}
894
+ _params = kwargs.pop("params", {}) or {}
895
+
896
+ cls: ClsType[list[_models.JobDetails]] = kwargs.pop("cls", None)
897
+
898
+ error_map: MutableMapping = {
899
+ 401: ClientAuthenticationError,
900
+ 404: ResourceNotFoundError,
901
+ 409: ResourceExistsError,
902
+ 304: ResourceNotModifiedError,
903
+ }
904
+ error_map.update(kwargs.pop("error_map", {}) or {})
905
+
906
+ def prepare_request(next_link=None):
907
+ if not next_link:
908
+
909
+ _request = build_services_jobs_list_request(
910
+ subscription_id=subscription_id,
911
+ resource_group_name=resource_group_name,
912
+ workspace_name=workspace_name,
913
+ filter=filter,
914
+ skip=skip,
915
+ top=top,
916
+ orderby=orderby,
917
+ api_version=self._config.api_version,
918
+ headers=_headers,
919
+ params=_params,
920
+ )
921
+ path_format_arguments = {
922
+ "endpoint": self._serialize.url(
923
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
924
+ ),
925
+ }
926
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
927
+
928
+ else:
929
+ # make call to next link with the client's api-version
930
+ _parsed_next_link = urllib.parse.urlparse(next_link)
931
+ _next_request_params = case_insensitive_dict(
932
+ {
933
+ key: [urllib.parse.quote(v) for v in value]
934
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
935
+ }
936
+ )
937
+ _next_request_params["api-version"] = self._config.api_version
938
+ _request = HttpRequest(
939
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
940
+ )
941
+ path_format_arguments = {
942
+ "endpoint": self._serialize.url(
943
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
944
+ ),
945
+ }
946
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
947
+
948
+ return _request
949
+
950
+ async def extract_data(pipeline_response):
951
+ deserialized = pipeline_response.http_response.json()
952
+ list_of_elem = _deserialize(list[_models.JobDetails], deserialized.get("value", []))
953
+ if cls:
954
+ list_of_elem = cls(list_of_elem) # type: ignore
955
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
956
+
957
+ async def get_next(next_link=None):
958
+ _request = prepare_request(next_link)
959
+
960
+ _stream = False
961
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
962
+ _request, stream=_stream, **kwargs
963
+ )
964
+ response = pipeline_response.http_response
965
+
966
+ if response.status_code not in [200]:
967
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
968
+ raise HttpResponseError(response=response)
969
+
970
+ return pipeline_response
971
+
972
+ return AsyncItemPaged(get_next, extract_data)
973
+
974
+
975
+ class ServicesProvidersOperations:
976
+ """
977
+ .. warning::
978
+ **DO NOT** instantiate this class directly.
979
+
980
+ Instead, you should access the following operations through
981
+ :class:`~azure.quantum.aio.WorkspaceClient`'s
982
+ :attr:`providers` attribute.
983
+ """
984
+
985
+ def __init__(self, *args, **kwargs) -> None:
986
+ input_args = list(args)
987
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
988
+ self._config: WorkspaceClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
989
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
990
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
991
+
992
+ @distributed_trace
993
+ def list(
994
+ self, subscription_id: str, resource_group_name: str, workspace_name: str, **kwargs: Any
995
+ ) -> AsyncItemPaged["_models.ProviderStatus"]:
996
+ """List all providers in the workspace with their respective status.
997
+
998
+ :param subscription_id: The Azure subscription ID. Required.
999
+ :type subscription_id: str
1000
+ :param resource_group_name: Name of the Azure resource group. Required.
1001
+ :type resource_group_name: str
1002
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1003
+ :type workspace_name: str
1004
+ :return: An iterator like instance of ProviderStatus
1005
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.ProviderStatus]
1006
+ :raises ~azure.core.exceptions.HttpResponseError:
1007
+ """
1008
+ _headers = kwargs.pop("headers", {}) or {}
1009
+ _params = kwargs.pop("params", {}) or {}
1010
+
1011
+ cls: ClsType[list[_models.ProviderStatus]] = kwargs.pop("cls", None)
1012
+
1013
+ error_map: MutableMapping = {
1014
+ 401: ClientAuthenticationError,
1015
+ 404: ResourceNotFoundError,
1016
+ 409: ResourceExistsError,
1017
+ 304: ResourceNotModifiedError,
1018
+ }
1019
+ error_map.update(kwargs.pop("error_map", {}) or {})
1020
+
1021
+ def prepare_request(next_link=None):
1022
+ if not next_link:
1023
+
1024
+ _request = build_services_providers_list_request(
1025
+ subscription_id=subscription_id,
1026
+ resource_group_name=resource_group_name,
1027
+ workspace_name=workspace_name,
1028
+ api_version=self._config.api_version,
1029
+ headers=_headers,
1030
+ params=_params,
1031
+ )
1032
+ path_format_arguments = {
1033
+ "endpoint": self._serialize.url(
1034
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1035
+ ),
1036
+ }
1037
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1038
+
1039
+ else:
1040
+ # make call to next link with the client's api-version
1041
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1042
+ _next_request_params = case_insensitive_dict(
1043
+ {
1044
+ key: [urllib.parse.quote(v) for v in value]
1045
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1046
+ }
1047
+ )
1048
+ _next_request_params["api-version"] = self._config.api_version
1049
+ _request = HttpRequest(
1050
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1051
+ )
1052
+ path_format_arguments = {
1053
+ "endpoint": self._serialize.url(
1054
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1055
+ ),
1056
+ }
1057
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1058
+
1059
+ return _request
1060
+
1061
+ async def extract_data(pipeline_response):
1062
+ deserialized = pipeline_response.http_response.json()
1063
+ list_of_elem = _deserialize(list[_models.ProviderStatus], deserialized.get("value", []))
1064
+ if cls:
1065
+ list_of_elem = cls(list_of_elem) # type: ignore
1066
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1067
+
1068
+ async def get_next(next_link=None):
1069
+ _request = prepare_request(next_link)
1070
+
1071
+ _stream = False
1072
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1073
+ _request, stream=_stream, **kwargs
1074
+ )
1075
+ response = pipeline_response.http_response
1076
+
1077
+ if response.status_code not in [200]:
1078
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1079
+ raise HttpResponseError(response=response)
1080
+
1081
+ return pipeline_response
1082
+
1083
+ return AsyncItemPaged(get_next, extract_data)
1084
+
1085
+
1086
+ class ServicesQuotasOperations:
1087
+ """
1088
+ .. warning::
1089
+ **DO NOT** instantiate this class directly.
1090
+
1091
+ Instead, you should access the following operations through
1092
+ :class:`~azure.quantum.aio.WorkspaceClient`'s
1093
+ :attr:`quotas` attribute.
1094
+ """
1095
+
1096
+ def __init__(self, *args, **kwargs) -> None:
1097
+ input_args = list(args)
1098
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
1099
+ self._config: WorkspaceClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
1100
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
1101
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
1102
+
1103
+ @distributed_trace
1104
+ def list(
1105
+ self, subscription_id: str, resource_group_name: str, workspace_name: str, **kwargs: Any
1106
+ ) -> AsyncItemPaged["_models.Quota"]:
1107
+ """List quotas for the given workspace.
1108
+
1109
+ :param subscription_id: The Azure subscription ID. Required.
1110
+ :type subscription_id: str
1111
+ :param resource_group_name: Name of the Azure resource group. Required.
1112
+ :type resource_group_name: str
1113
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1114
+ :type workspace_name: str
1115
+ :return: An iterator like instance of Quota
1116
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.Quota]
1117
+ :raises ~azure.core.exceptions.HttpResponseError:
1118
+ """
1119
+ _headers = kwargs.pop("headers", {}) or {}
1120
+ _params = kwargs.pop("params", {}) or {}
1121
+
1122
+ cls: ClsType[list[_models.Quota]] = kwargs.pop("cls", None)
1123
+
1124
+ error_map: MutableMapping = {
1125
+ 401: ClientAuthenticationError,
1126
+ 404: ResourceNotFoundError,
1127
+ 409: ResourceExistsError,
1128
+ 304: ResourceNotModifiedError,
1129
+ }
1130
+ error_map.update(kwargs.pop("error_map", {}) or {})
1131
+
1132
+ def prepare_request(next_link=None):
1133
+ if not next_link:
1134
+
1135
+ _request = build_services_quotas_list_request(
1136
+ subscription_id=subscription_id,
1137
+ resource_group_name=resource_group_name,
1138
+ workspace_name=workspace_name,
1139
+ api_version=self._config.api_version,
1140
+ headers=_headers,
1141
+ params=_params,
1142
+ )
1143
+ path_format_arguments = {
1144
+ "endpoint": self._serialize.url(
1145
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1146
+ ),
1147
+ }
1148
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1149
+
1150
+ else:
1151
+ # make call to next link with the client's api-version
1152
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1153
+ _next_request_params = case_insensitive_dict(
1154
+ {
1155
+ key: [urllib.parse.quote(v) for v in value]
1156
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1157
+ }
1158
+ )
1159
+ _next_request_params["api-version"] = self._config.api_version
1160
+ _request = HttpRequest(
1161
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1162
+ )
1163
+ path_format_arguments = {
1164
+ "endpoint": self._serialize.url(
1165
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1166
+ ),
1167
+ }
1168
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1169
+
1170
+ return _request
1171
+
1172
+ async def extract_data(pipeline_response):
1173
+ deserialized = pipeline_response.http_response.json()
1174
+ list_of_elem = _deserialize(list[_models.Quota], deserialized.get("value", []))
1175
+ if cls:
1176
+ list_of_elem = cls(list_of_elem) # type: ignore
1177
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1178
+
1179
+ async def get_next(next_link=None):
1180
+ _request = prepare_request(next_link)
1181
+
1182
+ _stream = False
1183
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1184
+ _request, stream=_stream, **kwargs
1185
+ )
1186
+ response = pipeline_response.http_response
1187
+
1188
+ if response.status_code not in [200]:
1189
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1190
+ raise HttpResponseError(response=response)
1191
+
1192
+ return pipeline_response
1193
+
1194
+ return AsyncItemPaged(get_next, extract_data)
1195
+
1196
+
1197
+ class ServicesSessionsOperations:
1198
+ """
1199
+ .. warning::
1200
+ **DO NOT** instantiate this class directly.
1201
+
1202
+ Instead, you should access the following operations through
1203
+ :class:`~azure.quantum.aio.WorkspaceClient`'s
1204
+ :attr:`sessions` attribute.
1205
+ """
1206
+
1207
+ def __init__(self, *args, **kwargs) -> None:
1208
+ input_args = list(args)
1209
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
1210
+ self._config: WorkspaceClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
1211
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
1212
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
1213
+
1214
+ @overload
1215
+ async def open(
1216
+ self,
1217
+ subscription_id: str,
1218
+ resource_group_name: str,
1219
+ workspace_name: str,
1220
+ session_id: str,
1221
+ resource: _models.SessionDetails,
1222
+ *,
1223
+ content_type: str = "application/json",
1224
+ **kwargs: Any
1225
+ ) -> _models.SessionDetails:
1226
+ """Open a new session.
1227
+
1228
+ :param subscription_id: The Azure subscription ID. Required.
1229
+ :type subscription_id: str
1230
+ :param resource_group_name: Name of the Azure resource group. Required.
1231
+ :type resource_group_name: str
1232
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1233
+ :type workspace_name: str
1234
+ :param session_id: Id of the session. Required.
1235
+ :type session_id: str
1236
+ :param resource: The resource instance. Required.
1237
+ :type resource: ~azure.quantum.models.SessionDetails
1238
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1239
+ Default value is "application/json".
1240
+ :paramtype content_type: str
1241
+ :return: SessionDetails. The SessionDetails is compatible with MutableMapping
1242
+ :rtype: ~azure.quantum.models.SessionDetails
1243
+ :raises ~azure.core.exceptions.HttpResponseError:
1244
+ """
1245
+
1246
+ @overload
1247
+ async def open(
1248
+ self,
1249
+ subscription_id: str,
1250
+ resource_group_name: str,
1251
+ workspace_name: str,
1252
+ session_id: str,
1253
+ resource: JSON,
1254
+ *,
1255
+ content_type: str = "application/json",
1256
+ **kwargs: Any
1257
+ ) -> _models.SessionDetails:
1258
+ """Open a new session.
1259
+
1260
+ :param subscription_id: The Azure subscription ID. Required.
1261
+ :type subscription_id: str
1262
+ :param resource_group_name: Name of the Azure resource group. Required.
1263
+ :type resource_group_name: str
1264
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1265
+ :type workspace_name: str
1266
+ :param session_id: Id of the session. Required.
1267
+ :type session_id: str
1268
+ :param resource: The resource instance. Required.
1269
+ :type resource: JSON
1270
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1271
+ Default value is "application/json".
1272
+ :paramtype content_type: str
1273
+ :return: SessionDetails. The SessionDetails is compatible with MutableMapping
1274
+ :rtype: ~azure.quantum.models.SessionDetails
1275
+ :raises ~azure.core.exceptions.HttpResponseError:
1276
+ """
1277
+
1278
+ @overload
1279
+ async def open(
1280
+ self,
1281
+ subscription_id: str,
1282
+ resource_group_name: str,
1283
+ workspace_name: str,
1284
+ session_id: str,
1285
+ resource: IO[bytes],
1286
+ *,
1287
+ content_type: str = "application/json",
1288
+ **kwargs: Any
1289
+ ) -> _models.SessionDetails:
1290
+ """Open a new session.
1291
+
1292
+ :param subscription_id: The Azure subscription ID. Required.
1293
+ :type subscription_id: str
1294
+ :param resource_group_name: Name of the Azure resource group. Required.
1295
+ :type resource_group_name: str
1296
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1297
+ :type workspace_name: str
1298
+ :param session_id: Id of the session. Required.
1299
+ :type session_id: str
1300
+ :param resource: The resource instance. Required.
1301
+ :type resource: IO[bytes]
1302
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
1303
+ Default value is "application/json".
1304
+ :paramtype content_type: str
1305
+ :return: SessionDetails. The SessionDetails is compatible with MutableMapping
1306
+ :rtype: ~azure.quantum.models.SessionDetails
1307
+ :raises ~azure.core.exceptions.HttpResponseError:
1308
+ """
1309
+
1310
+ @distributed_trace_async
1311
+ async def open(
1312
+ self,
1313
+ subscription_id: str,
1314
+ resource_group_name: str,
1315
+ workspace_name: str,
1316
+ session_id: str,
1317
+ resource: Union[_models.SessionDetails, JSON, IO[bytes]],
1318
+ **kwargs: Any
1319
+ ) -> _models.SessionDetails:
1320
+ """Open a new session.
1321
+
1322
+ :param subscription_id: The Azure subscription ID. Required.
1323
+ :type subscription_id: str
1324
+ :param resource_group_name: Name of the Azure resource group. Required.
1325
+ :type resource_group_name: str
1326
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1327
+ :type workspace_name: str
1328
+ :param session_id: Id of the session. Required.
1329
+ :type session_id: str
1330
+ :param resource: The resource instance. Is one of the following types: SessionDetails, JSON,
1331
+ IO[bytes] Required.
1332
+ :type resource: ~azure.quantum.models.SessionDetails or JSON or IO[bytes]
1333
+ :return: SessionDetails. The SessionDetails is compatible with MutableMapping
1334
+ :rtype: ~azure.quantum.models.SessionDetails
1335
+ :raises ~azure.core.exceptions.HttpResponseError:
1336
+ """
1337
+ error_map: MutableMapping = {
1338
+ 401: ClientAuthenticationError,
1339
+ 404: ResourceNotFoundError,
1340
+ 409: ResourceExistsError,
1341
+ 304: ResourceNotModifiedError,
1342
+ }
1343
+ error_map.update(kwargs.pop("error_map", {}) or {})
1344
+
1345
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1346
+ _params = kwargs.pop("params", {}) or {}
1347
+
1348
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1349
+ cls: ClsType[_models.SessionDetails] = kwargs.pop("cls", None)
1350
+
1351
+ content_type = content_type or "application/json"
1352
+ _content = None
1353
+ if isinstance(resource, (IOBase, bytes)):
1354
+ _content = resource
1355
+ else:
1356
+ _content = json.dumps(resource, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
1357
+
1358
+ _request = build_services_sessions_open_request(
1359
+ subscription_id=subscription_id,
1360
+ resource_group_name=resource_group_name,
1361
+ workspace_name=workspace_name,
1362
+ session_id=session_id,
1363
+ content_type=content_type,
1364
+ api_version=self._config.api_version,
1365
+ content=_content,
1366
+ headers=_headers,
1367
+ params=_params,
1368
+ )
1369
+ path_format_arguments = {
1370
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
1371
+ }
1372
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1373
+
1374
+ _stream = kwargs.pop("stream", False)
1375
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1376
+ _request, stream=_stream, **kwargs
1377
+ )
1378
+
1379
+ response = pipeline_response.http_response
1380
+
1381
+ if response.status_code not in [200, 201]:
1382
+ if _stream:
1383
+ try:
1384
+ await response.read() # Load the body in memory and close the socket
1385
+ except (StreamConsumedError, StreamClosedError):
1386
+ pass
1387
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1388
+ raise HttpResponseError(response=response)
1389
+
1390
+ if _stream:
1391
+ deserialized = response.iter_bytes()
1392
+ else:
1393
+ deserialized = _deserialize(_models.SessionDetails, response.json())
1394
+
1395
+ if cls:
1396
+ return cls(pipeline_response, deserialized, {}) # type: ignore
1397
+
1398
+ return deserialized # type: ignore
1399
+
1400
+ @distributed_trace_async
1401
+ async def close(
1402
+ self, subscription_id: str, resource_group_name: str, workspace_name: str, session_id: str, **kwargs: Any
1403
+ ) -> _models.SessionDetails:
1404
+ """Close an existing session.
1405
+
1406
+ :param subscription_id: The Azure subscription ID. Required.
1407
+ :type subscription_id: str
1408
+ :param resource_group_name: Name of the Azure resource group. Required.
1409
+ :type resource_group_name: str
1410
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1411
+ :type workspace_name: str
1412
+ :param session_id: Id of the session. Required.
1413
+ :type session_id: str
1414
+ :return: SessionDetails. The SessionDetails is compatible with MutableMapping
1415
+ :rtype: ~azure.quantum.models.SessionDetails
1416
+ :raises ~azure.core.exceptions.HttpResponseError:
1417
+ """
1418
+ error_map: MutableMapping = {
1419
+ 401: ClientAuthenticationError,
1420
+ 404: ResourceNotFoundError,
1421
+ 409: ResourceExistsError,
1422
+ 304: ResourceNotModifiedError,
1423
+ }
1424
+ error_map.update(kwargs.pop("error_map", {}) or {})
1425
+
1426
+ _headers = kwargs.pop("headers", {}) or {}
1427
+ _params = kwargs.pop("params", {}) or {}
1428
+
1429
+ cls: ClsType[_models.SessionDetails] = kwargs.pop("cls", None)
1430
+
1431
+ _request = build_services_sessions_close_request(
1432
+ subscription_id=subscription_id,
1433
+ resource_group_name=resource_group_name,
1434
+ workspace_name=workspace_name,
1435
+ session_id=session_id,
1436
+ api_version=self._config.api_version,
1437
+ headers=_headers,
1438
+ params=_params,
1439
+ )
1440
+ path_format_arguments = {
1441
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
1442
+ }
1443
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1444
+
1445
+ _stream = kwargs.pop("stream", False)
1446
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1447
+ _request, stream=_stream, **kwargs
1448
+ )
1449
+
1450
+ response = pipeline_response.http_response
1451
+
1452
+ if response.status_code not in [200]:
1453
+ if _stream:
1454
+ try:
1455
+ await response.read() # Load the body in memory and close the socket
1456
+ except (StreamConsumedError, StreamClosedError):
1457
+ pass
1458
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1459
+ raise HttpResponseError(response=response)
1460
+
1461
+ if _stream:
1462
+ deserialized = response.iter_bytes()
1463
+ else:
1464
+ deserialized = _deserialize(_models.SessionDetails, response.json())
1465
+
1466
+ if cls:
1467
+ return cls(pipeline_response, deserialized, {}) # type: ignore
1468
+
1469
+ return deserialized # type: ignore
1470
+
1471
+ @distributed_trace_async
1472
+ async def get(
1473
+ self, subscription_id: str, resource_group_name: str, workspace_name: str, session_id: str, **kwargs: Any
1474
+ ) -> _models.SessionDetails:
1475
+ """Get Session by its id.
1476
+
1477
+ :param subscription_id: The Azure subscription ID. Required.
1478
+ :type subscription_id: str
1479
+ :param resource_group_name: Name of the Azure resource group. Required.
1480
+ :type resource_group_name: str
1481
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1482
+ :type workspace_name: str
1483
+ :param session_id: Id of the session. Required.
1484
+ :type session_id: str
1485
+ :return: SessionDetails. The SessionDetails is compatible with MutableMapping
1486
+ :rtype: ~azure.quantum.models.SessionDetails
1487
+ :raises ~azure.core.exceptions.HttpResponseError:
1488
+ """
1489
+ error_map: MutableMapping = {
1490
+ 401: ClientAuthenticationError,
1491
+ 404: ResourceNotFoundError,
1492
+ 409: ResourceExistsError,
1493
+ 304: ResourceNotModifiedError,
1494
+ }
1495
+ error_map.update(kwargs.pop("error_map", {}) or {})
1496
+
1497
+ _headers = kwargs.pop("headers", {}) or {}
1498
+ _params = kwargs.pop("params", {}) or {}
1499
+
1500
+ cls: ClsType[_models.SessionDetails] = kwargs.pop("cls", None)
1501
+
1502
+ _request = build_services_sessions_get_request(
1503
+ subscription_id=subscription_id,
1504
+ resource_group_name=resource_group_name,
1505
+ workspace_name=workspace_name,
1506
+ session_id=session_id,
1507
+ api_version=self._config.api_version,
1508
+ headers=_headers,
1509
+ params=_params,
1510
+ )
1511
+ path_format_arguments = {
1512
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
1513
+ }
1514
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1515
+
1516
+ _stream = kwargs.pop("stream", False)
1517
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1518
+ _request, stream=_stream, **kwargs
1519
+ )
1520
+
1521
+ response = pipeline_response.http_response
1522
+
1523
+ if response.status_code not in [200]:
1524
+ if _stream:
1525
+ try:
1526
+ await response.read() # Load the body in memory and close the socket
1527
+ except (StreamConsumedError, StreamClosedError):
1528
+ pass
1529
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1530
+ raise HttpResponseError(response=response)
1531
+
1532
+ if _stream:
1533
+ deserialized = response.iter_bytes()
1534
+ else:
1535
+ deserialized = _deserialize(_models.SessionDetails, response.json())
1536
+
1537
+ if cls:
1538
+ return cls(pipeline_response, deserialized, {}) # type: ignore
1539
+
1540
+ return deserialized # type: ignore
1541
+
1542
+ @distributed_trace
1543
+ @api_version_validation(
1544
+ method_added_on="2024-10-01-preview",
1545
+ params_added_on={
1546
+ "2024-10-01-preview": [
1547
+ "api_version",
1548
+ "subscription_id",
1549
+ "resource_group_name",
1550
+ "workspace_name",
1551
+ "filter",
1552
+ "skip",
1553
+ "top",
1554
+ "orderby",
1555
+ "accept",
1556
+ ]
1557
+ },
1558
+ api_versions_list=["2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
1559
+ )
1560
+ def listv2(
1561
+ self,
1562
+ subscription_id: str,
1563
+ resource_group_name: str,
1564
+ workspace_name: str,
1565
+ *,
1566
+ filter: Optional[str] = None,
1567
+ skip: Optional[int] = None,
1568
+ top: Optional[int] = None,
1569
+ orderby: Optional[str] = None,
1570
+ **kwargs: Any
1571
+ ) -> AsyncItemPaged["_models.SessionDetails"]:
1572
+ """List all Sessions.
1573
+
1574
+ :param subscription_id: The Azure subscription ID. Required.
1575
+ :type subscription_id: str
1576
+ :param resource_group_name: Name of the Azure resource group. Required.
1577
+ :type resource_group_name: str
1578
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1579
+ :type workspace_name: str
1580
+ :keyword filter: Filter the result list using the given expression. Default value is None.
1581
+ :paramtype filter: str
1582
+ :keyword skip: The number of result items to skip. Default value is None.
1583
+ :paramtype skip: int
1584
+ :keyword top: The number of jobs taken. Default value is None.
1585
+ :paramtype top: int
1586
+ :keyword orderby: The order of returned items. Default value is None.
1587
+ :paramtype orderby: str
1588
+ :return: An iterator like instance of SessionDetails
1589
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.SessionDetails]
1590
+ :raises ~azure.core.exceptions.HttpResponseError:
1591
+ """
1592
+ _headers = kwargs.pop("headers", {}) or {}
1593
+ _params = kwargs.pop("params", {}) or {}
1594
+
1595
+ cls: ClsType[list[_models.SessionDetails]] = kwargs.pop("cls", None)
1596
+
1597
+ error_map: MutableMapping = {
1598
+ 401: ClientAuthenticationError,
1599
+ 404: ResourceNotFoundError,
1600
+ 409: ResourceExistsError,
1601
+ 304: ResourceNotModifiedError,
1602
+ }
1603
+ error_map.update(kwargs.pop("error_map", {}) or {})
1604
+
1605
+ def prepare_request(next_link=None):
1606
+ if not next_link:
1607
+
1608
+ _request = build_services_sessions_listv2_request(
1609
+ subscription_id=subscription_id,
1610
+ resource_group_name=resource_group_name,
1611
+ workspace_name=workspace_name,
1612
+ filter=filter,
1613
+ skip=skip,
1614
+ top=top,
1615
+ orderby=orderby,
1616
+ api_version=self._config.api_version,
1617
+ headers=_headers,
1618
+ params=_params,
1619
+ )
1620
+ path_format_arguments = {
1621
+ "endpoint": self._serialize.url(
1622
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1623
+ ),
1624
+ }
1625
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1626
+
1627
+ else:
1628
+ # make call to next link with the client's api-version
1629
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1630
+ _next_request_params = case_insensitive_dict(
1631
+ {
1632
+ key: [urllib.parse.quote(v) for v in value]
1633
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1634
+ }
1635
+ )
1636
+ _next_request_params["api-version"] = self._config.api_version
1637
+ _request = HttpRequest(
1638
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1639
+ )
1640
+ path_format_arguments = {
1641
+ "endpoint": self._serialize.url(
1642
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1643
+ ),
1644
+ }
1645
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1646
+
1647
+ return _request
1648
+
1649
+ async def extract_data(pipeline_response):
1650
+ deserialized = pipeline_response.http_response.json()
1651
+ list_of_elem = _deserialize(list[_models.SessionDetails], deserialized.get("value", []))
1652
+ if cls:
1653
+ list_of_elem = cls(list_of_elem) # type: ignore
1654
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1655
+
1656
+ async def get_next(next_link=None):
1657
+ _request = prepare_request(next_link)
1658
+
1659
+ _stream = False
1660
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1661
+ _request, stream=_stream, **kwargs
1662
+ )
1663
+ response = pipeline_response.http_response
1664
+
1665
+ if response.status_code not in [200]:
1666
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1667
+ raise HttpResponseError(response=response)
1668
+
1669
+ return pipeline_response
1670
+
1671
+ return AsyncItemPaged(get_next, extract_data)
1672
+
1673
+ @distributed_trace
1674
+ @api_version_validation(
1675
+ params_added_on={"2024-10-01-preview": ["filter", "skip", "top", "orderby"]},
1676
+ api_versions_list=["2024-03-01-preview", "2024-10-01-preview", "2025-09-01-preview", "2025-12-01-preview"],
1677
+ )
1678
+ def jobs_list(
1679
+ self,
1680
+ subscription_id: str,
1681
+ resource_group_name: str,
1682
+ workspace_name: str,
1683
+ session_id: str,
1684
+ *,
1685
+ filter: Optional[str] = None,
1686
+ skip: Optional[int] = None,
1687
+ top: Optional[int] = None,
1688
+ orderby: Optional[str] = None,
1689
+ **kwargs: Any
1690
+ ) -> AsyncItemPaged["_models.JobDetails"]:
1691
+ """List jobs in a session.
1692
+
1693
+ :param subscription_id: The Azure subscription ID. Required.
1694
+ :type subscription_id: str
1695
+ :param resource_group_name: Name of the Azure resource group. Required.
1696
+ :type resource_group_name: str
1697
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1698
+ :type workspace_name: str
1699
+ :param session_id: Id of the session to list jobs from. Required.
1700
+ :type session_id: str
1701
+ :keyword filter: Filter the result list using the given expression. Default value is None.
1702
+ :paramtype filter: str
1703
+ :keyword skip: The number of result items to skip. Default value is None.
1704
+ :paramtype skip: int
1705
+ :keyword top: The number of jobs taken. Default value is None.
1706
+ :paramtype top: int
1707
+ :keyword orderby: The order of returned items. Default value is None.
1708
+ :paramtype orderby: str
1709
+ :return: An iterator like instance of JobDetails
1710
+ :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum.models.JobDetails]
1711
+ :raises ~azure.core.exceptions.HttpResponseError:
1712
+ """
1713
+ _headers = kwargs.pop("headers", {}) or {}
1714
+ _params = kwargs.pop("params", {}) or {}
1715
+
1716
+ cls: ClsType[list[_models.JobDetails]] = kwargs.pop("cls", None)
1717
+
1718
+ error_map: MutableMapping = {
1719
+ 401: ClientAuthenticationError,
1720
+ 404: ResourceNotFoundError,
1721
+ 409: ResourceExistsError,
1722
+ 304: ResourceNotModifiedError,
1723
+ }
1724
+ error_map.update(kwargs.pop("error_map", {}) or {})
1725
+
1726
+ def prepare_request(next_link=None):
1727
+ if not next_link:
1728
+
1729
+ _request = build_services_sessions_jobs_list_request(
1730
+ subscription_id=subscription_id,
1731
+ resource_group_name=resource_group_name,
1732
+ workspace_name=workspace_name,
1733
+ session_id=session_id,
1734
+ filter=filter,
1735
+ skip=skip,
1736
+ top=top,
1737
+ orderby=orderby,
1738
+ api_version=self._config.api_version,
1739
+ headers=_headers,
1740
+ params=_params,
1741
+ )
1742
+ path_format_arguments = {
1743
+ "endpoint": self._serialize.url(
1744
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1745
+ ),
1746
+ }
1747
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1748
+
1749
+ else:
1750
+ # make call to next link with the client's api-version
1751
+ _parsed_next_link = urllib.parse.urlparse(next_link)
1752
+ _next_request_params = case_insensitive_dict(
1753
+ {
1754
+ key: [urllib.parse.quote(v) for v in value]
1755
+ for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1756
+ }
1757
+ )
1758
+ _next_request_params["api-version"] = self._config.api_version
1759
+ _request = HttpRequest(
1760
+ "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1761
+ )
1762
+ path_format_arguments = {
1763
+ "endpoint": self._serialize.url(
1764
+ "self._config.endpoint", self._config.endpoint, "str", skip_quote=True
1765
+ ),
1766
+ }
1767
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1768
+
1769
+ return _request
1770
+
1771
+ async def extract_data(pipeline_response):
1772
+ deserialized = pipeline_response.http_response.json()
1773
+ list_of_elem = _deserialize(list[_models.JobDetails], deserialized.get("value", []))
1774
+ if cls:
1775
+ list_of_elem = cls(list_of_elem) # type: ignore
1776
+ return deserialized.get("nextLink") or None, AsyncList(list_of_elem)
1777
+
1778
+ async def get_next(next_link=None):
1779
+ _request = prepare_request(next_link)
1780
+
1781
+ _stream = False
1782
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1783
+ _request, stream=_stream, **kwargs
1784
+ )
1785
+ response = pipeline_response.http_response
1786
+
1787
+ if response.status_code not in [200]:
1788
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1789
+ raise HttpResponseError(response=response)
1790
+
1791
+ return pipeline_response
1792
+
1793
+ return AsyncItemPaged(get_next, extract_data)
1794
+
1795
+
1796
+ class ServicesStorageOperations:
1797
+ """
1798
+ .. warning::
1799
+ **DO NOT** instantiate this class directly.
1800
+
1801
+ Instead, you should access the following operations through
1802
+ :class:`~azure.quantum.aio.WorkspaceClient`'s
1803
+ :attr:`storage` attribute.
1804
+ """
1805
+
1806
+ def __init__(self, *args, **kwargs) -> None:
1807
+ input_args = list(args)
1808
+ self._client: AsyncPipelineClient = input_args.pop(0) if input_args else kwargs.pop("client")
1809
+ self._config: WorkspaceClientConfiguration = input_args.pop(0) if input_args else kwargs.pop("config")
1810
+ self._serialize: Serializer = input_args.pop(0) if input_args else kwargs.pop("serializer")
1811
+ self._deserialize: Deserializer = input_args.pop(0) if input_args else kwargs.pop("deserializer")
1812
+
1813
+ @overload
1814
+ async def get_sas_uri(
1815
+ self,
1816
+ subscription_id: str,
1817
+ resource_group_name: str,
1818
+ workspace_name: str,
1819
+ blob_details: _models.BlobDetails,
1820
+ *,
1821
+ content_type: str = "application/json",
1822
+ **kwargs: Any
1823
+ ) -> _models.SasUriResponse:
1824
+ """Gets a URL with SAS token for a container/blob in the storage account associated with the
1825
+ workspace. The SAS URL can be used to upload job input and/or download job output.
1826
+
1827
+ :param subscription_id: The Azure subscription ID. Required.
1828
+ :type subscription_id: str
1829
+ :param resource_group_name: Name of the Azure resource group. Required.
1830
+ :type resource_group_name: str
1831
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1832
+ :type workspace_name: str
1833
+ :param blob_details: The details (name and container) of the blob. Required.
1834
+ :type blob_details: ~azure.quantum.models.BlobDetails
1835
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1836
+ Default value is "application/json".
1837
+ :paramtype content_type: str
1838
+ :return: SasUriResponse. The SasUriResponse is compatible with MutableMapping
1839
+ :rtype: ~azure.quantum.models.SasUriResponse
1840
+ :raises ~azure.core.exceptions.HttpResponseError:
1841
+ """
1842
+
1843
+ @overload
1844
+ async def get_sas_uri(
1845
+ self,
1846
+ subscription_id: str,
1847
+ resource_group_name: str,
1848
+ workspace_name: str,
1849
+ blob_details: JSON,
1850
+ *,
1851
+ content_type: str = "application/json",
1852
+ **kwargs: Any
1853
+ ) -> _models.SasUriResponse:
1854
+ """Gets a URL with SAS token for a container/blob in the storage account associated with the
1855
+ workspace. The SAS URL can be used to upload job input and/or download job output.
1856
+
1857
+ :param subscription_id: The Azure subscription ID. Required.
1858
+ :type subscription_id: str
1859
+ :param resource_group_name: Name of the Azure resource group. Required.
1860
+ :type resource_group_name: str
1861
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1862
+ :type workspace_name: str
1863
+ :param blob_details: The details (name and container) of the blob. Required.
1864
+ :type blob_details: JSON
1865
+ :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
1866
+ Default value is "application/json".
1867
+ :paramtype content_type: str
1868
+ :return: SasUriResponse. The SasUriResponse is compatible with MutableMapping
1869
+ :rtype: ~azure.quantum.models.SasUriResponse
1870
+ :raises ~azure.core.exceptions.HttpResponseError:
1871
+ """
1872
+
1873
+ @overload
1874
+ async def get_sas_uri(
1875
+ self,
1876
+ subscription_id: str,
1877
+ resource_group_name: str,
1878
+ workspace_name: str,
1879
+ blob_details: IO[bytes],
1880
+ *,
1881
+ content_type: str = "application/json",
1882
+ **kwargs: Any
1883
+ ) -> _models.SasUriResponse:
1884
+ """Gets a URL with SAS token for a container/blob in the storage account associated with the
1885
+ workspace. The SAS URL can be used to upload job input and/or download job output.
1886
+
1887
+ :param subscription_id: The Azure subscription ID. Required.
1888
+ :type subscription_id: str
1889
+ :param resource_group_name: Name of the Azure resource group. Required.
1890
+ :type resource_group_name: str
1891
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1892
+ :type workspace_name: str
1893
+ :param blob_details: The details (name and container) of the blob. Required.
1894
+ :type blob_details: IO[bytes]
1895
+ :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
1896
+ Default value is "application/json".
1897
+ :paramtype content_type: str
1898
+ :return: SasUriResponse. The SasUriResponse is compatible with MutableMapping
1899
+ :rtype: ~azure.quantum.models.SasUriResponse
1900
+ :raises ~azure.core.exceptions.HttpResponseError:
1901
+ """
1902
+
1903
+ @distributed_trace_async
1904
+ async def get_sas_uri(
1905
+ self,
1906
+ subscription_id: str,
1907
+ resource_group_name: str,
1908
+ workspace_name: str,
1909
+ blob_details: Union[_models.BlobDetails, JSON, IO[bytes]],
1910
+ **kwargs: Any
1911
+ ) -> _models.SasUriResponse:
1912
+ """Gets a URL with SAS token for a container/blob in the storage account associated with the
1913
+ workspace. The SAS URL can be used to upload job input and/or download job output.
1914
+
1915
+ :param subscription_id: The Azure subscription ID. Required.
1916
+ :type subscription_id: str
1917
+ :param resource_group_name: Name of the Azure resource group. Required.
1918
+ :type resource_group_name: str
1919
+ :param workspace_name: Name of the Azure Quantum workspace. Required.
1920
+ :type workspace_name: str
1921
+ :param blob_details: The details (name and container) of the blob. Is one of the following
1922
+ types: BlobDetails, JSON, IO[bytes] Required.
1923
+ :type blob_details: ~azure.quantum.models.BlobDetails or JSON or IO[bytes]
1924
+ :return: SasUriResponse. The SasUriResponse is compatible with MutableMapping
1925
+ :rtype: ~azure.quantum.models.SasUriResponse
1926
+ :raises ~azure.core.exceptions.HttpResponseError:
1927
+ """
1928
+ error_map: MutableMapping = {
1929
+ 401: ClientAuthenticationError,
1930
+ 404: ResourceNotFoundError,
1931
+ 409: ResourceExistsError,
1932
+ 304: ResourceNotModifiedError,
1933
+ }
1934
+ error_map.update(kwargs.pop("error_map", {}) or {})
1935
+
1936
+ _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1937
+ _params = kwargs.pop("params", {}) or {}
1938
+
1939
+ content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1940
+ cls: ClsType[_models.SasUriResponse] = kwargs.pop("cls", None)
1941
+
1942
+ content_type = content_type or "application/json"
1943
+ _content = None
1944
+ if isinstance(blob_details, (IOBase, bytes)):
1945
+ _content = blob_details
1946
+ else:
1947
+ _content = json.dumps(blob_details, cls=SdkJSONEncoder, exclude_readonly=True) # type: ignore
1948
+
1949
+ _request = build_services_storage_get_sas_uri_request(
1950
+ subscription_id=subscription_id,
1951
+ resource_group_name=resource_group_name,
1952
+ workspace_name=workspace_name,
1953
+ content_type=content_type,
1954
+ api_version=self._config.api_version,
1955
+ content=_content,
1956
+ headers=_headers,
1957
+ params=_params,
1958
+ )
1959
+ path_format_arguments = {
1960
+ "endpoint": self._serialize.url("self._config.endpoint", self._config.endpoint, "str", skip_quote=True),
1961
+ }
1962
+ _request.url = self._client.format_url(_request.url, **path_format_arguments)
1963
+
1964
+ _stream = kwargs.pop("stream", False)
1965
+ pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1966
+ _request, stream=_stream, **kwargs
1967
+ )
1968
+
1969
+ response = pipeline_response.http_response
1970
+
1971
+ if response.status_code not in [200]:
1972
+ if _stream:
1973
+ try:
1974
+ await response.read() # Load the body in memory and close the socket
1975
+ except (StreamConsumedError, StreamClosedError):
1976
+ pass
1977
+ map_error(status_code=response.status_code, response=response, error_map=error_map)
1978
+ raise HttpResponseError(response=response)
1979
+
1980
+ if _stream:
1981
+ deserialized = response.iter_bytes()
1982
+ else:
1983
+ deserialized = _deserialize(_models.SasUriResponse, response.json())
1984
+
1985
+ if cls:
1986
+ return cls(pipeline_response, deserialized, {}) # type: ignore
1987
+
1988
+ return deserialized # type: ignore