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