azure-quantum 0.30.0__py3-none-any.whl → 1.0.0__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 (55) hide show
  1. azure/quantum/_client/_version.py +1 -1
  2. azure/quantum/cirq/service.py +7 -0
  3. azure/quantum/cirq/targets/quantinuum.py +1 -1
  4. azure/quantum/job/job.py +15 -1
  5. azure/quantum/qiskit/backends/backend.py +130 -35
  6. azure/quantum/qiskit/backends/ionq.py +65 -5
  7. azure/quantum/qiskit/backends/qci.py +35 -2
  8. azure/quantum/qiskit/backends/quantinuum.py +25 -4
  9. azure/quantum/qiskit/backends/rigetti.py +8 -1
  10. azure/quantum/qiskit/job.py +7 -16
  11. azure/quantum/qiskit/provider.py +18 -2
  12. azure/quantum/target/ionq.py +37 -12
  13. azure/quantum/target/microsoft/elements/dft/target.py +13 -1
  14. azure/quantum/target/microsoft/target.py +36 -9
  15. azure/quantum/target/params.py +1 -1
  16. azure/quantum/target/pasqal/target.py +16 -2
  17. azure/quantum/target/quantinuum.py +34 -9
  18. azure/quantum/target/rigetti/target.py +15 -2
  19. azure/quantum/target/solvers.py +7 -1
  20. azure/quantum/target/target.py +82 -0
  21. azure/quantum/target/target_factory.py +0 -2
  22. azure/quantum/version.py +1 -1
  23. azure/quantum/workspace.py +11 -8
  24. {azure_quantum-0.30.0.dist-info → azure_quantum-1.0.0.dist-info}/METADATA +3 -5
  25. {azure_quantum-0.30.0.dist-info → azure_quantum-1.0.0.dist-info}/RECORD +27 -55
  26. azure/quantum/_client/aio/__init__.py +0 -23
  27. azure/quantum/_client/aio/_client.py +0 -124
  28. azure/quantum/_client/aio/_configuration.py +0 -89
  29. azure/quantum/_client/aio/_patch.py +0 -20
  30. azure/quantum/_client/aio/operations/__init__.py +0 -29
  31. azure/quantum/_client/aio/operations/_operations.py +0 -1291
  32. azure/quantum/_client/aio/operations/_patch.py +0 -20
  33. azure/quantum/aio/__init__.py +0 -14
  34. azure/quantum/aio/_authentication/__init__.py +0 -9
  35. azure/quantum/aio/_authentication/_chained.py +0 -94
  36. azure/quantum/aio/_authentication/_default.py +0 -212
  37. azure/quantum/aio/_authentication/_token.py +0 -81
  38. azure/quantum/aio/job/__init__.py +0 -1
  39. azure/quantum/aio/job/base_job.py +0 -326
  40. azure/quantum/aio/job/job.py +0 -104
  41. azure/quantum/aio/optimization/__init__.py +0 -11
  42. azure/quantum/aio/optimization/online_problem.py +0 -17
  43. azure/quantum/aio/optimization/problem.py +0 -102
  44. azure/quantum/aio/optimization/streaming_problem.py +0 -280
  45. azure/quantum/aio/storage.py +0 -390
  46. azure/quantum/aio/target/__init__.py +0 -19
  47. azure/quantum/aio/target/ionq.py +0 -47
  48. azure/quantum/aio/target/quantinuum.py +0 -47
  49. azure/quantum/aio/target/solvers.py +0 -96
  50. azure/quantum/aio/target/target.py +0 -68
  51. azure/quantum/aio/target/target_factory.py +0 -72
  52. azure/quantum/aio/target/toshiba.py +0 -6
  53. azure/quantum/aio/workspace.py +0 -337
  54. {azure_quantum-0.30.0.dist-info → azure_quantum-1.0.0.dist-info}/WHEEL +0 -0
  55. {azure_quantum-0.30.0.dist-info → azure_quantum-1.0.0.dist-info}/top_level.txt +0 -0
