diracx-client 0.0.1a33__py3-none-any.whl → 0.0.1a35__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.
- _diracx_client_importer.pth +1 -0
- diracx/_client_importer.py +384 -0
- diracx/client/__init__.py +12 -4
- diracx/client/{generated → _generated}/__init__.py +1 -1
- diracx/client/{generated → _generated}/_client.py +5 -5
- diracx/client/{generated → _generated}/_configuration.py +1 -1
- diracx/client/{generated/aio → _generated}/_patch.py +4 -5
- diracx/client/{generated → _generated}/_serialization.py +1 -1
- diracx/client/{generated/aio → _generated}/_vendor.py +1 -1
- diracx/client/{generated → _generated}/aio/__init__.py +1 -1
- diracx/client/{generated → _generated}/aio/_client.py +5 -5
- diracx/client/{generated → _generated}/aio/_configuration.py +1 -1
- diracx/client/{generated → _generated/aio}/_patch.py +4 -9
- diracx/client/{generated → _generated/aio}/_vendor.py +1 -1
- diracx/client/{generated → _generated}/aio/operations/__init__.py +1 -1
- diracx/client/{generated → _generated}/aio/operations/_operations.py +158 -28
- diracx/client/_generated/aio/operations/_patch.py +26 -0
- diracx/client/{generated → _generated}/models/__init__.py +11 -1
- diracx/client/{generated → _generated}/models/_enums.py +1 -1
- diracx/client/{generated → _generated}/models/_models.py +152 -39
- diracx/client/{generated → _generated}/models/_patch.py +15 -12
- diracx/client/{generated → _generated}/operations/__init__.py +1 -1
- diracx/client/{generated → _generated}/operations/_operations.py +178 -28
- diracx/client/_generated/operations/_patch.py +26 -0
- diracx/client/aio.py +12 -2
- diracx/client/models.py +3 -6
- diracx/client/patches/auth/aio.py +45 -0
- diracx/client/patches/auth/common.py +56 -0
- diracx/client/patches/auth/sync.py +41 -0
- diracx/client/patches/{aio/utils.py → client/aio.py} +22 -40
- diracx/client/patches/client/common.py +196 -0
- diracx/client/patches/client/sync.py +141 -0
- diracx/client/patches/jobs/aio.py +34 -0
- diracx/client/patches/jobs/common.py +85 -0
- diracx/client/patches/jobs/sync.py +34 -0
- diracx/client/py.typed +0 -1
- diracx/client/sync.py +13 -0
- {diracx_client-0.0.1a33.dist-info → diracx_client-0.0.1a35.dist-info}/METADATA +3 -4
- diracx_client-0.0.1a35.dist-info/RECORD +42 -0
- {diracx_client-0.0.1a33.dist-info → diracx_client-0.0.1a35.dist-info}/WHEEL +1 -2
- diracx/client/extensions.py +0 -90
- diracx/client/generated/aio/operations/_patch.py +0 -126
- diracx/client/generated/operations/_patch.py +0 -129
- diracx/client/patches/__init__.py +0 -19
- diracx/client/patches/aio/__init__.py +0 -18
- diracx_client-0.0.1a33.dist-info/RECORD +0 -36
- diracx_client-0.0.1a33.dist-info/entry_points.txt +0 -3
- diracx_client-0.0.1a33.dist-info/top_level.txt +0 -1
- /diracx/client/{generated → _generated}/py.typed +0 -0
@@ -1,7 +1,7 @@
|
|
1
1
|
# pylint: disable=too-many-lines
|
2
2
|
# coding=utf-8
|
3
3
|
# --------------------------------------------------------------------------
|
4
|
-
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.4, generator: @autorest/python@6.32.
|
4
|
+
# Code generated by Microsoft (R) AutoRest Code Generator (autorest: 3.10.4, generator: @autorest/python@6.32.2)
|
5
5
|
# Changes may cause incorrect behavior and will be lost if the code is regenerated.
|
6
6
|
# --------------------------------------------------------------------------
|
7
7
|
from io import IOBase
|
@@ -508,6 +508,27 @@ def build_jobs_set_job_statuses_request(
|
|
508
508
|
)
|
509
509
|
|
510
510
|
|
511
|
+
def build_jobs_add_heartbeat_request(**kwargs: Any) -> HttpRequest:
|
512
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
513
|
+
|
514
|
+
content_type: Optional[str] = kwargs.pop(
|
515
|
+
"content_type", _headers.pop("Content-Type", None)
|
516
|
+
)
|
517
|
+
accept = _headers.pop("Accept", "application/json")
|
518
|
+
|
519
|
+
# Construct URL
|
520
|
+
_url = "/api/jobs/heartbeat"
|
521
|
+
|
522
|
+
# Construct headers
|
523
|
+
if content_type is not None:
|
524
|
+
_headers["Content-Type"] = _SERIALIZER.header(
|
525
|
+
"content_type", content_type, "str"
|
526
|
+
)
|
527
|
+
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
|
528
|
+
|
529
|
+
return HttpRequest(method="PATCH", url=_url, headers=_headers, **kwargs)
|
530
|
+
|
531
|
+
|
511
532
|
def build_jobs_reschedule_jobs_request(
|
512
533
|
*, job_ids: List[int], reset_jobs: bool = False, **kwargs: Any
|
513
534
|
) -> HttpRequest:
|
@@ -630,7 +651,7 @@ class WellKnownOperations:
|
|
630
651
|
**DO NOT** instantiate this class directly.
|
631
652
|
|
632
653
|
Instead, you should access the following operations through
|
633
|
-
:class:`~
|
654
|
+
:class:`~_generated.Dirac`'s
|
634
655
|
:attr:`well_known` attribute.
|
635
656
|
"""
|
636
657
|
|
@@ -658,7 +679,7 @@ class WellKnownOperations:
|
|
658
679
|
OpenID Connect discovery endpoint.
|
659
680
|
|
660
681
|
:return: OpenIDConfiguration
|
661
|
-
:rtype: ~
|
682
|
+
:rtype: ~_generated.models.OpenIDConfiguration
|
662
683
|
:raises ~azure.core.exceptions.HttpResponseError:
|
663
684
|
"""
|
664
685
|
error_map: MutableMapping = {
|
@@ -711,7 +732,7 @@ class WellKnownOperations:
|
|
711
732
|
Get metadata about the dirac installation.
|
712
733
|
|
713
734
|
:return: Metadata
|
714
|
-
:rtype: ~
|
735
|
+
:rtype: ~_generated.models.Metadata
|
715
736
|
:raises ~azure.core.exceptions.HttpResponseError:
|
716
737
|
"""
|
717
738
|
error_map: MutableMapping = {
|
@@ -762,7 +783,7 @@ class AuthOperations: # pylint: disable=abstract-class-instantiated
|
|
762
783
|
**DO NOT** instantiate this class directly.
|
763
784
|
|
764
785
|
Instead, you should access the following operations through
|
765
|
-
:class:`~
|
786
|
+
:class:`~_generated.Dirac`'s
|
766
787
|
:attr:`auth` attribute.
|
767
788
|
"""
|
768
789
|
|
@@ -825,7 +846,7 @@ class AuthOperations: # pylint: disable=abstract-class-instantiated
|
|
825
846
|
:keyword scope: Required.
|
826
847
|
:paramtype scope: str
|
827
848
|
:return: InitiateDeviceFlowResponse
|
828
|
-
:rtype: ~
|
849
|
+
:rtype: ~_generated.models.InitiateDeviceFlowResponse
|
829
850
|
:raises ~azure.core.exceptions.HttpResponseError:
|
830
851
|
"""
|
831
852
|
error_map: MutableMapping = {
|
@@ -1160,7 +1181,7 @@ class AuthOperations: # pylint: disable=abstract-class-instantiated
|
|
1160
1181
|
Get information about the user's identity.
|
1161
1182
|
|
1162
1183
|
:return: UserInfoResponse
|
1163
|
-
:rtype: ~
|
1184
|
+
:rtype: ~_generated.models.UserInfoResponse
|
1164
1185
|
:raises ~azure.core.exceptions.HttpResponseError:
|
1165
1186
|
"""
|
1166
1187
|
error_map: MutableMapping = {
|
@@ -1386,7 +1407,7 @@ class ConfigOperations:
|
|
1386
1407
|
**DO NOT** instantiate this class directly.
|
1387
1408
|
|
1388
1409
|
Instead, you should access the following operations through
|
1389
|
-
:class:`~
|
1410
|
+
:class:`~_generated.Dirac`'s
|
1390
1411
|
:attr:`config` attribute.
|
1391
1412
|
"""
|
1392
1413
|
|
@@ -1493,7 +1514,7 @@ class JobsOperations:
|
|
1493
1514
|
**DO NOT** instantiate this class directly.
|
1494
1515
|
|
1495
1516
|
Instead, you should access the following operations through
|
1496
|
-
:class:`~
|
1517
|
+
:class:`~_generated.Dirac`'s
|
1497
1518
|
:attr:`jobs` attribute.
|
1498
1519
|
"""
|
1499
1520
|
|
@@ -1533,12 +1554,12 @@ class JobsOperations:
|
|
1533
1554
|
should be used to upload the sandbox to the storage backend.
|
1534
1555
|
|
1535
1556
|
:param body: Required.
|
1536
|
-
:type body: ~
|
1557
|
+
:type body: ~_generated.models.SandboxInfo
|
1537
1558
|
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
1538
1559
|
Default value is "application/json".
|
1539
1560
|
:paramtype content_type: str
|
1540
1561
|
:return: SandboxUploadResponse
|
1541
|
-
:rtype: ~
|
1562
|
+
:rtype: ~_generated.models.SandboxUploadResponse
|
1542
1563
|
:raises ~azure.core.exceptions.HttpResponseError:
|
1543
1564
|
"""
|
1544
1565
|
|
@@ -1562,7 +1583,7 @@ class JobsOperations:
|
|
1562
1583
|
Default value is "application/json".
|
1563
1584
|
:paramtype content_type: str
|
1564
1585
|
:return: SandboxUploadResponse
|
1565
|
-
:rtype: ~
|
1586
|
+
:rtype: ~_generated.models.SandboxUploadResponse
|
1566
1587
|
:raises ~azure.core.exceptions.HttpResponseError:
|
1567
1588
|
"""
|
1568
1589
|
|
@@ -1581,9 +1602,9 @@ class JobsOperations:
|
|
1581
1602
|
should be used to upload the sandbox to the storage backend.
|
1582
1603
|
|
1583
1604
|
:param body: Is either a SandboxInfo type or a IO[bytes] type. Required.
|
1584
|
-
:type body: ~
|
1605
|
+
:type body: ~_generated.models.SandboxInfo or IO[bytes]
|
1585
1606
|
:return: SandboxUploadResponse
|
1586
|
-
:rtype: ~
|
1607
|
+
:rtype: ~_generated.models.SandboxUploadResponse
|
1587
1608
|
:raises ~azure.core.exceptions.HttpResponseError:
|
1588
1609
|
"""
|
1589
1610
|
error_map: MutableMapping = {
|
@@ -1660,7 +1681,7 @@ class JobsOperations:
|
|
1660
1681
|
:keyword pfn: Required.
|
1661
1682
|
:paramtype pfn: str
|
1662
1683
|
:return: SandboxDownloadResponse
|
1663
|
-
:rtype: ~
|
1684
|
+
:rtype: ~_generated.models.SandboxDownloadResponse
|
1664
1685
|
:raises ~azure.core.exceptions.HttpResponseError:
|
1665
1686
|
"""
|
1666
1687
|
error_map: MutableMapping = {
|
@@ -1882,7 +1903,7 @@ class JobsOperations:
|
|
1882
1903
|
:param job_id: Required.
|
1883
1904
|
:type job_id: int
|
1884
1905
|
:param sandbox_type: Known values are: "input" and "output". Required.
|
1885
|
-
:type sandbox_type: str or ~
|
1906
|
+
:type sandbox_type: str or ~_generated.models.SandboxType
|
1886
1907
|
:return: list of any
|
1887
1908
|
:rtype: list[any]
|
1888
1909
|
:raises ~azure.core.exceptions.HttpResponseError:
|
@@ -2066,14 +2087,14 @@ class JobsOperations:
|
|
2066
2087
|
Set Job Statuses.
|
2067
2088
|
|
2068
2089
|
:param body: Required.
|
2069
|
-
:type body: dict[str, dict[str, ~
|
2090
|
+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]]
|
2070
2091
|
:keyword force: Default value is False.
|
2071
2092
|
:paramtype force: bool
|
2072
2093
|
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
2073
2094
|
Default value is "application/json".
|
2074
2095
|
:paramtype content_type: str
|
2075
2096
|
:return: SetJobStatusReturn
|
2076
|
-
:rtype: ~
|
2097
|
+
:rtype: ~_generated.models.SetJobStatusReturn
|
2077
2098
|
:raises ~azure.core.exceptions.HttpResponseError:
|
2078
2099
|
"""
|
2079
2100
|
|
@@ -2098,7 +2119,7 @@ class JobsOperations:
|
|
2098
2119
|
Default value is "application/json".
|
2099
2120
|
:paramtype content_type: str
|
2100
2121
|
:return: SetJobStatusReturn
|
2101
|
-
:rtype: ~
|
2122
|
+
:rtype: ~_generated.models.SetJobStatusReturn
|
2102
2123
|
:raises ~azure.core.exceptions.HttpResponseError:
|
2103
2124
|
"""
|
2104
2125
|
|
@@ -2115,11 +2136,11 @@ class JobsOperations:
|
|
2115
2136
|
Set Job Statuses.
|
2116
2137
|
|
2117
2138
|
:param body: Is either a {str: {str: JobStatusUpdate}} type or a IO[bytes] type. Required.
|
2118
|
-
:type body: dict[str, dict[str, ~
|
2139
|
+
:type body: dict[str, dict[str, ~_generated.models.JobStatusUpdate]] or IO[bytes]
|
2119
2140
|
:keyword force: Default value is False.
|
2120
2141
|
:paramtype force: bool
|
2121
2142
|
:return: SetJobStatusReturn
|
2122
|
-
:rtype: ~
|
2143
|
+
:rtype: ~_generated.models.SetJobStatusReturn
|
2123
2144
|
:raises ~azure.core.exceptions.HttpResponseError:
|
2124
2145
|
"""
|
2125
2146
|
error_map: MutableMapping = {
|
@@ -2180,6 +2201,135 @@ class JobsOperations:
|
|
2180
2201
|
|
2181
2202
|
return deserialized # type: ignore
|
2182
2203
|
|
2204
|
+
@overload
|
2205
|
+
def add_heartbeat(
|
2206
|
+
self,
|
2207
|
+
body: Dict[str, _models.HeartbeatData],
|
2208
|
+
*,
|
2209
|
+
content_type: str = "application/json",
|
2210
|
+
**kwargs: Any,
|
2211
|
+
) -> List[_models.JobCommand]:
|
2212
|
+
"""Add Heartbeat.
|
2213
|
+
|
2214
|
+
Register a heartbeat from the job.
|
2215
|
+
|
2216
|
+
This endpoint is used by the JobAgent to send heartbeats to the WMS and to
|
2217
|
+
receive job commands from the WMS. It also results in stalled jobs being
|
2218
|
+
restored to the RUNNING status.
|
2219
|
+
|
2220
|
+
The ``data`` parameter and return value are mappings keyed by job ID.
|
2221
|
+
|
2222
|
+
:param body: Required.
|
2223
|
+
:type body: dict[str, ~_generated.models.HeartbeatData]
|
2224
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
2225
|
+
Default value is "application/json".
|
2226
|
+
:paramtype content_type: str
|
2227
|
+
:return: list of JobCommand
|
2228
|
+
:rtype: list[~_generated.models.JobCommand]
|
2229
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
2230
|
+
"""
|
2231
|
+
|
2232
|
+
@overload
|
2233
|
+
def add_heartbeat(
|
2234
|
+
self, body: IO[bytes], *, content_type: str = "application/json", **kwargs: Any
|
2235
|
+
) -> List[_models.JobCommand]:
|
2236
|
+
"""Add Heartbeat.
|
2237
|
+
|
2238
|
+
Register a heartbeat from the job.
|
2239
|
+
|
2240
|
+
This endpoint is used by the JobAgent to send heartbeats to the WMS and to
|
2241
|
+
receive job commands from the WMS. It also results in stalled jobs being
|
2242
|
+
restored to the RUNNING status.
|
2243
|
+
|
2244
|
+
The ``data`` parameter and return value are mappings keyed by job ID.
|
2245
|
+
|
2246
|
+
:param body: Required.
|
2247
|
+
:type body: IO[bytes]
|
2248
|
+
:keyword content_type: Body Parameter content-type. Content type parameter for binary body.
|
2249
|
+
Default value is "application/json".
|
2250
|
+
:paramtype content_type: str
|
2251
|
+
:return: list of JobCommand
|
2252
|
+
:rtype: list[~_generated.models.JobCommand]
|
2253
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
2254
|
+
"""
|
2255
|
+
|
2256
|
+
@distributed_trace
|
2257
|
+
def add_heartbeat(
|
2258
|
+
self, body: Union[Dict[str, _models.HeartbeatData], IO[bytes]], **kwargs: Any
|
2259
|
+
) -> List[_models.JobCommand]:
|
2260
|
+
"""Add Heartbeat.
|
2261
|
+
|
2262
|
+
Register a heartbeat from the job.
|
2263
|
+
|
2264
|
+
This endpoint is used by the JobAgent to send heartbeats to the WMS and to
|
2265
|
+
receive job commands from the WMS. It also results in stalled jobs being
|
2266
|
+
restored to the RUNNING status.
|
2267
|
+
|
2268
|
+
The ``data`` parameter and return value are mappings keyed by job ID.
|
2269
|
+
|
2270
|
+
:param body: Is either a {str: HeartbeatData} type or a IO[bytes] type. Required.
|
2271
|
+
:type body: dict[str, ~_generated.models.HeartbeatData] or IO[bytes]
|
2272
|
+
:return: list of JobCommand
|
2273
|
+
:rtype: list[~_generated.models.JobCommand]
|
2274
|
+
:raises ~azure.core.exceptions.HttpResponseError:
|
2275
|
+
"""
|
2276
|
+
error_map: MutableMapping = {
|
2277
|
+
401: ClientAuthenticationError,
|
2278
|
+
404: ResourceNotFoundError,
|
2279
|
+
409: ResourceExistsError,
|
2280
|
+
304: ResourceNotModifiedError,
|
2281
|
+
}
|
2282
|
+
error_map.update(kwargs.pop("error_map", {}) or {})
|
2283
|
+
|
2284
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
2285
|
+
_params = kwargs.pop("params", {}) or {}
|
2286
|
+
|
2287
|
+
content_type: Optional[str] = kwargs.pop(
|
2288
|
+
"content_type", _headers.pop("Content-Type", None)
|
2289
|
+
)
|
2290
|
+
cls: ClsType[List[_models.JobCommand]] = kwargs.pop("cls", None)
|
2291
|
+
|
2292
|
+
content_type = content_type or "application/json"
|
2293
|
+
_json = None
|
2294
|
+
_content = None
|
2295
|
+
if isinstance(body, (IOBase, bytes)):
|
2296
|
+
_content = body
|
2297
|
+
else:
|
2298
|
+
_json = self._serialize.body(body, "{HeartbeatData}")
|
2299
|
+
|
2300
|
+
_request = build_jobs_add_heartbeat_request(
|
2301
|
+
content_type=content_type,
|
2302
|
+
json=_json,
|
2303
|
+
content=_content,
|
2304
|
+
headers=_headers,
|
2305
|
+
params=_params,
|
2306
|
+
)
|
2307
|
+
_request.url = self._client.format_url(_request.url)
|
2308
|
+
|
2309
|
+
_stream = False
|
2310
|
+
pipeline_response: PipelineResponse = (
|
2311
|
+
self._client._pipeline.run( # pylint: disable=protected-access
|
2312
|
+
_request, stream=_stream, **kwargs
|
2313
|
+
)
|
2314
|
+
)
|
2315
|
+
|
2316
|
+
response = pipeline_response.http_response
|
2317
|
+
|
2318
|
+
if response.status_code not in [200]:
|
2319
|
+
map_error(
|
2320
|
+
status_code=response.status_code, response=response, error_map=error_map
|
2321
|
+
)
|
2322
|
+
raise HttpResponseError(response=response)
|
2323
|
+
|
2324
|
+
deserialized = self._deserialize(
|
2325
|
+
"[JobCommand]", pipeline_response.http_response
|
2326
|
+
)
|
2327
|
+
|
2328
|
+
if cls:
|
2329
|
+
return cls(pipeline_response, deserialized, {}) # type: ignore
|
2330
|
+
|
2331
|
+
return deserialized # type: ignore
|
2332
|
+
|
2183
2333
|
@distributed_trace
|
2184
2334
|
def reschedule_jobs(
|
2185
2335
|
self, *, job_ids: List[int], reset_jobs: bool = False, **kwargs: Any
|
@@ -2361,7 +2511,7 @@ class JobsOperations:
|
|
2361
2511
|
**TODO: Add more docs**.
|
2362
2512
|
|
2363
2513
|
:param body: Default value is None.
|
2364
|
-
:type body: ~
|
2514
|
+
:type body: ~_generated.models.JobSearchParams
|
2365
2515
|
:keyword page: Default value is 1.
|
2366
2516
|
:paramtype page: int
|
2367
2517
|
:keyword per_page: Default value is 100.
|
@@ -2420,7 +2570,7 @@ class JobsOperations:
|
|
2420
2570
|
**TODO: Add more docs**.
|
2421
2571
|
|
2422
2572
|
:param body: Is either a JobSearchParams type or a IO[bytes] type. Default value is None.
|
2423
|
-
:type body: ~
|
2573
|
+
:type body: ~_generated.models.JobSearchParams or IO[bytes]
|
2424
2574
|
:keyword page: Default value is 1.
|
2425
2575
|
:paramtype page: int
|
2426
2576
|
:keyword per_page: Default value is 100.
|
@@ -2508,7 +2658,7 @@ class JobsOperations:
|
|
2508
2658
|
Show information suitable for plotting.
|
2509
2659
|
|
2510
2660
|
:param body: Required.
|
2511
|
-
:type body: ~
|
2661
|
+
:type body: ~_generated.models.JobSummaryParams
|
2512
2662
|
:keyword content_type: Body Parameter content-type. Content type parameter for JSON body.
|
2513
2663
|
Default value is "application/json".
|
2514
2664
|
:paramtype content_type: str
|
@@ -2544,7 +2694,7 @@ class JobsOperations:
|
|
2544
2694
|
Show information suitable for plotting.
|
2545
2695
|
|
2546
2696
|
:param body: Is either a JobSummaryParams type or a IO[bytes] type. Required.
|
2547
|
-
:type body: ~
|
2697
|
+
:type body: ~_generated.models.JobSummaryParams or IO[bytes]
|
2548
2698
|
:return: any
|
2549
2699
|
:rtype: any
|
2550
2700
|
:raises ~azure.core.exceptions.HttpResponseError:
|
@@ -2618,7 +2768,7 @@ class JobsOperations:
|
|
2618
2768
|
Default value is "application/json".
|
2619
2769
|
:paramtype content_type: str
|
2620
2770
|
:return: list of InsertedJob
|
2621
|
-
:rtype: list[~
|
2771
|
+
:rtype: list[~_generated.models.InsertedJob]
|
2622
2772
|
:raises ~azure.core.exceptions.HttpResponseError:
|
2623
2773
|
"""
|
2624
2774
|
|
@@ -2636,7 +2786,7 @@ class JobsOperations:
|
|
2636
2786
|
Default value is "application/json".
|
2637
2787
|
:paramtype content_type: str
|
2638
2788
|
:return: list of InsertedJob
|
2639
|
-
:rtype: list[~
|
2789
|
+
:rtype: list[~_generated.models.InsertedJob]
|
2640
2790
|
:raises ~azure.core.exceptions.HttpResponseError:
|
2641
2791
|
"""
|
2642
2792
|
|
@@ -2651,7 +2801,7 @@ class JobsOperations:
|
|
2651
2801
|
:param body: Is either a [str] type or a IO[bytes] type. Required.
|
2652
2802
|
:type body: list[str] or IO[bytes]
|
2653
2803
|
:return: list of InsertedJob
|
2654
|
-
:rtype: list[~
|
2804
|
+
:rtype: list[~_generated.models.InsertedJob]
|
2655
2805
|
:raises ~azure.core.exceptions.HttpResponseError:
|
2656
2806
|
"""
|
2657
2807
|
error_map: MutableMapping = {
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# ------------------------------------
|
2
|
+
# Copyright (c) Microsoft Corporation.
|
3
|
+
# Licensed under the MIT License.
|
4
|
+
# ------------------------------------
|
5
|
+
"""Customize generated code here.
|
6
|
+
|
7
|
+
Follow our quickstart for examples: https://aka.ms/azsdk/python/dpcodegen/python/customize
|
8
|
+
"""
|
9
|
+
from __future__ import annotations
|
10
|
+
|
11
|
+
__all__ = [
|
12
|
+
"AuthOperations",
|
13
|
+
"JobsOperations",
|
14
|
+
] # Add all objects you want publicly available to users at this package level
|
15
|
+
|
16
|
+
from ...patches.auth.sync import AuthOperations
|
17
|
+
from ...patches.jobs.sync import JobsOperations
|
18
|
+
|
19
|
+
|
20
|
+
def patch_sdk():
|
21
|
+
"""Do not remove from this file.
|
22
|
+
|
23
|
+
`patch_sdk` is a last resort escape hatch that allows you to do customizations
|
24
|
+
you can't accomplish using the techniques described in
|
25
|
+
https://aka.ms/azsdk/python/dpcodegen/python/customize
|
26
|
+
"""
|
diracx/client/aio.py
CHANGED
@@ -1,3 +1,13 @@
|
|
1
|
-
from
|
1
|
+
from __future__ import absolute_import
|
2
2
|
|
3
|
-
__all__ =
|
3
|
+
__all__ = [
|
4
|
+
"AsyncDiracClient",
|
5
|
+
"async_operations",
|
6
|
+
]
|
7
|
+
|
8
|
+
from ._generated.aio import Dirac
|
9
|
+
from ._generated.aio import operations as async_operations
|
10
|
+
|
11
|
+
|
12
|
+
class AsyncDiracClient(Dirac):
|
13
|
+
pass
|
diracx/client/models.py
CHANGED
@@ -1,7 +1,4 @@
|
|
1
|
-
from
|
1
|
+
from __future__ import absolute_import
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
from .generated.models import DeviceFlowErrorResponse
|
6
|
-
|
7
|
-
__all__ = ("DeviceFlowErrorResponse",)
|
3
|
+
from ._generated.models import *
|
4
|
+
from ._generated.models import __all__
|
@@ -0,0 +1,45 @@
|
|
1
|
+
"""Patches for the autorest-generated jobs client.
|
2
|
+
|
3
|
+
This file can be used to customize the generated code for the jobs client.
|
4
|
+
When adding new classes to this file, make sure to also add them to the
|
5
|
+
__all__ list in the corresponding file in the patches directory.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from __future__ import annotations
|
9
|
+
|
10
|
+
__all__ = [
|
11
|
+
"AuthOperations",
|
12
|
+
]
|
13
|
+
|
14
|
+
from azure.core.pipeline import PipelineResponse
|
15
|
+
from azure.core.tracing.decorator_async import distributed_trace_async
|
16
|
+
from diracx.core.models import TokenResponse
|
17
|
+
|
18
|
+
from ..._generated.aio.operations._operations import (
|
19
|
+
_models,
|
20
|
+
AuthOperations as _AuthOperations,
|
21
|
+
)
|
22
|
+
from .common import prepare_request, handle_response
|
23
|
+
|
24
|
+
|
25
|
+
class AuthOperations(_AuthOperations):
|
26
|
+
@distributed_trace_async
|
27
|
+
async def get_oidc_token(
|
28
|
+
self, device_code: str, client_id: str, **kwargs
|
29
|
+
) -> TokenResponse | _models.DeviceFlowErrorResponse:
|
30
|
+
request = prepare_request(
|
31
|
+
device_code=device_code,
|
32
|
+
client_id=client_id,
|
33
|
+
format_url=self._client.format_url,
|
34
|
+
)
|
35
|
+
|
36
|
+
pipeline_response: PipelineResponse = (
|
37
|
+
await self._client._pipeline.run( # pylint: disable=protected-access
|
38
|
+
request, stream=False, **kwargs
|
39
|
+
)
|
40
|
+
)
|
41
|
+
|
42
|
+
response = handle_response(pipeline_response, self._deserialize)
|
43
|
+
if isinstance(response, _models.DeviceFlowErrorResponse):
|
44
|
+
return response
|
45
|
+
return TokenResponse.model_validate(response.as_dict())
|
@@ -0,0 +1,56 @@
|
|
1
|
+
"""Utilities which are common to the sync and async auth operator patches."""
|
2
|
+
|
3
|
+
from __future__ import annotations
|
4
|
+
|
5
|
+
__all__ = [
|
6
|
+
"prepare_request",
|
7
|
+
"handle_response",
|
8
|
+
]
|
9
|
+
|
10
|
+
from typing import Any
|
11
|
+
|
12
|
+
from azure.core.exceptions import map_error, HttpResponseError
|
13
|
+
from azure.core.pipeline import PipelineResponse
|
14
|
+
from azure.core.rest import HttpRequest
|
15
|
+
from azure.core.utils import case_insensitive_dict
|
16
|
+
|
17
|
+
from ..._generated.models import TokenResponse, DeviceFlowErrorResponse
|
18
|
+
from ..._generated.operations._operations import _SERIALIZER
|
19
|
+
|
20
|
+
|
21
|
+
def build_token_request(**kwargs: Any) -> HttpRequest:
|
22
|
+
_headers = case_insensitive_dict(kwargs.pop("headers", {}) or {})
|
23
|
+
|
24
|
+
accept = _headers.pop("Accept", "application/json")
|
25
|
+
|
26
|
+
_url = "/api/auth/token"
|
27
|
+
|
28
|
+
_headers["Accept"] = _SERIALIZER.header("accept", accept, "str")
|
29
|
+
|
30
|
+
return HttpRequest(method="POST", url=_url, headers=_headers, **kwargs)
|
31
|
+
|
32
|
+
|
33
|
+
def prepare_request(device_code, client_id, format_url) -> HttpRequest:
|
34
|
+
request = build_token_request(
|
35
|
+
data={
|
36
|
+
"grant_type": "urn:ietf:params:oauth:grant-type:device_code",
|
37
|
+
"device_code": device_code,
|
38
|
+
"client_id": client_id,
|
39
|
+
},
|
40
|
+
)
|
41
|
+
request.url = format_url(request.url)
|
42
|
+
return request
|
43
|
+
|
44
|
+
|
45
|
+
def handle_response(
|
46
|
+
pipeline_response: PipelineResponse, deserialize
|
47
|
+
) -> TokenResponse | DeviceFlowErrorResponse:
|
48
|
+
response = pipeline_response.http_response
|
49
|
+
|
50
|
+
if response.status_code == 200:
|
51
|
+
return deserialize("TokenResponse", pipeline_response)
|
52
|
+
elif response.status_code == 400:
|
53
|
+
return deserialize("DeviceFlowErrorResponse", pipeline_response)
|
54
|
+
else:
|
55
|
+
map_error(status_code=response.status_code, response=response, error_map={})
|
56
|
+
raise HttpResponseError(response=response)
|
@@ -0,0 +1,41 @@
|
|
1
|
+
"""Patches for the autorest-generated jobs client.
|
2
|
+
|
3
|
+
This file can be used to customize the generated code for the jobs client.
|
4
|
+
When adding new classes to this file, make sure to also add them to the
|
5
|
+
__all__ list in the corresponding file in the patches directory.
|
6
|
+
"""
|
7
|
+
|
8
|
+
from __future__ import annotations
|
9
|
+
|
10
|
+
__all__ = [
|
11
|
+
"AuthOperations",
|
12
|
+
]
|
13
|
+
|
14
|
+
from azure.core.pipeline import PipelineResponse
|
15
|
+
from azure.core.tracing.decorator import distributed_trace
|
16
|
+
|
17
|
+
from ..._generated.operations._operations import (
|
18
|
+
_models,
|
19
|
+
AuthOperations as _AuthOperations,
|
20
|
+
)
|
21
|
+
from .common import prepare_request, handle_response
|
22
|
+
|
23
|
+
|
24
|
+
class AuthOperations(_AuthOperations):
|
25
|
+
@distributed_trace
|
26
|
+
async def get_oidc_token(
|
27
|
+
self, device_code: str, client_id: str, **kwargs
|
28
|
+
) -> _models.TokenResponse | _models.DeviceFlowErrorResponse:
|
29
|
+
request = prepare_request(
|
30
|
+
device_code=device_code,
|
31
|
+
client_id=client_id,
|
32
|
+
format_url=self._client.format_url,
|
33
|
+
)
|
34
|
+
|
35
|
+
pipeline_response: PipelineResponse = (
|
36
|
+
self._client._pipeline.run( # pylint: disable=protected-access
|
37
|
+
request, stream=False, **kwargs
|
38
|
+
)
|
39
|
+
)
|
40
|
+
|
41
|
+
return handle_response(pipeline_response, self._deserialize)
|