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