@@ -1,1291 +0,0 @@
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) AutoRest Code Generator.
7
- # Changes may cause incorrect behavior and will be lost if the code is regenerated.
8
- # --------------------------------------------------------------------------
9
- from typing import Any, AsyncIterable, Callable, Dict, IO, List, Optional, TypeVar, Union, overload
10
- import urllib.parse
11
-
12
- from azure.core.async_paging import AsyncItemPaged, AsyncList
13
- from azure.core.exceptions import (
14
- ClientAuthenticationError,
15
- HttpResponseError,
16
- ResourceExistsError,
17
- ResourceNotFoundError,
18
- ResourceNotModifiedError,
19
- map_error,
20
- )
21
- from azure.core.pipeline import PipelineResponse
22
- from azure.core.pipeline.transport import AsyncHttpResponse
23
- from azure.core.rest import HttpRequest
24
- from azure.core.tracing.decorator import distributed_trace
25
- from azure.core.tracing.decorator_async import distributed_trace_async
26
- from azure.core.utils import case_insensitive_dict
27
-
28
- from ... import models as _models
29
- from ...operations._operations import (
30
- build_jobs_cancel_request,
31
- build_jobs_create_request,
32
- build_jobs_get_request,
33
- build_jobs_list_request,
34
- build_jobs_patch_request,
35
- build_providers_get_status_request,
36
- build_quotas_list_request,
37
- build_sessions_close_request,
38
- build_sessions_get_request,
39
- build_sessions_jobs_list_request,
40
- build_sessions_list_request,
41
- build_sessions_open_request,
42
- build_storage_sas_uri_request,
43
- build_top_level_items_list_request,
44
- )
45
-
46
- T = TypeVar("T")
47
- ClsType = Optional[Callable[[PipelineResponse[HttpRequest, AsyncHttpResponse], T, Dict[str, Any]], Any]]
48
-
49
-
50
- class JobsOperations:
51
- """
52
- .. warning::
53
- **DO NOT** instantiate this class directly.
54
-
55
- Instead, you should access the following operations through
56
- :class:`~azure.quantum._client.aio.QuantumClient`'s
57
- :attr:`jobs` attribute.
58
- """
59
-
60
- models = _models
61
-
62
- def __init__(self, *args, **kwargs) -> None:
63
- input_args = list(args)
64
- self._client = input_args.pop(0) if input_args else kwargs.pop("client")
65
- self._config = input_args.pop(0) if input_args else kwargs.pop("config")
66
- self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
67
- self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
68
-
69
- @distributed_trace
70
- def list(self, **kwargs: Any) -> AsyncIterable["_models.JobDetails"]:
71
- """List jobs.
72
-
73
- :return: An iterator like instance of JobDetails
74
- :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.JobDetails]
75
- :raises ~azure.core.exceptions.HttpResponseError:
76
- """
77
- _headers = kwargs.pop("headers", {}) or {}
78
- _params = kwargs.pop("params", {}) or {}
79
-
80
- cls: ClsType[_models._models.JobDetailsList] = kwargs.pop("cls", None) # pylint: disable=protected-access
81
-
82
- error_map = {
83
- 401: ClientAuthenticationError,
84
- 404: ResourceNotFoundError,
85
- 409: ResourceExistsError,
86
- 304: ResourceNotModifiedError,
87
- }
88
- error_map.update(kwargs.pop("error_map", {}) or {})
89
-
90
- def prepare_request(next_link=None):
91
- if not next_link:
92
-
93
- request = build_jobs_list_request(
94
- subscription_id=self._config.subscription_id,
95
- resource_group_name=self._config.resource_group_name,
96
- workspace_name=self._config.workspace_name,
97
- api_version=self._config.api_version,
98
- headers=_headers,
99
- params=_params,
100
- )
101
- request.url = self._client.format_url(request.url)
102
-
103
- else:
104
- # make call to next link with the client's api-version
105
- _parsed_next_link = urllib.parse.urlparse(next_link)
106
- _next_request_params = case_insensitive_dict(
107
- {
108
- key: [urllib.parse.quote(v) for v in value]
109
- for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
110
- }
111
- )
112
- _next_request_params["api-version"] = self._config.api_version
113
- request = HttpRequest(
114
- "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
115
- )
116
- request.url = self._client.format_url(request.url)
117
-
118
- return request
119
-
120
- async def extract_data(pipeline_response):
121
- deserialized = self._deserialize(
122
- _models._models.JobDetailsList, pipeline_response # pylint: disable=protected-access
123
- )
124
- list_of_elem = deserialized.value
125
- if cls:
126
- list_of_elem = cls(list_of_elem) # type: ignore
127
- return deserialized.next_link or None, AsyncList(list_of_elem)
128
-
129
- async def get_next(next_link=None):
130
- request = prepare_request(next_link)
131
-
132
- _stream = False
133
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
134
- request, stream=_stream, **kwargs
135
- )
136
- response = pipeline_response.http_response
137
-
138
- if response.status_code not in [200]:
139
- map_error(status_code=response.status_code, response=response, error_map=error_map)
140
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
141
- raise HttpResponseError(response=response, model=error)
142
-
143
- return pipeline_response
144
-
145
- return AsyncItemPaged(get_next, extract_data)
146
-
147
- @distributed_trace_async
148
- async def get(self, job_id: str, **kwargs: Any) -> _models.JobDetails:
149
- """Get job by id.
150
-
151
- :param job_id: Id of the job. Required.
152
- :type job_id: str
153
- :return: JobDetails
154
- :rtype: ~azure.quantum._client.models.JobDetails
155
- :raises ~azure.core.exceptions.HttpResponseError:
156
- """
157
- error_map = {
158
- 401: ClientAuthenticationError,
159
- 404: ResourceNotFoundError,
160
- 409: ResourceExistsError,
161
- 304: ResourceNotModifiedError,
162
- }
163
- error_map.update(kwargs.pop("error_map", {}) or {})
164
-
165
- _headers = kwargs.pop("headers", {}) or {}
166
- _params = kwargs.pop("params", {}) or {}
167
-
168
- cls: ClsType[_models.JobDetails] = kwargs.pop("cls", None)
169
-
170
- request = build_jobs_get_request(
171
- job_id=job_id,
172
- subscription_id=self._config.subscription_id,
173
- resource_group_name=self._config.resource_group_name,
174
- workspace_name=self._config.workspace_name,
175
- api_version=self._config.api_version,
176
- headers=_headers,
177
- params=_params,
178
- )
179
- request.url = self._client.format_url(request.url)
180
-
181
- _stream = False
182
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
183
- request, stream=_stream, **kwargs
184
- )
185
-
186
- response = pipeline_response.http_response
187
-
188
- if response.status_code not in [200]:
189
- map_error(status_code=response.status_code, response=response, error_map=error_map)
190
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
191
- raise HttpResponseError(response=response, model=error)
192
-
193
- deserialized = self._deserialize("JobDetails", pipeline_response)
194
-
195
- if cls:
196
- return cls(pipeline_response, deserialized, {})
197
-
198
- return deserialized
199
-
200
- @overload
201
- async def create(
202
- self, job_id: str, job: _models.JobDetails, *, content_type: str = "application/json", **kwargs: Any
203
- ) -> _models.JobDetails:
204
- """Create a job.
205
-
206
- :param job_id: Id of the job. Required.
207
- :type job_id: str
208
- :param job: The complete metadata of the job to submit. Required.
209
- :type job: ~azure.quantum._client.models.JobDetails
210
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
211
- Default value is "application/json".
212
- :paramtype content_type: str
213
- :return: JobDetails
214
- :rtype: ~azure.quantum._client.models.JobDetails
215
- :raises ~azure.core.exceptions.HttpResponseError:
216
- """
217
-
218
- @overload
219
- async def create(
220
- self, job_id: str, job: IO, *, content_type: str = "application/json", **kwargs: Any
221
- ) -> _models.JobDetails:
222
- """Create a job.
223
-
224
- :param job_id: Id of the job. Required.
225
- :type job_id: str
226
- :param job: The complete metadata of the job to submit. Required.
227
- :type job: IO
228
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
229
- Default value is "application/json".
230
- :paramtype content_type: str
231
- :return: JobDetails
232
- :rtype: ~azure.quantum._client.models.JobDetails
233
- :raises ~azure.core.exceptions.HttpResponseError:
234
- """
235
-
236
- @distributed_trace_async
237
- async def create(self, job_id: str, job: Union[_models.JobDetails, IO], **kwargs: Any) -> _models.JobDetails:
238
- """Create a job.
239
-
240
- :param job_id: Id of the job. Required.
241
- :type job_id: str
242
- :param job: The complete metadata of the job to submit. Is either a JobDetails type or a IO
243
- type. Required.
244
- :type job: ~azure.quantum._client.models.JobDetails or IO
245
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
246
- Default value is None.
247
- :paramtype content_type: str
248
- :return: JobDetails
249
- :rtype: ~azure.quantum._client.models.JobDetails
250
- :raises ~azure.core.exceptions.HttpResponseError:
251
- """
252
- error_map = {
253
- 401: ClientAuthenticationError,
254
- 404: ResourceNotFoundError,
255
- 409: ResourceExistsError,
256
- 304: ResourceNotModifiedError,
257
- }
258
- error_map.update(kwargs.pop("error_map", {}) or {})
259
-
260
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
261
- _params = kwargs.pop("params", {}) or {}
262
-
263
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
264
- cls: ClsType[_models.JobDetails] = kwargs.pop("cls", None)
265
-
266
- content_type = content_type or "application/json"
267
- _json = None
268
- _content = None
269
- if isinstance(job, (IO, bytes)):
270
- _content = job
271
- else:
272
- _json = self._serialize.body(job, "JobDetails")
273
-
274
- request = build_jobs_create_request(
275
- job_id=job_id,
276
- subscription_id=self._config.subscription_id,
277
- resource_group_name=self._config.resource_group_name,
278
- workspace_name=self._config.workspace_name,
279
- content_type=content_type,
280
- api_version=self._config.api_version,
281
- json=_json,
282
- content=_content,
283
- headers=_headers,
284
- params=_params,
285
- )
286
- request.url = self._client.format_url(request.url)
287
-
288
- _stream = False
289
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
290
- request, stream=_stream, **kwargs
291
- )
292
-
293
- response = pipeline_response.http_response
294
-
295
- if response.status_code not in [200, 201]:
296
- map_error(status_code=response.status_code, response=response, error_map=error_map)
297
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
298
- raise HttpResponseError(response=response, model=error)
299
-
300
- if response.status_code == 200:
301
- deserialized = self._deserialize("JobDetails", pipeline_response)
302
-
303
- if response.status_code == 201:
304
- deserialized = self._deserialize("JobDetails", pipeline_response)
305
-
306
- if cls:
307
- return cls(pipeline_response, deserialized, {}) # type: ignore
308
-
309
- return deserialized # type: ignore
310
-
311
- @distributed_trace_async
312
- async def cancel(self, job_id: str, **kwargs: Any) -> None: # pylint: disable=inconsistent-return-statements
313
- """Cancel a job.
314
-
315
- :param job_id: Id of the job. Required.
316
- :type job_id: str
317
- :return: None
318
- :rtype: None
319
- :raises ~azure.core.exceptions.HttpResponseError:
320
- """
321
- error_map = {
322
- 401: ClientAuthenticationError,
323
- 404: ResourceNotFoundError,
324
- 409: ResourceExistsError,
325
- 304: ResourceNotModifiedError,
326
- }
327
- error_map.update(kwargs.pop("error_map", {}) or {})
328
-
329
- _headers = kwargs.pop("headers", {}) or {}
330
- _params = kwargs.pop("params", {}) or {}
331
-
332
- cls: ClsType[None] = kwargs.pop("cls", None)
333
-
334
- request = build_jobs_cancel_request(
335
- job_id=job_id,
336
- subscription_id=self._config.subscription_id,
337
- resource_group_name=self._config.resource_group_name,
338
- workspace_name=self._config.workspace_name,
339
- api_version=self._config.api_version,
340
- headers=_headers,
341
- params=_params,
342
- )
343
- request.url = self._client.format_url(request.url)
344
-
345
- _stream = False
346
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
347
- request, stream=_stream, **kwargs
348
- )
349
-
350
- response = pipeline_response.http_response
351
-
352
- if response.status_code not in [204]:
353
- map_error(status_code=response.status_code, response=response, error_map=error_map)
354
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
355
- raise HttpResponseError(response=response, model=error)
356
-
357
- if cls:
358
- return cls(pipeline_response, None, {})
359
-
360
- @overload
361
- async def patch(
362
- self,
363
- job_id: str,
364
- patch_job: List[_models.JsonPatchDocument],
365
- *,
366
- content_type: str = "application/json",
367
- **kwargs: Any
368
- ) -> Optional[_models.JobDetails]:
369
- """Patch a job.
370
-
371
- :param job_id: Id of the job. Required.
372
- :type job_id: str
373
- :param patch_job: The json patch document containing the patch operations. Required.
374
- :type patch_job: list[~azure.quantum._client.models.JsonPatchDocument]
375
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
376
- Default value is "application/json".
377
- :paramtype content_type: str
378
- :return: JobDetails or None
379
- :rtype: ~azure.quantum._client.models.JobDetails or None
380
- :raises ~azure.core.exceptions.HttpResponseError:
381
- """
382
-
383
- @overload
384
- async def patch(
385
- self, job_id: str, patch_job: IO, *, content_type: str = "application/json", **kwargs: Any
386
- ) -> Optional[_models.JobDetails]:
387
- """Patch a job.
388
-
389
- :param job_id: Id of the job. Required.
390
- :type job_id: str
391
- :param patch_job: The json patch document containing the patch operations. Required.
392
- :type patch_job: IO
393
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
394
- Default value is "application/json".
395
- :paramtype content_type: str
396
- :return: JobDetails or None
397
- :rtype: ~azure.quantum._client.models.JobDetails or None
398
- :raises ~azure.core.exceptions.HttpResponseError:
399
- """
400
-
401
- @distributed_trace_async
402
- async def patch(
403
- self, job_id: str, patch_job: Union[List[_models.JsonPatchDocument], IO], **kwargs: Any
404
- ) -> Optional[_models.JobDetails]:
405
- """Patch a job.
406
-
407
- :param job_id: Id of the job. Required.
408
- :type job_id: str
409
- :param patch_job: The json patch document containing the patch operations. Is either a
410
- [JsonPatchDocument] type or a IO type. Required.
411
- :type patch_job: list[~azure.quantum._client.models.JsonPatchDocument] or IO
412
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
413
- Default value is None.
414
- :paramtype content_type: str
415
- :return: JobDetails or None
416
- :rtype: ~azure.quantum._client.models.JobDetails or None
417
- :raises ~azure.core.exceptions.HttpResponseError:
418
- """
419
- error_map = {
420
- 401: ClientAuthenticationError,
421
- 404: ResourceNotFoundError,
422
- 409: ResourceExistsError,
423
- 304: ResourceNotModifiedError,
424
- }
425
- error_map.update(kwargs.pop("error_map", {}) or {})
426
-
427
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
428
- _params = kwargs.pop("params", {}) or {}
429
-
430
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
431
- cls: ClsType[Optional[_models.JobDetails]] = kwargs.pop("cls", None)
432
-
433
- content_type = content_type or "application/json"
434
- _json = None
435
- _content = None
436
- if isinstance(patch_job, (IO, bytes)):
437
- _content = patch_job
438
- else:
439
- _json = self._serialize.body(patch_job, "[JsonPatchDocument]")
440
-
441
- request = build_jobs_patch_request(
442
- job_id=job_id,
443
- subscription_id=self._config.subscription_id,
444
- resource_group_name=self._config.resource_group_name,
445
- workspace_name=self._config.workspace_name,
446
- content_type=content_type,
447
- api_version=self._config.api_version,
448
- json=_json,
449
- content=_content,
450
- headers=_headers,
451
- params=_params,
452
- )
453
- request.url = self._client.format_url(request.url)
454
-
455
- _stream = False
456
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
457
- request, stream=_stream, **kwargs
458
- )
459
-
460
- response = pipeline_response.http_response
461
-
462
- if response.status_code not in [200, 204]:
463
- map_error(status_code=response.status_code, response=response, error_map=error_map)
464
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
465
- raise HttpResponseError(response=response, model=error)
466
-
467
- deserialized = None
468
- if response.status_code == 200:
469
- deserialized = self._deserialize("JobDetails", pipeline_response)
470
-
471
- if cls:
472
- return cls(pipeline_response, deserialized, {})
473
-
474
- return deserialized
475
-
476
-
477
- class ProvidersOperations:
478
- """
479
- .. warning::
480
- **DO NOT** instantiate this class directly.
481
-
482
- Instead, you should access the following operations through
483
- :class:`~azure.quantum._client.aio.QuantumClient`'s
484
- :attr:`providers` attribute.
485
- """
486
-
487
- models = _models
488
-
489
- def __init__(self, *args, **kwargs) -> None:
490
- input_args = list(args)
491
- self._client = input_args.pop(0) if input_args else kwargs.pop("client")
492
- self._config = input_args.pop(0) if input_args else kwargs.pop("config")
493
- self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
494
- self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
495
-
496
- @distributed_trace
497
- def get_status(self, **kwargs: Any) -> AsyncIterable["_models.ProviderStatus"]:
498
- """Get provider status.
499
-
500
- :return: An iterator like instance of ProviderStatus
501
- :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.ProviderStatus]
502
- :raises ~azure.core.exceptions.HttpResponseError:
503
- """
504
- _headers = kwargs.pop("headers", {}) or {}
505
- _params = kwargs.pop("params", {}) or {}
506
-
507
- cls: ClsType[_models._models.ProviderStatusList] = kwargs.pop("cls", None) # pylint: disable=protected-access
508
-
509
- error_map = {
510
- 401: ClientAuthenticationError,
511
- 404: ResourceNotFoundError,
512
- 409: ResourceExistsError,
513
- 304: ResourceNotModifiedError,
514
- }
515
- error_map.update(kwargs.pop("error_map", {}) or {})
516
-
517
- def prepare_request(next_link=None):
518
- if not next_link:
519
-
520
- request = build_providers_get_status_request(
521
- subscription_id=self._config.subscription_id,
522
- resource_group_name=self._config.resource_group_name,
523
- workspace_name=self._config.workspace_name,
524
- api_version=self._config.api_version,
525
- headers=_headers,
526
- params=_params,
527
- )
528
- request.url = self._client.format_url(request.url)
529
-
530
- else:
531
- # make call to next link with the client's api-version
532
- _parsed_next_link = urllib.parse.urlparse(next_link)
533
- _next_request_params = case_insensitive_dict(
534
- {
535
- key: [urllib.parse.quote(v) for v in value]
536
- for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
537
- }
538
- )
539
- _next_request_params["api-version"] = self._config.api_version
540
- request = HttpRequest(
541
- "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
542
- )
543
- request.url = self._client.format_url(request.url)
544
-
545
- return request
546
-
547
- async def extract_data(pipeline_response):
548
- deserialized = self._deserialize(
549
- _models._models.ProviderStatusList, pipeline_response # pylint: disable=protected-access
550
- )
551
- list_of_elem = deserialized.value
552
- if cls:
553
- list_of_elem = cls(list_of_elem) # type: ignore
554
- return deserialized.next_link or None, AsyncList(list_of_elem)
555
-
556
- async def get_next(next_link=None):
557
- request = prepare_request(next_link)
558
-
559
- _stream = False
560
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
561
- request, stream=_stream, **kwargs
562
- )
563
- response = pipeline_response.http_response
564
-
565
- if response.status_code not in [200]:
566
- map_error(status_code=response.status_code, response=response, error_map=error_map)
567
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
568
- raise HttpResponseError(response=response, model=error)
569
-
570
- return pipeline_response
571
-
572
- return AsyncItemPaged(get_next, extract_data)
573
-
574
-
575
- class StorageOperations:
576
- """
577
- .. warning::
578
- **DO NOT** instantiate this class directly.
579
-
580
- Instead, you should access the following operations through
581
- :class:`~azure.quantum._client.aio.QuantumClient`'s
582
- :attr:`storage` attribute.
583
- """
584
-
585
- models = _models
586
-
587
- def __init__(self, *args, **kwargs) -> None:
588
- input_args = list(args)
589
- self._client = input_args.pop(0) if input_args else kwargs.pop("client")
590
- self._config = input_args.pop(0) if input_args else kwargs.pop("config")
591
- self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
592
- self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
593
-
594
- @overload
595
- async def sas_uri(
596
- self, blob_details: _models.BlobDetails, *, content_type: str = "application/json", **kwargs: Any
597
- ) -> _models.SasUriResponse:
598
- """Gets a URL with SAS token for a container/blob in the storage account associated with the
599
- workspace. The SAS URL can be used to upload job input and/or download job output.
600
-
601
- :param blob_details: The details (name and container) of the blob to store or download data.
602
- Required.
603
- :type blob_details: ~azure.quantum._client.models.BlobDetails
604
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
605
- Default value is "application/json".
606
- :paramtype content_type: str
607
- :return: SasUriResponse
608
- :rtype: ~azure.quantum._client.models.SasUriResponse
609
- :raises ~azure.core.exceptions.HttpResponseError:
610
- """
611
-
612
- @overload
613
- async def sas_uri(
614
- self, blob_details: IO, *, content_type: str = "application/json", **kwargs: Any
615
- ) -> _models.SasUriResponse:
616
- """Gets a URL with SAS token for a container/blob in the storage account associated with the
617
- workspace. The SAS URL can be used to upload job input and/or download job output.
618
-
619
- :param blob_details: The details (name and container) of the blob to store or download data.
620
- Required.
621
- :type blob_details: IO
622
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
623
- Default value is "application/json".
624
- :paramtype content_type: str
625
- :return: SasUriResponse
626
- :rtype: ~azure.quantum._client.models.SasUriResponse
627
- :raises ~azure.core.exceptions.HttpResponseError:
628
- """
629
-
630
- @distributed_trace_async
631
- async def sas_uri(self, blob_details: Union[_models.BlobDetails, IO], **kwargs: Any) -> _models.SasUriResponse:
632
- """Gets a URL with SAS token for a container/blob in the storage account associated with the
633
- workspace. The SAS URL can be used to upload job input and/or download job output.
634
-
635
- :param blob_details: The details (name and container) of the blob to store or download data. Is
636
- either a BlobDetails type or a IO type. Required.
637
- :type blob_details: ~azure.quantum._client.models.BlobDetails or IO
638
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
639
- Default value is None.
640
- :paramtype content_type: str
641
- :return: SasUriResponse
642
- :rtype: ~azure.quantum._client.models.SasUriResponse
643
- :raises ~azure.core.exceptions.HttpResponseError:
644
- """
645
- error_map = {
646
- 401: ClientAuthenticationError,
647
- 404: ResourceNotFoundError,
648
- 409: ResourceExistsError,
649
- 304: ResourceNotModifiedError,
650
- }
651
- error_map.update(kwargs.pop("error_map", {}) or {})
652
-
653
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
654
- _params = kwargs.pop("params", {}) or {}
655
-
656
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
657
- cls: ClsType[_models.SasUriResponse] = kwargs.pop("cls", None)
658
-
659
- content_type = content_type or "application/json"
660
- _json = None
661
- _content = None
662
- if isinstance(blob_details, (IO, bytes)):
663
- _content = blob_details
664
- else:
665
- _json = self._serialize.body(blob_details, "BlobDetails")
666
-
667
- request = build_storage_sas_uri_request(
668
- subscription_id=self._config.subscription_id,
669
- resource_group_name=self._config.resource_group_name,
670
- workspace_name=self._config.workspace_name,
671
- content_type=content_type,
672
- api_version=self._config.api_version,
673
- json=_json,
674
- content=_content,
675
- headers=_headers,
676
- params=_params,
677
- )
678
- request.url = self._client.format_url(request.url)
679
-
680
- _stream = False
681
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
682
- request, stream=_stream, **kwargs
683
- )
684
-
685
- response = pipeline_response.http_response
686
-
687
- if response.status_code not in [200]:
688
- map_error(status_code=response.status_code, response=response, error_map=error_map)
689
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
690
- raise HttpResponseError(response=response, model=error)
691
-
692
- deserialized = self._deserialize("SasUriResponse", pipeline_response)
693
-
694
- if cls:
695
- return cls(pipeline_response, deserialized, {})
696
-
697
- return deserialized
698
-
699
-
700
- class QuotasOperations:
701
- """
702
- .. warning::
703
- **DO NOT** instantiate this class directly.
704
-
705
- Instead, you should access the following operations through
706
- :class:`~azure.quantum._client.aio.QuantumClient`'s
707
- :attr:`quotas` attribute.
708
- """
709
-
710
- models = _models
711
-
712
- def __init__(self, *args, **kwargs) -> None:
713
- input_args = list(args)
714
- self._client = input_args.pop(0) if input_args else kwargs.pop("client")
715
- self._config = input_args.pop(0) if input_args else kwargs.pop("config")
716
- self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
717
- self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
718
-
719
- @distributed_trace
720
- def list(self, **kwargs: Any) -> AsyncIterable["_models.Quota"]:
721
- """List quotas for the given workspace.
722
-
723
- :return: An iterator like instance of Quota
724
- :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.Quota]
725
- :raises ~azure.core.exceptions.HttpResponseError:
726
- """
727
- _headers = kwargs.pop("headers", {}) or {}
728
- _params = kwargs.pop("params", {}) or {}
729
-
730
- cls: ClsType[_models._models.QuotaList] = kwargs.pop("cls", None) # pylint: disable=protected-access
731
-
732
- error_map = {
733
- 401: ClientAuthenticationError,
734
- 404: ResourceNotFoundError,
735
- 409: ResourceExistsError,
736
- 304: ResourceNotModifiedError,
737
- }
738
- error_map.update(kwargs.pop("error_map", {}) or {})
739
-
740
- def prepare_request(next_link=None):
741
- if not next_link:
742
-
743
- request = build_quotas_list_request(
744
- subscription_id=self._config.subscription_id,
745
- resource_group_name=self._config.resource_group_name,
746
- workspace_name=self._config.workspace_name,
747
- api_version=self._config.api_version,
748
- headers=_headers,
749
- params=_params,
750
- )
751
- request.url = self._client.format_url(request.url)
752
-
753
- else:
754
- # make call to next link with the client's api-version
755
- _parsed_next_link = urllib.parse.urlparse(next_link)
756
- _next_request_params = case_insensitive_dict(
757
- {
758
- key: [urllib.parse.quote(v) for v in value]
759
- for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
760
- }
761
- )
762
- _next_request_params["api-version"] = self._config.api_version
763
- request = HttpRequest(
764
- "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
765
- )
766
- request.url = self._client.format_url(request.url)
767
-
768
- return request
769
-
770
- async def extract_data(pipeline_response):
771
- deserialized = self._deserialize(
772
- _models._models.QuotaList, pipeline_response # pylint: disable=protected-access
773
- )
774
- list_of_elem = deserialized.value
775
- if cls:
776
- list_of_elem = cls(list_of_elem) # type: ignore
777
- return deserialized.next_link or None, AsyncList(list_of_elem)
778
-
779
- async def get_next(next_link=None):
780
- request = prepare_request(next_link)
781
-
782
- _stream = False
783
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
784
- request, stream=_stream, **kwargs
785
- )
786
- response = pipeline_response.http_response
787
-
788
- if response.status_code not in [200]:
789
- map_error(status_code=response.status_code, response=response, error_map=error_map)
790
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
791
- raise HttpResponseError(response=response, model=error)
792
-
793
- return pipeline_response
794
-
795
- return AsyncItemPaged(get_next, extract_data)
796
-
797
-
798
- class SessionsOperations:
799
- """
800
- .. warning::
801
- **DO NOT** instantiate this class directly.
802
-
803
- Instead, you should access the following operations through
804
- :class:`~azure.quantum._client.aio.QuantumClient`'s
805
- :attr:`sessions` attribute.
806
- """
807
-
808
- models = _models
809
-
810
- def __init__(self, *args, **kwargs) -> None:
811
- input_args = list(args)
812
- self._client = input_args.pop(0) if input_args else kwargs.pop("client")
813
- self._config = input_args.pop(0) if input_args else kwargs.pop("config")
814
- self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
815
- self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
816
-
817
- @distributed_trace
818
- def list(self, **kwargs: Any) -> AsyncIterable["_models.SessionDetails"]:
819
- """List sessions.
820
-
821
- :return: An iterator like instance of SessionDetails
822
- :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.SessionDetails]
823
- :raises ~azure.core.exceptions.HttpResponseError:
824
- """
825
- _headers = kwargs.pop("headers", {}) or {}
826
- _params = kwargs.pop("params", {}) or {}
827
-
828
- cls: ClsType[_models._models.SessionDetailsList] = kwargs.pop("cls", None) # pylint: disable=protected-access
829
-
830
- error_map = {
831
- 401: ClientAuthenticationError,
832
- 404: ResourceNotFoundError,
833
- 409: ResourceExistsError,
834
- 304: ResourceNotModifiedError,
835
- }
836
- error_map.update(kwargs.pop("error_map", {}) or {})
837
-
838
- def prepare_request(next_link=None):
839
- if not next_link:
840
-
841
- request = build_sessions_list_request(
842
- subscription_id=self._config.subscription_id,
843
- resource_group_name=self._config.resource_group_name,
844
- workspace_name=self._config.workspace_name,
845
- api_version=self._config.api_version,
846
- headers=_headers,
847
- params=_params,
848
- )
849
- request.url = self._client.format_url(request.url)
850
-
851
- else:
852
- # make call to next link with the client's api-version
853
- _parsed_next_link = urllib.parse.urlparse(next_link)
854
- _next_request_params = case_insensitive_dict(
855
- {
856
- key: [urllib.parse.quote(v) for v in value]
857
- for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
858
- }
859
- )
860
- _next_request_params["api-version"] = self._config.api_version
861
- request = HttpRequest(
862
- "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
863
- )
864
- request.url = self._client.format_url(request.url)
865
-
866
- return request
867
-
868
- async def extract_data(pipeline_response):
869
- deserialized = self._deserialize(
870
- _models._models.SessionDetailsList, pipeline_response # pylint: disable=protected-access
871
- )
872
- list_of_elem = deserialized.value
873
- if cls:
874
- list_of_elem = cls(list_of_elem) # type: ignore
875
- return deserialized.next_link or None, AsyncList(list_of_elem)
876
-
877
- async def get_next(next_link=None):
878
- request = prepare_request(next_link)
879
-
880
- _stream = False
881
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
882
- request, stream=_stream, **kwargs
883
- )
884
- response = pipeline_response.http_response
885
-
886
- if response.status_code not in [200]:
887
- map_error(status_code=response.status_code, response=response, error_map=error_map)
888
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
889
- raise HttpResponseError(response=response, model=error)
890
-
891
- return pipeline_response
892
-
893
- return AsyncItemPaged(get_next, extract_data)
894
-
895
- @distributed_trace_async
896
- async def get(self, session_id: str, **kwargs: Any) -> _models.SessionDetails:
897
- """Get session by id.
898
-
899
- :param session_id: Id of the session. Required.
900
- :type session_id: str
901
- :return: SessionDetails
902
- :rtype: ~azure.quantum._client.models.SessionDetails
903
- :raises ~azure.core.exceptions.HttpResponseError:
904
- """
905
- error_map = {
906
- 401: ClientAuthenticationError,
907
- 404: ResourceNotFoundError,
908
- 409: ResourceExistsError,
909
- 304: ResourceNotModifiedError,
910
- }
911
- error_map.update(kwargs.pop("error_map", {}) or {})
912
-
913
- _headers = kwargs.pop("headers", {}) or {}
914
- _params = kwargs.pop("params", {}) or {}
915
-
916
- cls: ClsType[_models.SessionDetails] = kwargs.pop("cls", None)
917
-
918
- request = build_sessions_get_request(
919
- session_id=session_id,
920
- subscription_id=self._config.subscription_id,
921
- resource_group_name=self._config.resource_group_name,
922
- workspace_name=self._config.workspace_name,
923
- api_version=self._config.api_version,
924
- headers=_headers,
925
- params=_params,
926
- )
927
- request.url = self._client.format_url(request.url)
928
-
929
- _stream = False
930
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
931
- request, stream=_stream, **kwargs
932
- )
933
-
934
- response = pipeline_response.http_response
935
-
936
- if response.status_code not in [200]:
937
- map_error(status_code=response.status_code, response=response, error_map=error_map)
938
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
939
- raise HttpResponseError(response=response, model=error)
940
-
941
- deserialized = self._deserialize("SessionDetails", pipeline_response)
942
-
943
- if cls:
944
- return cls(pipeline_response, deserialized, {})
945
-
946
- return deserialized
947
-
948
- @overload
949
- async def open(
950
- self, session_id: str, session: _models.SessionDetails, *, content_type: str = "application/json", **kwargs: Any
951
- ) -> _models.SessionDetails:
952
- """Open a session.
953
-
954
- :param session_id: Id of the session. Required.
955
- :type session_id: str
956
- :param session: The complete metadata of the session to be opened. Required.
957
- :type session: ~azure.quantum._client.models.SessionDetails
958
- :keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
959
- Default value is "application/json".
960
- :paramtype content_type: str
961
- :return: SessionDetails
962
- :rtype: ~azure.quantum._client.models.SessionDetails
963
- :raises ~azure.core.exceptions.HttpResponseError:
964
- """
965
-
966
- @overload
967
- async def open(
968
- self, session_id: str, session: IO, *, content_type: str = "application/json", **kwargs: Any
969
- ) -> _models.SessionDetails:
970
- """Open a session.
971
-
972
- :param session_id: Id of the session. Required.
973
- :type session_id: str
974
- :param session: The complete metadata of the session to be opened. Required.
975
- :type session: IO
976
- :keyword content_type: Body Parameter content-type. Content type parameter for binary body.
977
- Default value is "application/json".
978
- :paramtype content_type: str
979
- :return: SessionDetails
980
- :rtype: ~azure.quantum._client.models.SessionDetails
981
- :raises ~azure.core.exceptions.HttpResponseError:
982
- """
983
-
984
- @distributed_trace_async
985
- async def open(
986
- self, session_id: str, session: Union[_models.SessionDetails, IO], **kwargs: Any
987
- ) -> _models.SessionDetails:
988
- """Open a session.
989
-
990
- :param session_id: Id of the session. Required.
991
- :type session_id: str
992
- :param session: The complete metadata of the session to be opened. Is either a SessionDetails
993
- type or a IO type. Required.
994
- :type session: ~azure.quantum._client.models.SessionDetails or IO
995
- :keyword content_type: Body Parameter content-type. Known values are: 'application/json'.
996
- Default value is None.
997
- :paramtype content_type: str
998
- :return: SessionDetails
999
- :rtype: ~azure.quantum._client.models.SessionDetails
1000
- :raises ~azure.core.exceptions.HttpResponseError:
1001
- """
1002
- error_map = {
1003
- 401: ClientAuthenticationError,
1004
- 404: ResourceNotFoundError,
1005
- 409: ResourceExistsError,
1006
- 304: ResourceNotModifiedError,
1007
- }
1008
- error_map.update(kwargs.pop("error_map", {}) or {})
1009
-
1010
- _headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
1011
- _params = kwargs.pop("params", {}) or {}
1012
-
1013
- content_type: Optional[str] = kwargs.pop("content_type", _headers.pop("Content-Type", None))
1014
- cls: ClsType[_models.SessionDetails] = kwargs.pop("cls", None)
1015
-
1016
- content_type = content_type or "application/json"
1017
- _json = None
1018
- _content = None
1019
- if isinstance(session, (IO, bytes)):
1020
- _content = session
1021
- else:
1022
- _json = self._serialize.body(session, "SessionDetails")
1023
-
1024
- request = build_sessions_open_request(
1025
- session_id=session_id,
1026
- subscription_id=self._config.subscription_id,
1027
- resource_group_name=self._config.resource_group_name,
1028
- workspace_name=self._config.workspace_name,
1029
- content_type=content_type,
1030
- api_version=self._config.api_version,
1031
- json=_json,
1032
- content=_content,
1033
- headers=_headers,
1034
- params=_params,
1035
- )
1036
- request.url = self._client.format_url(request.url)
1037
-
1038
- _stream = False
1039
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1040
- request, stream=_stream, **kwargs
1041
- )
1042
-
1043
- response = pipeline_response.http_response
1044
-
1045
- if response.status_code not in [200, 201]:
1046
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1047
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
1048
- raise HttpResponseError(response=response, model=error)
1049
-
1050
- if response.status_code == 200:
1051
- deserialized = self._deserialize("SessionDetails", pipeline_response)
1052
-
1053
- if response.status_code == 201:
1054
- deserialized = self._deserialize("SessionDetails", pipeline_response)
1055
-
1056
- if cls:
1057
- return cls(pipeline_response, deserialized, {}) # type: ignore
1058
-
1059
- return deserialized # type: ignore
1060
-
1061
- @distributed_trace_async
1062
- async def close(self, session_id: str, **kwargs: Any) -> _models.SessionDetails:
1063
- """Close a session.
1064
-
1065
- :param session_id: Id of the session. Required.
1066
- :type session_id: str
1067
- :return: SessionDetails
1068
- :rtype: ~azure.quantum._client.models.SessionDetails
1069
- :raises ~azure.core.exceptions.HttpResponseError:
1070
- """
1071
- error_map = {
1072
- 401: ClientAuthenticationError,
1073
- 404: ResourceNotFoundError,
1074
- 409: ResourceExistsError,
1075
- 304: ResourceNotModifiedError,
1076
- }
1077
- error_map.update(kwargs.pop("error_map", {}) or {})
1078
-
1079
- _headers = kwargs.pop("headers", {}) or {}
1080
- _params = kwargs.pop("params", {}) or {}
1081
-
1082
- cls: ClsType[_models.SessionDetails] = kwargs.pop("cls", None)
1083
-
1084
- request = build_sessions_close_request(
1085
- session_id=session_id,
1086
- subscription_id=self._config.subscription_id,
1087
- resource_group_name=self._config.resource_group_name,
1088
- workspace_name=self._config.workspace_name,
1089
- api_version=self._config.api_version,
1090
- headers=_headers,
1091
- params=_params,
1092
- )
1093
- request.url = self._client.format_url(request.url)
1094
-
1095
- _stream = False
1096
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1097
- request, stream=_stream, **kwargs
1098
- )
1099
-
1100
- response = pipeline_response.http_response
1101
-
1102
- if response.status_code not in [200]:
1103
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1104
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
1105
- raise HttpResponseError(response=response, model=error)
1106
-
1107
- deserialized = self._deserialize("SessionDetails", pipeline_response)
1108
-
1109
- if cls:
1110
- return cls(pipeline_response, deserialized, {})
1111
-
1112
- return deserialized
1113
-
1114
- @distributed_trace
1115
- def jobs_list(self, session_id: str, **kwargs: Any) -> AsyncIterable["_models.JobDetails"]:
1116
- """List jobs in a session.
1117
-
1118
- :param session_id: Id of the session. Required.
1119
- :type session_id: str
1120
- :return: An iterator like instance of JobDetails
1121
- :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.JobDetails]
1122
- :raises ~azure.core.exceptions.HttpResponseError:
1123
- """
1124
- _headers = kwargs.pop("headers", {}) or {}
1125
- _params = kwargs.pop("params", {}) or {}
1126
-
1127
- cls: ClsType[_models._models.JobDetailsList] = kwargs.pop("cls", None) # pylint: disable=protected-access
1128
-
1129
- error_map = {
1130
- 401: ClientAuthenticationError,
1131
- 404: ResourceNotFoundError,
1132
- 409: ResourceExistsError,
1133
- 304: ResourceNotModifiedError,
1134
- }
1135
- error_map.update(kwargs.pop("error_map", {}) or {})
1136
-
1137
- def prepare_request(next_link=None):
1138
- if not next_link:
1139
-
1140
- request = build_sessions_jobs_list_request(
1141
- session_id=session_id,
1142
- subscription_id=self._config.subscription_id,
1143
- resource_group_name=self._config.resource_group_name,
1144
- workspace_name=self._config.workspace_name,
1145
- api_version=self._config.api_version,
1146
- headers=_headers,
1147
- params=_params,
1148
- )
1149
- request.url = self._client.format_url(request.url)
1150
-
1151
- else:
1152
- # make call to next link with the client's api-version
1153
- _parsed_next_link = urllib.parse.urlparse(next_link)
1154
- _next_request_params = case_insensitive_dict(
1155
- {
1156
- key: [urllib.parse.quote(v) for v in value]
1157
- for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1158
- }
1159
- )
1160
- _next_request_params["api-version"] = self._config.api_version
1161
- request = HttpRequest(
1162
- "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1163
- )
1164
- request.url = self._client.format_url(request.url)
1165
-
1166
- return request
1167
-
1168
- async def extract_data(pipeline_response):
1169
- deserialized = self._deserialize(
1170
- _models._models.JobDetailsList, pipeline_response # pylint: disable=protected-access
1171
- )
1172
- list_of_elem = deserialized.value
1173
- if cls:
1174
- list_of_elem = cls(list_of_elem) # type: ignore
1175
- return deserialized.next_link or None, AsyncList(list_of_elem)
1176
-
1177
- async def get_next(next_link=None):
1178
- request = prepare_request(next_link)
1179
-
1180
- _stream = False
1181
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1182
- request, stream=_stream, **kwargs
1183
- )
1184
- response = pipeline_response.http_response
1185
-
1186
- if response.status_code not in [200]:
1187
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1188
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
1189
- raise HttpResponseError(response=response, model=error)
1190
-
1191
- return pipeline_response
1192
-
1193
- return AsyncItemPaged(get_next, extract_data)
1194
-
1195
-
1196
- class TopLevelItemsOperations:
1197
- """
1198
- .. warning::
1199
- **DO NOT** instantiate this class directly.
1200
-
1201
- Instead, you should access the following operations through
1202
- :class:`~azure.quantum._client.aio.QuantumClient`'s
1203
- :attr:`top_level_items` attribute.
1204
- """
1205
-
1206
- models = _models
1207
-
1208
- def __init__(self, *args, **kwargs) -> None:
1209
- input_args = list(args)
1210
- self._client = input_args.pop(0) if input_args else kwargs.pop("client")
1211
- self._config = input_args.pop(0) if input_args else kwargs.pop("config")
1212
- self._serialize = input_args.pop(0) if input_args else kwargs.pop("serializer")
1213
- self._deserialize = input_args.pop(0) if input_args else kwargs.pop("deserializer")
1214
-
1215
- @distributed_trace
1216
- def list(self, **kwargs: Any) -> AsyncIterable["_models.ItemDetails"]:
1217
- """List top-level items.
1218
-
1219
- :return: An iterator like instance of ItemDetails
1220
- :rtype: ~azure.core.async_paging.AsyncItemPaged[~azure.quantum._client.models.ItemDetails]
1221
- :raises ~azure.core.exceptions.HttpResponseError:
1222
- """
1223
- _headers = kwargs.pop("headers", {}) or {}
1224
- _params = kwargs.pop("params", {}) or {}
1225
-
1226
- cls: ClsType[_models._models.ItemDetailsList] = kwargs.pop("cls", None) # pylint: disable=protected-access
1227
-
1228
- error_map = {
1229
- 401: ClientAuthenticationError,
1230
- 404: ResourceNotFoundError,
1231
- 409: ResourceExistsError,
1232
- 304: ResourceNotModifiedError,
1233
- }
1234
- error_map.update(kwargs.pop("error_map", {}) or {})
1235
-
1236
- def prepare_request(next_link=None):
1237
- if not next_link:
1238
-
1239
- request = build_top_level_items_list_request(
1240
- subscription_id=self._config.subscription_id,
1241
- resource_group_name=self._config.resource_group_name,
1242
- workspace_name=self._config.workspace_name,
1243
- api_version=self._config.api_version,
1244
- headers=_headers,
1245
- params=_params,
1246
- )
1247
- request.url = self._client.format_url(request.url)
1248
-
1249
- else:
1250
- # make call to next link with the client's api-version
1251
- _parsed_next_link = urllib.parse.urlparse(next_link)
1252
- _next_request_params = case_insensitive_dict(
1253
- {
1254
- key: [urllib.parse.quote(v) for v in value]
1255
- for key, value in urllib.parse.parse_qs(_parsed_next_link.query).items()
1256
- }
1257
- )
1258
- _next_request_params["api-version"] = self._config.api_version
1259
- request = HttpRequest(
1260
- "GET", urllib.parse.urljoin(next_link, _parsed_next_link.path), params=_next_request_params
1261
- )
1262
- request.url = self._client.format_url(request.url)
1263
-
1264
- return request
1265
-
1266
- async def extract_data(pipeline_response):
1267
- deserialized = self._deserialize(
1268
- _models._models.ItemDetailsList, pipeline_response # pylint: disable=protected-access
1269
- )
1270
- list_of_elem = deserialized.value
1271
- if cls:
1272
- list_of_elem = cls(list_of_elem) # type: ignore
1273
- return deserialized.next_link or None, AsyncList(list_of_elem)
1274
-
1275
- async def get_next(next_link=None):
1276
- request = prepare_request(next_link)
1277
-
1278
- _stream = False
1279
- pipeline_response: PipelineResponse = await self._client._pipeline.run( # pylint: disable=protected-access
1280
- request, stream=_stream, **kwargs
1281
- )
1282
- response = pipeline_response.http_response
1283
-
1284
- if response.status_code not in [200]:
1285
- map_error(status_code=response.status_code, response=response, error_map=error_map)
1286
- error = self._deserialize.failsafe_deserialize(_models.RestError, pipeline_response)
1287
- raise HttpResponseError(response=response, model=error)
1288
-
1289
- return pipeline_response
1290
-
1291
- return AsyncItemPaged(get_next, extract_data)