samsara-api 5.3.1__py3-none-any.whl → 5.4.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- samsara/__init__.py +6 -0
- samsara/alerts/client.py +4 -0
- samsara/alerts/raw_client.py +4 -0
- samsara/beta_ap_is/client.py +0 -630
- samsara/beta_ap_is/raw_client.py +1496 -3144
- samsara/client.py +38 -0
- samsara/core/client_wrapper.py +2 -2
- samsara/media/client.py +4 -4
- samsara/media/raw_client.py +4 -4
- samsara/training_assignments/__init__.py +4 -0
- samsara/training_assignments/client.py +528 -0
- samsara/training_assignments/raw_client.py +1330 -0
- samsara/training_courses/__init__.py +4 -0
- samsara/training_courses/client.py +168 -0
- samsara/training_courses/raw_client.py +364 -0
- samsara/types/harsh_event_trigger_details_object_request_body_types_item.py +1 -0
- samsara/types/harsh_event_trigger_details_object_response_body_types_item.py +1 -0
- samsara/types/webhook_response_response_body_event_types_item.py +1 -0
- samsara/types/webhooks_get_webhook_response_body_event_types_item.py +1 -0
- samsara/types/webhooks_patch_webhook_response_body_event_types_item.py +1 -0
- samsara/types/webhooks_post_webhooks_response_body_event_types_item.py +1 -0
- samsara/types/workflow_trigger_object_request_body.py +2 -4
- samsara/types/workflow_trigger_object_response_body.py +2 -4
- samsara/webhooks/types/webhooks_post_webhooks_request_body_event_types_item.py +1 -0
- {samsara_api-5.3.1.dist-info → samsara_api-5.4.0.dist-info}/METADATA +1 -1
- {samsara_api-5.3.1.dist-info → samsara_api-5.4.0.dist-info}/RECORD +28 -22
- {samsara_api-5.3.1.dist-info → samsara_api-5.4.0.dist-info}/LICENSE +0 -0
- {samsara_api-5.3.1.dist-info → samsara_api-5.4.0.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,1330 @@
|
|
|
1
|
+
# This file was auto-generated by Fern from our API Definition.
|
|
2
|
+
|
|
3
|
+
import typing
|
|
4
|
+
from json.decoder import JSONDecodeError
|
|
5
|
+
|
|
6
|
+
from ..core.api_error import ApiError
|
|
7
|
+
from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
|
|
8
|
+
from ..core.http_response import AsyncHttpResponse, HttpResponse
|
|
9
|
+
from ..core.pydantic_utilities import parse_obj_as
|
|
10
|
+
from ..core.request_options import RequestOptions
|
|
11
|
+
from ..errors.bad_gateway_error import BadGatewayError
|
|
12
|
+
from ..errors.gateway_timeout_error import GatewayTimeoutError
|
|
13
|
+
from ..errors.internal_server_error import InternalServerError
|
|
14
|
+
from ..errors.method_not_allowed_error import MethodNotAllowedError
|
|
15
|
+
from ..errors.not_found_error import NotFoundError
|
|
16
|
+
from ..errors.not_implemented_error import NotImplementedError
|
|
17
|
+
from ..errors.service_unavailable_error import ServiceUnavailableError
|
|
18
|
+
from ..errors.too_many_requests_error import TooManyRequestsError
|
|
19
|
+
from ..errors.unauthorized_error import UnauthorizedError
|
|
20
|
+
from ..types.training_assignments_get_training_assignments_stream_response_body import (
|
|
21
|
+
TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody,
|
|
22
|
+
)
|
|
23
|
+
from ..types.training_assignments_patch_training_assignments_response_body import (
|
|
24
|
+
TrainingAssignmentsPatchTrainingAssignmentsResponseBody,
|
|
25
|
+
)
|
|
26
|
+
from ..types.training_assignments_post_training_assignments_response_body import (
|
|
27
|
+
TrainingAssignmentsPostTrainingAssignmentsResponseBody,
|
|
28
|
+
)
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class RawTrainingAssignmentsClient:
|
|
32
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
33
|
+
self._client_wrapper = client_wrapper
|
|
34
|
+
|
|
35
|
+
def post_training_assignments(
|
|
36
|
+
self,
|
|
37
|
+
*,
|
|
38
|
+
course_id: str,
|
|
39
|
+
due_at_time: str,
|
|
40
|
+
learner_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
41
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
42
|
+
) -> HttpResponse[TrainingAssignmentsPostTrainingAssignmentsResponseBody]:
|
|
43
|
+
"""
|
|
44
|
+
Create training assignments. Existing assignments will remain unchanged.
|
|
45
|
+
|
|
46
|
+
<b>Rate limit:</b> 10 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
47
|
+
|
|
48
|
+
To use this endpoint, select **Write Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
52
|
+
|
|
53
|
+
Parameters
|
|
54
|
+
----------
|
|
55
|
+
course_id : str
|
|
56
|
+
String for the course ID.
|
|
57
|
+
|
|
58
|
+
due_at_time : str
|
|
59
|
+
Due date of the training assignment in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
60
|
+
|
|
61
|
+
learner_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
62
|
+
Optional string of comma separated learner IDs. If learner ID is present, training assignments for the specified learner(s) will be returned. Max value for this value is 100 objects. Example: `learnerIds=driver-281474,driver-46282156`
|
|
63
|
+
|
|
64
|
+
request_options : typing.Optional[RequestOptions]
|
|
65
|
+
Request-specific configuration.
|
|
66
|
+
|
|
67
|
+
Returns
|
|
68
|
+
-------
|
|
69
|
+
HttpResponse[TrainingAssignmentsPostTrainingAssignmentsResponseBody]
|
|
70
|
+
OK response.
|
|
71
|
+
"""
|
|
72
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
73
|
+
"training-assignments",
|
|
74
|
+
method="POST",
|
|
75
|
+
params={
|
|
76
|
+
"courseId": course_id,
|
|
77
|
+
"dueAtTime": due_at_time,
|
|
78
|
+
"learnerIds": learner_ids,
|
|
79
|
+
},
|
|
80
|
+
request_options=request_options,
|
|
81
|
+
)
|
|
82
|
+
try:
|
|
83
|
+
if 200 <= _response.status_code < 300:
|
|
84
|
+
_data = typing.cast(
|
|
85
|
+
TrainingAssignmentsPostTrainingAssignmentsResponseBody,
|
|
86
|
+
parse_obj_as(
|
|
87
|
+
type_=TrainingAssignmentsPostTrainingAssignmentsResponseBody, # type: ignore
|
|
88
|
+
object_=_response.json(),
|
|
89
|
+
),
|
|
90
|
+
)
|
|
91
|
+
return HttpResponse(response=_response, data=_data)
|
|
92
|
+
if _response.status_code == 401:
|
|
93
|
+
raise UnauthorizedError(
|
|
94
|
+
headers=dict(_response.headers),
|
|
95
|
+
body=typing.cast(
|
|
96
|
+
typing.Any,
|
|
97
|
+
parse_obj_as(
|
|
98
|
+
type_=typing.Any, # type: ignore
|
|
99
|
+
object_=_response.json(),
|
|
100
|
+
),
|
|
101
|
+
),
|
|
102
|
+
)
|
|
103
|
+
if _response.status_code == 404:
|
|
104
|
+
raise NotFoundError(
|
|
105
|
+
headers=dict(_response.headers),
|
|
106
|
+
body=typing.cast(
|
|
107
|
+
typing.Any,
|
|
108
|
+
parse_obj_as(
|
|
109
|
+
type_=typing.Any, # type: ignore
|
|
110
|
+
object_=_response.json(),
|
|
111
|
+
),
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
if _response.status_code == 405:
|
|
115
|
+
raise MethodNotAllowedError(
|
|
116
|
+
headers=dict(_response.headers),
|
|
117
|
+
body=typing.cast(
|
|
118
|
+
typing.Any,
|
|
119
|
+
parse_obj_as(
|
|
120
|
+
type_=typing.Any, # type: ignore
|
|
121
|
+
object_=_response.json(),
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
)
|
|
125
|
+
if _response.status_code == 429:
|
|
126
|
+
raise TooManyRequestsError(
|
|
127
|
+
headers=dict(_response.headers),
|
|
128
|
+
body=typing.cast(
|
|
129
|
+
typing.Any,
|
|
130
|
+
parse_obj_as(
|
|
131
|
+
type_=typing.Any, # type: ignore
|
|
132
|
+
object_=_response.json(),
|
|
133
|
+
),
|
|
134
|
+
),
|
|
135
|
+
)
|
|
136
|
+
if _response.status_code == 500:
|
|
137
|
+
raise InternalServerError(
|
|
138
|
+
headers=dict(_response.headers),
|
|
139
|
+
body=typing.cast(
|
|
140
|
+
typing.Any,
|
|
141
|
+
parse_obj_as(
|
|
142
|
+
type_=typing.Any, # type: ignore
|
|
143
|
+
object_=_response.json(),
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
)
|
|
147
|
+
if _response.status_code == 501:
|
|
148
|
+
raise NotImplementedError(
|
|
149
|
+
headers=dict(_response.headers),
|
|
150
|
+
body=typing.cast(
|
|
151
|
+
typing.Any,
|
|
152
|
+
parse_obj_as(
|
|
153
|
+
type_=typing.Any, # type: ignore
|
|
154
|
+
object_=_response.json(),
|
|
155
|
+
),
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
if _response.status_code == 502:
|
|
159
|
+
raise BadGatewayError(
|
|
160
|
+
headers=dict(_response.headers),
|
|
161
|
+
body=typing.cast(
|
|
162
|
+
typing.Any,
|
|
163
|
+
parse_obj_as(
|
|
164
|
+
type_=typing.Any, # type: ignore
|
|
165
|
+
object_=_response.json(),
|
|
166
|
+
),
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
if _response.status_code == 503:
|
|
170
|
+
raise ServiceUnavailableError(
|
|
171
|
+
headers=dict(_response.headers),
|
|
172
|
+
body=typing.cast(
|
|
173
|
+
typing.Any,
|
|
174
|
+
parse_obj_as(
|
|
175
|
+
type_=typing.Any, # type: ignore
|
|
176
|
+
object_=_response.json(),
|
|
177
|
+
),
|
|
178
|
+
),
|
|
179
|
+
)
|
|
180
|
+
if _response.status_code == 504:
|
|
181
|
+
raise GatewayTimeoutError(
|
|
182
|
+
headers=dict(_response.headers),
|
|
183
|
+
body=typing.cast(
|
|
184
|
+
typing.Any,
|
|
185
|
+
parse_obj_as(
|
|
186
|
+
type_=typing.Any, # type: ignore
|
|
187
|
+
object_=_response.json(),
|
|
188
|
+
),
|
|
189
|
+
),
|
|
190
|
+
)
|
|
191
|
+
_response_json = _response.json()
|
|
192
|
+
except JSONDecodeError:
|
|
193
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
194
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
195
|
+
|
|
196
|
+
def delete_training_assignments(
|
|
197
|
+
self,
|
|
198
|
+
*,
|
|
199
|
+
ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
200
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
201
|
+
) -> HttpResponse[None]:
|
|
202
|
+
"""
|
|
203
|
+
This endpoint supports batch deletion operations. The response does not indicate which specific deletions, if any, have failed. On a successful deletion or partial failure, a ‘204 No Content’ status is returned.
|
|
204
|
+
|
|
205
|
+
<b>Rate limit:</b> 10 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
206
|
+
|
|
207
|
+
To use this endpoint, select **Write Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
208
|
+
|
|
209
|
+
|
|
210
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
211
|
+
|
|
212
|
+
Parameters
|
|
213
|
+
----------
|
|
214
|
+
ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
215
|
+
String of comma separated assignments IDs. Max value for this value is 100 objects. Example: `ids=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
216
|
+
|
|
217
|
+
request_options : typing.Optional[RequestOptions]
|
|
218
|
+
Request-specific configuration.
|
|
219
|
+
|
|
220
|
+
Returns
|
|
221
|
+
-------
|
|
222
|
+
HttpResponse[None]
|
|
223
|
+
"""
|
|
224
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
225
|
+
"training-assignments",
|
|
226
|
+
method="DELETE",
|
|
227
|
+
params={
|
|
228
|
+
"ids": ids,
|
|
229
|
+
},
|
|
230
|
+
request_options=request_options,
|
|
231
|
+
)
|
|
232
|
+
try:
|
|
233
|
+
if 200 <= _response.status_code < 300:
|
|
234
|
+
return HttpResponse(response=_response, data=None)
|
|
235
|
+
if _response.status_code == 401:
|
|
236
|
+
raise UnauthorizedError(
|
|
237
|
+
headers=dict(_response.headers),
|
|
238
|
+
body=typing.cast(
|
|
239
|
+
typing.Any,
|
|
240
|
+
parse_obj_as(
|
|
241
|
+
type_=typing.Any, # type: ignore
|
|
242
|
+
object_=_response.json(),
|
|
243
|
+
),
|
|
244
|
+
),
|
|
245
|
+
)
|
|
246
|
+
if _response.status_code == 404:
|
|
247
|
+
raise NotFoundError(
|
|
248
|
+
headers=dict(_response.headers),
|
|
249
|
+
body=typing.cast(
|
|
250
|
+
typing.Any,
|
|
251
|
+
parse_obj_as(
|
|
252
|
+
type_=typing.Any, # type: ignore
|
|
253
|
+
object_=_response.json(),
|
|
254
|
+
),
|
|
255
|
+
),
|
|
256
|
+
)
|
|
257
|
+
if _response.status_code == 405:
|
|
258
|
+
raise MethodNotAllowedError(
|
|
259
|
+
headers=dict(_response.headers),
|
|
260
|
+
body=typing.cast(
|
|
261
|
+
typing.Any,
|
|
262
|
+
parse_obj_as(
|
|
263
|
+
type_=typing.Any, # type: ignore
|
|
264
|
+
object_=_response.json(),
|
|
265
|
+
),
|
|
266
|
+
),
|
|
267
|
+
)
|
|
268
|
+
if _response.status_code == 429:
|
|
269
|
+
raise TooManyRequestsError(
|
|
270
|
+
headers=dict(_response.headers),
|
|
271
|
+
body=typing.cast(
|
|
272
|
+
typing.Any,
|
|
273
|
+
parse_obj_as(
|
|
274
|
+
type_=typing.Any, # type: ignore
|
|
275
|
+
object_=_response.json(),
|
|
276
|
+
),
|
|
277
|
+
),
|
|
278
|
+
)
|
|
279
|
+
if _response.status_code == 500:
|
|
280
|
+
raise InternalServerError(
|
|
281
|
+
headers=dict(_response.headers),
|
|
282
|
+
body=typing.cast(
|
|
283
|
+
typing.Any,
|
|
284
|
+
parse_obj_as(
|
|
285
|
+
type_=typing.Any, # type: ignore
|
|
286
|
+
object_=_response.json(),
|
|
287
|
+
),
|
|
288
|
+
),
|
|
289
|
+
)
|
|
290
|
+
if _response.status_code == 501:
|
|
291
|
+
raise NotImplementedError(
|
|
292
|
+
headers=dict(_response.headers),
|
|
293
|
+
body=typing.cast(
|
|
294
|
+
typing.Any,
|
|
295
|
+
parse_obj_as(
|
|
296
|
+
type_=typing.Any, # type: ignore
|
|
297
|
+
object_=_response.json(),
|
|
298
|
+
),
|
|
299
|
+
),
|
|
300
|
+
)
|
|
301
|
+
if _response.status_code == 502:
|
|
302
|
+
raise BadGatewayError(
|
|
303
|
+
headers=dict(_response.headers),
|
|
304
|
+
body=typing.cast(
|
|
305
|
+
typing.Any,
|
|
306
|
+
parse_obj_as(
|
|
307
|
+
type_=typing.Any, # type: ignore
|
|
308
|
+
object_=_response.json(),
|
|
309
|
+
),
|
|
310
|
+
),
|
|
311
|
+
)
|
|
312
|
+
if _response.status_code == 503:
|
|
313
|
+
raise ServiceUnavailableError(
|
|
314
|
+
headers=dict(_response.headers),
|
|
315
|
+
body=typing.cast(
|
|
316
|
+
typing.Any,
|
|
317
|
+
parse_obj_as(
|
|
318
|
+
type_=typing.Any, # type: ignore
|
|
319
|
+
object_=_response.json(),
|
|
320
|
+
),
|
|
321
|
+
),
|
|
322
|
+
)
|
|
323
|
+
if _response.status_code == 504:
|
|
324
|
+
raise GatewayTimeoutError(
|
|
325
|
+
headers=dict(_response.headers),
|
|
326
|
+
body=typing.cast(
|
|
327
|
+
typing.Any,
|
|
328
|
+
parse_obj_as(
|
|
329
|
+
type_=typing.Any, # type: ignore
|
|
330
|
+
object_=_response.json(),
|
|
331
|
+
),
|
|
332
|
+
),
|
|
333
|
+
)
|
|
334
|
+
_response_json = _response.json()
|
|
335
|
+
except JSONDecodeError:
|
|
336
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
337
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
338
|
+
|
|
339
|
+
def patch_training_assignments(
|
|
340
|
+
self,
|
|
341
|
+
*,
|
|
342
|
+
due_at_time: str,
|
|
343
|
+
ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
344
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
345
|
+
) -> HttpResponse[TrainingAssignmentsPatchTrainingAssignmentsResponseBody]:
|
|
346
|
+
"""
|
|
347
|
+
Update training assignments.
|
|
348
|
+
|
|
349
|
+
<b>Rate limit:</b> 10 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
350
|
+
|
|
351
|
+
To use this endpoint, select **Write Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
352
|
+
|
|
353
|
+
|
|
354
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
355
|
+
|
|
356
|
+
Parameters
|
|
357
|
+
----------
|
|
358
|
+
due_at_time : str
|
|
359
|
+
Due date of the training assignment in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
360
|
+
|
|
361
|
+
ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
362
|
+
String of comma separated assignments IDs. Max value for this value is 100 objects. Example: `ids=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
363
|
+
|
|
364
|
+
request_options : typing.Optional[RequestOptions]
|
|
365
|
+
Request-specific configuration.
|
|
366
|
+
|
|
367
|
+
Returns
|
|
368
|
+
-------
|
|
369
|
+
HttpResponse[TrainingAssignmentsPatchTrainingAssignmentsResponseBody]
|
|
370
|
+
OK response.
|
|
371
|
+
"""
|
|
372
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
373
|
+
"training-assignments",
|
|
374
|
+
method="PATCH",
|
|
375
|
+
params={
|
|
376
|
+
"ids": ids,
|
|
377
|
+
"dueAtTime": due_at_time,
|
|
378
|
+
},
|
|
379
|
+
request_options=request_options,
|
|
380
|
+
)
|
|
381
|
+
try:
|
|
382
|
+
if 200 <= _response.status_code < 300:
|
|
383
|
+
_data = typing.cast(
|
|
384
|
+
TrainingAssignmentsPatchTrainingAssignmentsResponseBody,
|
|
385
|
+
parse_obj_as(
|
|
386
|
+
type_=TrainingAssignmentsPatchTrainingAssignmentsResponseBody, # type: ignore
|
|
387
|
+
object_=_response.json(),
|
|
388
|
+
),
|
|
389
|
+
)
|
|
390
|
+
return HttpResponse(response=_response, data=_data)
|
|
391
|
+
if _response.status_code == 401:
|
|
392
|
+
raise UnauthorizedError(
|
|
393
|
+
headers=dict(_response.headers),
|
|
394
|
+
body=typing.cast(
|
|
395
|
+
typing.Any,
|
|
396
|
+
parse_obj_as(
|
|
397
|
+
type_=typing.Any, # type: ignore
|
|
398
|
+
object_=_response.json(),
|
|
399
|
+
),
|
|
400
|
+
),
|
|
401
|
+
)
|
|
402
|
+
if _response.status_code == 404:
|
|
403
|
+
raise NotFoundError(
|
|
404
|
+
headers=dict(_response.headers),
|
|
405
|
+
body=typing.cast(
|
|
406
|
+
typing.Any,
|
|
407
|
+
parse_obj_as(
|
|
408
|
+
type_=typing.Any, # type: ignore
|
|
409
|
+
object_=_response.json(),
|
|
410
|
+
),
|
|
411
|
+
),
|
|
412
|
+
)
|
|
413
|
+
if _response.status_code == 405:
|
|
414
|
+
raise MethodNotAllowedError(
|
|
415
|
+
headers=dict(_response.headers),
|
|
416
|
+
body=typing.cast(
|
|
417
|
+
typing.Any,
|
|
418
|
+
parse_obj_as(
|
|
419
|
+
type_=typing.Any, # type: ignore
|
|
420
|
+
object_=_response.json(),
|
|
421
|
+
),
|
|
422
|
+
),
|
|
423
|
+
)
|
|
424
|
+
if _response.status_code == 429:
|
|
425
|
+
raise TooManyRequestsError(
|
|
426
|
+
headers=dict(_response.headers),
|
|
427
|
+
body=typing.cast(
|
|
428
|
+
typing.Any,
|
|
429
|
+
parse_obj_as(
|
|
430
|
+
type_=typing.Any, # type: ignore
|
|
431
|
+
object_=_response.json(),
|
|
432
|
+
),
|
|
433
|
+
),
|
|
434
|
+
)
|
|
435
|
+
if _response.status_code == 500:
|
|
436
|
+
raise InternalServerError(
|
|
437
|
+
headers=dict(_response.headers),
|
|
438
|
+
body=typing.cast(
|
|
439
|
+
typing.Any,
|
|
440
|
+
parse_obj_as(
|
|
441
|
+
type_=typing.Any, # type: ignore
|
|
442
|
+
object_=_response.json(),
|
|
443
|
+
),
|
|
444
|
+
),
|
|
445
|
+
)
|
|
446
|
+
if _response.status_code == 501:
|
|
447
|
+
raise NotImplementedError(
|
|
448
|
+
headers=dict(_response.headers),
|
|
449
|
+
body=typing.cast(
|
|
450
|
+
typing.Any,
|
|
451
|
+
parse_obj_as(
|
|
452
|
+
type_=typing.Any, # type: ignore
|
|
453
|
+
object_=_response.json(),
|
|
454
|
+
),
|
|
455
|
+
),
|
|
456
|
+
)
|
|
457
|
+
if _response.status_code == 502:
|
|
458
|
+
raise BadGatewayError(
|
|
459
|
+
headers=dict(_response.headers),
|
|
460
|
+
body=typing.cast(
|
|
461
|
+
typing.Any,
|
|
462
|
+
parse_obj_as(
|
|
463
|
+
type_=typing.Any, # type: ignore
|
|
464
|
+
object_=_response.json(),
|
|
465
|
+
),
|
|
466
|
+
),
|
|
467
|
+
)
|
|
468
|
+
if _response.status_code == 503:
|
|
469
|
+
raise ServiceUnavailableError(
|
|
470
|
+
headers=dict(_response.headers),
|
|
471
|
+
body=typing.cast(
|
|
472
|
+
typing.Any,
|
|
473
|
+
parse_obj_as(
|
|
474
|
+
type_=typing.Any, # type: ignore
|
|
475
|
+
object_=_response.json(),
|
|
476
|
+
),
|
|
477
|
+
),
|
|
478
|
+
)
|
|
479
|
+
if _response.status_code == 504:
|
|
480
|
+
raise GatewayTimeoutError(
|
|
481
|
+
headers=dict(_response.headers),
|
|
482
|
+
body=typing.cast(
|
|
483
|
+
typing.Any,
|
|
484
|
+
parse_obj_as(
|
|
485
|
+
type_=typing.Any, # type: ignore
|
|
486
|
+
object_=_response.json(),
|
|
487
|
+
),
|
|
488
|
+
),
|
|
489
|
+
)
|
|
490
|
+
_response_json = _response.json()
|
|
491
|
+
except JSONDecodeError:
|
|
492
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
493
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
494
|
+
|
|
495
|
+
def get_training_assignments_stream(
|
|
496
|
+
self,
|
|
497
|
+
*,
|
|
498
|
+
start_time: str,
|
|
499
|
+
after: typing.Optional[str] = None,
|
|
500
|
+
end_time: typing.Optional[str] = None,
|
|
501
|
+
learner_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
502
|
+
course_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
503
|
+
status: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
504
|
+
is_overdue: typing.Optional[bool] = None,
|
|
505
|
+
category_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
506
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
507
|
+
) -> HttpResponse[TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody]:
|
|
508
|
+
"""
|
|
509
|
+
Returns all training assignments data that has been created or modified for your organization based on the time parameters passed in. Results are paginated and are sorted by last modified date. If you include an endTime, the endpoint will return data up until that point (exclusive). If you don't include an endTime, the API will continue to poll with the pagination cursor that gets returned on every call. The hasNextPage response value will be true if there is no endTime specified and endCursor is nonempty.
|
|
510
|
+
|
|
511
|
+
<b>Rate limit:</b> 5 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
512
|
+
|
|
513
|
+
To use this endpoint, select **Read Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
514
|
+
|
|
515
|
+
|
|
516
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
517
|
+
|
|
518
|
+
Parameters
|
|
519
|
+
----------
|
|
520
|
+
start_time : str
|
|
521
|
+
A start time in RFC 3339 format. Defaults to now if not provided. Millisecond precision and timezones are supported. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).
|
|
522
|
+
|
|
523
|
+
after : typing.Optional[str]
|
|
524
|
+
If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.
|
|
525
|
+
|
|
526
|
+
end_time : typing.Optional[str]
|
|
527
|
+
An end time in RFC 3339 format. Defaults to now if not provided. Millisecond precision and timezones are supported. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).
|
|
528
|
+
|
|
529
|
+
learner_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
530
|
+
Optional string of comma separated learner IDs. If learner ID is present, training assignments for the specified learner(s) will be returned. Max value for this value is 100 objects. Example: `learnerIds=driver-281474,driver-46282156`
|
|
531
|
+
|
|
532
|
+
course_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
533
|
+
Optional string of comma separated course IDs. If course ID is present, training assignments for the specified course ID(s) will be returned. Max value for this value is 100 objects. Defaults to returning all courses. Example: `courseIds=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
534
|
+
|
|
535
|
+
status : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
536
|
+
Optional string of comma separated values. If status is present, training assignments for the specified status(s) will be returned. Valid values: "notStarted", "inProgress", "completed". Defaults to returning all courses.
|
|
537
|
+
|
|
538
|
+
is_overdue : typing.Optional[bool]
|
|
539
|
+
Optional boolean value. If present, training assignments for the specified overdue status will be returned. Valid values: true, false. Defaults to returning all assignments.
|
|
540
|
+
|
|
541
|
+
category_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
542
|
+
Optional string of comma separated category IDs. If category ID is present, training assignments for the specified category ID(s) will be returned. Max value for this value is 100 objects. Example: `categoryIds=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
543
|
+
|
|
544
|
+
request_options : typing.Optional[RequestOptions]
|
|
545
|
+
Request-specific configuration.
|
|
546
|
+
|
|
547
|
+
Returns
|
|
548
|
+
-------
|
|
549
|
+
HttpResponse[TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody]
|
|
550
|
+
OK response.
|
|
551
|
+
"""
|
|
552
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
553
|
+
"training-assignments/stream",
|
|
554
|
+
method="GET",
|
|
555
|
+
params={
|
|
556
|
+
"after": after,
|
|
557
|
+
"startTime": start_time,
|
|
558
|
+
"endTime": end_time,
|
|
559
|
+
"learnerIds": learner_ids,
|
|
560
|
+
"courseIds": course_ids,
|
|
561
|
+
"status": status,
|
|
562
|
+
"isOverdue": is_overdue,
|
|
563
|
+
"categoryIds": category_ids,
|
|
564
|
+
},
|
|
565
|
+
request_options=request_options,
|
|
566
|
+
)
|
|
567
|
+
try:
|
|
568
|
+
if 200 <= _response.status_code < 300:
|
|
569
|
+
_data = typing.cast(
|
|
570
|
+
TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody,
|
|
571
|
+
parse_obj_as(
|
|
572
|
+
type_=TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody, # type: ignore
|
|
573
|
+
object_=_response.json(),
|
|
574
|
+
),
|
|
575
|
+
)
|
|
576
|
+
return HttpResponse(response=_response, data=_data)
|
|
577
|
+
if _response.status_code == 401:
|
|
578
|
+
raise UnauthorizedError(
|
|
579
|
+
headers=dict(_response.headers),
|
|
580
|
+
body=typing.cast(
|
|
581
|
+
typing.Any,
|
|
582
|
+
parse_obj_as(
|
|
583
|
+
type_=typing.Any, # type: ignore
|
|
584
|
+
object_=_response.json(),
|
|
585
|
+
),
|
|
586
|
+
),
|
|
587
|
+
)
|
|
588
|
+
if _response.status_code == 404:
|
|
589
|
+
raise NotFoundError(
|
|
590
|
+
headers=dict(_response.headers),
|
|
591
|
+
body=typing.cast(
|
|
592
|
+
typing.Any,
|
|
593
|
+
parse_obj_as(
|
|
594
|
+
type_=typing.Any, # type: ignore
|
|
595
|
+
object_=_response.json(),
|
|
596
|
+
),
|
|
597
|
+
),
|
|
598
|
+
)
|
|
599
|
+
if _response.status_code == 405:
|
|
600
|
+
raise MethodNotAllowedError(
|
|
601
|
+
headers=dict(_response.headers),
|
|
602
|
+
body=typing.cast(
|
|
603
|
+
typing.Any,
|
|
604
|
+
parse_obj_as(
|
|
605
|
+
type_=typing.Any, # type: ignore
|
|
606
|
+
object_=_response.json(),
|
|
607
|
+
),
|
|
608
|
+
),
|
|
609
|
+
)
|
|
610
|
+
if _response.status_code == 429:
|
|
611
|
+
raise TooManyRequestsError(
|
|
612
|
+
headers=dict(_response.headers),
|
|
613
|
+
body=typing.cast(
|
|
614
|
+
typing.Any,
|
|
615
|
+
parse_obj_as(
|
|
616
|
+
type_=typing.Any, # type: ignore
|
|
617
|
+
object_=_response.json(),
|
|
618
|
+
),
|
|
619
|
+
),
|
|
620
|
+
)
|
|
621
|
+
if _response.status_code == 500:
|
|
622
|
+
raise InternalServerError(
|
|
623
|
+
headers=dict(_response.headers),
|
|
624
|
+
body=typing.cast(
|
|
625
|
+
typing.Any,
|
|
626
|
+
parse_obj_as(
|
|
627
|
+
type_=typing.Any, # type: ignore
|
|
628
|
+
object_=_response.json(),
|
|
629
|
+
),
|
|
630
|
+
),
|
|
631
|
+
)
|
|
632
|
+
if _response.status_code == 501:
|
|
633
|
+
raise NotImplementedError(
|
|
634
|
+
headers=dict(_response.headers),
|
|
635
|
+
body=typing.cast(
|
|
636
|
+
typing.Any,
|
|
637
|
+
parse_obj_as(
|
|
638
|
+
type_=typing.Any, # type: ignore
|
|
639
|
+
object_=_response.json(),
|
|
640
|
+
),
|
|
641
|
+
),
|
|
642
|
+
)
|
|
643
|
+
if _response.status_code == 502:
|
|
644
|
+
raise BadGatewayError(
|
|
645
|
+
headers=dict(_response.headers),
|
|
646
|
+
body=typing.cast(
|
|
647
|
+
typing.Any,
|
|
648
|
+
parse_obj_as(
|
|
649
|
+
type_=typing.Any, # type: ignore
|
|
650
|
+
object_=_response.json(),
|
|
651
|
+
),
|
|
652
|
+
),
|
|
653
|
+
)
|
|
654
|
+
if _response.status_code == 503:
|
|
655
|
+
raise ServiceUnavailableError(
|
|
656
|
+
headers=dict(_response.headers),
|
|
657
|
+
body=typing.cast(
|
|
658
|
+
typing.Any,
|
|
659
|
+
parse_obj_as(
|
|
660
|
+
type_=typing.Any, # type: ignore
|
|
661
|
+
object_=_response.json(),
|
|
662
|
+
),
|
|
663
|
+
),
|
|
664
|
+
)
|
|
665
|
+
if _response.status_code == 504:
|
|
666
|
+
raise GatewayTimeoutError(
|
|
667
|
+
headers=dict(_response.headers),
|
|
668
|
+
body=typing.cast(
|
|
669
|
+
typing.Any,
|
|
670
|
+
parse_obj_as(
|
|
671
|
+
type_=typing.Any, # type: ignore
|
|
672
|
+
object_=_response.json(),
|
|
673
|
+
),
|
|
674
|
+
),
|
|
675
|
+
)
|
|
676
|
+
_response_json = _response.json()
|
|
677
|
+
except JSONDecodeError:
|
|
678
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
679
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
680
|
+
|
|
681
|
+
|
|
682
|
+
class AsyncRawTrainingAssignmentsClient:
|
|
683
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
684
|
+
self._client_wrapper = client_wrapper
|
|
685
|
+
|
|
686
|
+
async def post_training_assignments(
|
|
687
|
+
self,
|
|
688
|
+
*,
|
|
689
|
+
course_id: str,
|
|
690
|
+
due_at_time: str,
|
|
691
|
+
learner_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
692
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
693
|
+
) -> AsyncHttpResponse[TrainingAssignmentsPostTrainingAssignmentsResponseBody]:
|
|
694
|
+
"""
|
|
695
|
+
Create training assignments. Existing assignments will remain unchanged.
|
|
696
|
+
|
|
697
|
+
<b>Rate limit:</b> 10 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
698
|
+
|
|
699
|
+
To use this endpoint, select **Write Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
700
|
+
|
|
701
|
+
|
|
702
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
703
|
+
|
|
704
|
+
Parameters
|
|
705
|
+
----------
|
|
706
|
+
course_id : str
|
|
707
|
+
String for the course ID.
|
|
708
|
+
|
|
709
|
+
due_at_time : str
|
|
710
|
+
Due date of the training assignment in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
711
|
+
|
|
712
|
+
learner_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
713
|
+
Optional string of comma separated learner IDs. If learner ID is present, training assignments for the specified learner(s) will be returned. Max value for this value is 100 objects. Example: `learnerIds=driver-281474,driver-46282156`
|
|
714
|
+
|
|
715
|
+
request_options : typing.Optional[RequestOptions]
|
|
716
|
+
Request-specific configuration.
|
|
717
|
+
|
|
718
|
+
Returns
|
|
719
|
+
-------
|
|
720
|
+
AsyncHttpResponse[TrainingAssignmentsPostTrainingAssignmentsResponseBody]
|
|
721
|
+
OK response.
|
|
722
|
+
"""
|
|
723
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
724
|
+
"training-assignments",
|
|
725
|
+
method="POST",
|
|
726
|
+
params={
|
|
727
|
+
"courseId": course_id,
|
|
728
|
+
"dueAtTime": due_at_time,
|
|
729
|
+
"learnerIds": learner_ids,
|
|
730
|
+
},
|
|
731
|
+
request_options=request_options,
|
|
732
|
+
)
|
|
733
|
+
try:
|
|
734
|
+
if 200 <= _response.status_code < 300:
|
|
735
|
+
_data = typing.cast(
|
|
736
|
+
TrainingAssignmentsPostTrainingAssignmentsResponseBody,
|
|
737
|
+
parse_obj_as(
|
|
738
|
+
type_=TrainingAssignmentsPostTrainingAssignmentsResponseBody, # type: ignore
|
|
739
|
+
object_=_response.json(),
|
|
740
|
+
),
|
|
741
|
+
)
|
|
742
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
743
|
+
if _response.status_code == 401:
|
|
744
|
+
raise UnauthorizedError(
|
|
745
|
+
headers=dict(_response.headers),
|
|
746
|
+
body=typing.cast(
|
|
747
|
+
typing.Any,
|
|
748
|
+
parse_obj_as(
|
|
749
|
+
type_=typing.Any, # type: ignore
|
|
750
|
+
object_=_response.json(),
|
|
751
|
+
),
|
|
752
|
+
),
|
|
753
|
+
)
|
|
754
|
+
if _response.status_code == 404:
|
|
755
|
+
raise NotFoundError(
|
|
756
|
+
headers=dict(_response.headers),
|
|
757
|
+
body=typing.cast(
|
|
758
|
+
typing.Any,
|
|
759
|
+
parse_obj_as(
|
|
760
|
+
type_=typing.Any, # type: ignore
|
|
761
|
+
object_=_response.json(),
|
|
762
|
+
),
|
|
763
|
+
),
|
|
764
|
+
)
|
|
765
|
+
if _response.status_code == 405:
|
|
766
|
+
raise MethodNotAllowedError(
|
|
767
|
+
headers=dict(_response.headers),
|
|
768
|
+
body=typing.cast(
|
|
769
|
+
typing.Any,
|
|
770
|
+
parse_obj_as(
|
|
771
|
+
type_=typing.Any, # type: ignore
|
|
772
|
+
object_=_response.json(),
|
|
773
|
+
),
|
|
774
|
+
),
|
|
775
|
+
)
|
|
776
|
+
if _response.status_code == 429:
|
|
777
|
+
raise TooManyRequestsError(
|
|
778
|
+
headers=dict(_response.headers),
|
|
779
|
+
body=typing.cast(
|
|
780
|
+
typing.Any,
|
|
781
|
+
parse_obj_as(
|
|
782
|
+
type_=typing.Any, # type: ignore
|
|
783
|
+
object_=_response.json(),
|
|
784
|
+
),
|
|
785
|
+
),
|
|
786
|
+
)
|
|
787
|
+
if _response.status_code == 500:
|
|
788
|
+
raise InternalServerError(
|
|
789
|
+
headers=dict(_response.headers),
|
|
790
|
+
body=typing.cast(
|
|
791
|
+
typing.Any,
|
|
792
|
+
parse_obj_as(
|
|
793
|
+
type_=typing.Any, # type: ignore
|
|
794
|
+
object_=_response.json(),
|
|
795
|
+
),
|
|
796
|
+
),
|
|
797
|
+
)
|
|
798
|
+
if _response.status_code == 501:
|
|
799
|
+
raise NotImplementedError(
|
|
800
|
+
headers=dict(_response.headers),
|
|
801
|
+
body=typing.cast(
|
|
802
|
+
typing.Any,
|
|
803
|
+
parse_obj_as(
|
|
804
|
+
type_=typing.Any, # type: ignore
|
|
805
|
+
object_=_response.json(),
|
|
806
|
+
),
|
|
807
|
+
),
|
|
808
|
+
)
|
|
809
|
+
if _response.status_code == 502:
|
|
810
|
+
raise BadGatewayError(
|
|
811
|
+
headers=dict(_response.headers),
|
|
812
|
+
body=typing.cast(
|
|
813
|
+
typing.Any,
|
|
814
|
+
parse_obj_as(
|
|
815
|
+
type_=typing.Any, # type: ignore
|
|
816
|
+
object_=_response.json(),
|
|
817
|
+
),
|
|
818
|
+
),
|
|
819
|
+
)
|
|
820
|
+
if _response.status_code == 503:
|
|
821
|
+
raise ServiceUnavailableError(
|
|
822
|
+
headers=dict(_response.headers),
|
|
823
|
+
body=typing.cast(
|
|
824
|
+
typing.Any,
|
|
825
|
+
parse_obj_as(
|
|
826
|
+
type_=typing.Any, # type: ignore
|
|
827
|
+
object_=_response.json(),
|
|
828
|
+
),
|
|
829
|
+
),
|
|
830
|
+
)
|
|
831
|
+
if _response.status_code == 504:
|
|
832
|
+
raise GatewayTimeoutError(
|
|
833
|
+
headers=dict(_response.headers),
|
|
834
|
+
body=typing.cast(
|
|
835
|
+
typing.Any,
|
|
836
|
+
parse_obj_as(
|
|
837
|
+
type_=typing.Any, # type: ignore
|
|
838
|
+
object_=_response.json(),
|
|
839
|
+
),
|
|
840
|
+
),
|
|
841
|
+
)
|
|
842
|
+
_response_json = _response.json()
|
|
843
|
+
except JSONDecodeError:
|
|
844
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
845
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
846
|
+
|
|
847
|
+
async def delete_training_assignments(
|
|
848
|
+
self,
|
|
849
|
+
*,
|
|
850
|
+
ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
851
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
852
|
+
) -> AsyncHttpResponse[None]:
|
|
853
|
+
"""
|
|
854
|
+
This endpoint supports batch deletion operations. The response does not indicate which specific deletions, if any, have failed. On a successful deletion or partial failure, a ‘204 No Content’ status is returned.
|
|
855
|
+
|
|
856
|
+
<b>Rate limit:</b> 10 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
857
|
+
|
|
858
|
+
To use this endpoint, select **Write Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
859
|
+
|
|
860
|
+
|
|
861
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
862
|
+
|
|
863
|
+
Parameters
|
|
864
|
+
----------
|
|
865
|
+
ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
866
|
+
String of comma separated assignments IDs. Max value for this value is 100 objects. Example: `ids=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
867
|
+
|
|
868
|
+
request_options : typing.Optional[RequestOptions]
|
|
869
|
+
Request-specific configuration.
|
|
870
|
+
|
|
871
|
+
Returns
|
|
872
|
+
-------
|
|
873
|
+
AsyncHttpResponse[None]
|
|
874
|
+
"""
|
|
875
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
876
|
+
"training-assignments",
|
|
877
|
+
method="DELETE",
|
|
878
|
+
params={
|
|
879
|
+
"ids": ids,
|
|
880
|
+
},
|
|
881
|
+
request_options=request_options,
|
|
882
|
+
)
|
|
883
|
+
try:
|
|
884
|
+
if 200 <= _response.status_code < 300:
|
|
885
|
+
return AsyncHttpResponse(response=_response, data=None)
|
|
886
|
+
if _response.status_code == 401:
|
|
887
|
+
raise UnauthorizedError(
|
|
888
|
+
headers=dict(_response.headers),
|
|
889
|
+
body=typing.cast(
|
|
890
|
+
typing.Any,
|
|
891
|
+
parse_obj_as(
|
|
892
|
+
type_=typing.Any, # type: ignore
|
|
893
|
+
object_=_response.json(),
|
|
894
|
+
),
|
|
895
|
+
),
|
|
896
|
+
)
|
|
897
|
+
if _response.status_code == 404:
|
|
898
|
+
raise NotFoundError(
|
|
899
|
+
headers=dict(_response.headers),
|
|
900
|
+
body=typing.cast(
|
|
901
|
+
typing.Any,
|
|
902
|
+
parse_obj_as(
|
|
903
|
+
type_=typing.Any, # type: ignore
|
|
904
|
+
object_=_response.json(),
|
|
905
|
+
),
|
|
906
|
+
),
|
|
907
|
+
)
|
|
908
|
+
if _response.status_code == 405:
|
|
909
|
+
raise MethodNotAllowedError(
|
|
910
|
+
headers=dict(_response.headers),
|
|
911
|
+
body=typing.cast(
|
|
912
|
+
typing.Any,
|
|
913
|
+
parse_obj_as(
|
|
914
|
+
type_=typing.Any, # type: ignore
|
|
915
|
+
object_=_response.json(),
|
|
916
|
+
),
|
|
917
|
+
),
|
|
918
|
+
)
|
|
919
|
+
if _response.status_code == 429:
|
|
920
|
+
raise TooManyRequestsError(
|
|
921
|
+
headers=dict(_response.headers),
|
|
922
|
+
body=typing.cast(
|
|
923
|
+
typing.Any,
|
|
924
|
+
parse_obj_as(
|
|
925
|
+
type_=typing.Any, # type: ignore
|
|
926
|
+
object_=_response.json(),
|
|
927
|
+
),
|
|
928
|
+
),
|
|
929
|
+
)
|
|
930
|
+
if _response.status_code == 500:
|
|
931
|
+
raise InternalServerError(
|
|
932
|
+
headers=dict(_response.headers),
|
|
933
|
+
body=typing.cast(
|
|
934
|
+
typing.Any,
|
|
935
|
+
parse_obj_as(
|
|
936
|
+
type_=typing.Any, # type: ignore
|
|
937
|
+
object_=_response.json(),
|
|
938
|
+
),
|
|
939
|
+
),
|
|
940
|
+
)
|
|
941
|
+
if _response.status_code == 501:
|
|
942
|
+
raise NotImplementedError(
|
|
943
|
+
headers=dict(_response.headers),
|
|
944
|
+
body=typing.cast(
|
|
945
|
+
typing.Any,
|
|
946
|
+
parse_obj_as(
|
|
947
|
+
type_=typing.Any, # type: ignore
|
|
948
|
+
object_=_response.json(),
|
|
949
|
+
),
|
|
950
|
+
),
|
|
951
|
+
)
|
|
952
|
+
if _response.status_code == 502:
|
|
953
|
+
raise BadGatewayError(
|
|
954
|
+
headers=dict(_response.headers),
|
|
955
|
+
body=typing.cast(
|
|
956
|
+
typing.Any,
|
|
957
|
+
parse_obj_as(
|
|
958
|
+
type_=typing.Any, # type: ignore
|
|
959
|
+
object_=_response.json(),
|
|
960
|
+
),
|
|
961
|
+
),
|
|
962
|
+
)
|
|
963
|
+
if _response.status_code == 503:
|
|
964
|
+
raise ServiceUnavailableError(
|
|
965
|
+
headers=dict(_response.headers),
|
|
966
|
+
body=typing.cast(
|
|
967
|
+
typing.Any,
|
|
968
|
+
parse_obj_as(
|
|
969
|
+
type_=typing.Any, # type: ignore
|
|
970
|
+
object_=_response.json(),
|
|
971
|
+
),
|
|
972
|
+
),
|
|
973
|
+
)
|
|
974
|
+
if _response.status_code == 504:
|
|
975
|
+
raise GatewayTimeoutError(
|
|
976
|
+
headers=dict(_response.headers),
|
|
977
|
+
body=typing.cast(
|
|
978
|
+
typing.Any,
|
|
979
|
+
parse_obj_as(
|
|
980
|
+
type_=typing.Any, # type: ignore
|
|
981
|
+
object_=_response.json(),
|
|
982
|
+
),
|
|
983
|
+
),
|
|
984
|
+
)
|
|
985
|
+
_response_json = _response.json()
|
|
986
|
+
except JSONDecodeError:
|
|
987
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
988
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
989
|
+
|
|
990
|
+
async def patch_training_assignments(
|
|
991
|
+
self,
|
|
992
|
+
*,
|
|
993
|
+
due_at_time: str,
|
|
994
|
+
ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
995
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
996
|
+
) -> AsyncHttpResponse[TrainingAssignmentsPatchTrainingAssignmentsResponseBody]:
|
|
997
|
+
"""
|
|
998
|
+
Update training assignments.
|
|
999
|
+
|
|
1000
|
+
<b>Rate limit:</b> 10 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
1001
|
+
|
|
1002
|
+
To use this endpoint, select **Write Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
1003
|
+
|
|
1004
|
+
|
|
1005
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
1006
|
+
|
|
1007
|
+
Parameters
|
|
1008
|
+
----------
|
|
1009
|
+
due_at_time : str
|
|
1010
|
+
Due date of the training assignment in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
1011
|
+
|
|
1012
|
+
ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
1013
|
+
String of comma separated assignments IDs. Max value for this value is 100 objects. Example: `ids=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
1014
|
+
|
|
1015
|
+
request_options : typing.Optional[RequestOptions]
|
|
1016
|
+
Request-specific configuration.
|
|
1017
|
+
|
|
1018
|
+
Returns
|
|
1019
|
+
-------
|
|
1020
|
+
AsyncHttpResponse[TrainingAssignmentsPatchTrainingAssignmentsResponseBody]
|
|
1021
|
+
OK response.
|
|
1022
|
+
"""
|
|
1023
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1024
|
+
"training-assignments",
|
|
1025
|
+
method="PATCH",
|
|
1026
|
+
params={
|
|
1027
|
+
"ids": ids,
|
|
1028
|
+
"dueAtTime": due_at_time,
|
|
1029
|
+
},
|
|
1030
|
+
request_options=request_options,
|
|
1031
|
+
)
|
|
1032
|
+
try:
|
|
1033
|
+
if 200 <= _response.status_code < 300:
|
|
1034
|
+
_data = typing.cast(
|
|
1035
|
+
TrainingAssignmentsPatchTrainingAssignmentsResponseBody,
|
|
1036
|
+
parse_obj_as(
|
|
1037
|
+
type_=TrainingAssignmentsPatchTrainingAssignmentsResponseBody, # type: ignore
|
|
1038
|
+
object_=_response.json(),
|
|
1039
|
+
),
|
|
1040
|
+
)
|
|
1041
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1042
|
+
if _response.status_code == 401:
|
|
1043
|
+
raise UnauthorizedError(
|
|
1044
|
+
headers=dict(_response.headers),
|
|
1045
|
+
body=typing.cast(
|
|
1046
|
+
typing.Any,
|
|
1047
|
+
parse_obj_as(
|
|
1048
|
+
type_=typing.Any, # type: ignore
|
|
1049
|
+
object_=_response.json(),
|
|
1050
|
+
),
|
|
1051
|
+
),
|
|
1052
|
+
)
|
|
1053
|
+
if _response.status_code == 404:
|
|
1054
|
+
raise NotFoundError(
|
|
1055
|
+
headers=dict(_response.headers),
|
|
1056
|
+
body=typing.cast(
|
|
1057
|
+
typing.Any,
|
|
1058
|
+
parse_obj_as(
|
|
1059
|
+
type_=typing.Any, # type: ignore
|
|
1060
|
+
object_=_response.json(),
|
|
1061
|
+
),
|
|
1062
|
+
),
|
|
1063
|
+
)
|
|
1064
|
+
if _response.status_code == 405:
|
|
1065
|
+
raise MethodNotAllowedError(
|
|
1066
|
+
headers=dict(_response.headers),
|
|
1067
|
+
body=typing.cast(
|
|
1068
|
+
typing.Any,
|
|
1069
|
+
parse_obj_as(
|
|
1070
|
+
type_=typing.Any, # type: ignore
|
|
1071
|
+
object_=_response.json(),
|
|
1072
|
+
),
|
|
1073
|
+
),
|
|
1074
|
+
)
|
|
1075
|
+
if _response.status_code == 429:
|
|
1076
|
+
raise TooManyRequestsError(
|
|
1077
|
+
headers=dict(_response.headers),
|
|
1078
|
+
body=typing.cast(
|
|
1079
|
+
typing.Any,
|
|
1080
|
+
parse_obj_as(
|
|
1081
|
+
type_=typing.Any, # type: ignore
|
|
1082
|
+
object_=_response.json(),
|
|
1083
|
+
),
|
|
1084
|
+
),
|
|
1085
|
+
)
|
|
1086
|
+
if _response.status_code == 500:
|
|
1087
|
+
raise InternalServerError(
|
|
1088
|
+
headers=dict(_response.headers),
|
|
1089
|
+
body=typing.cast(
|
|
1090
|
+
typing.Any,
|
|
1091
|
+
parse_obj_as(
|
|
1092
|
+
type_=typing.Any, # type: ignore
|
|
1093
|
+
object_=_response.json(),
|
|
1094
|
+
),
|
|
1095
|
+
),
|
|
1096
|
+
)
|
|
1097
|
+
if _response.status_code == 501:
|
|
1098
|
+
raise NotImplementedError(
|
|
1099
|
+
headers=dict(_response.headers),
|
|
1100
|
+
body=typing.cast(
|
|
1101
|
+
typing.Any,
|
|
1102
|
+
parse_obj_as(
|
|
1103
|
+
type_=typing.Any, # type: ignore
|
|
1104
|
+
object_=_response.json(),
|
|
1105
|
+
),
|
|
1106
|
+
),
|
|
1107
|
+
)
|
|
1108
|
+
if _response.status_code == 502:
|
|
1109
|
+
raise BadGatewayError(
|
|
1110
|
+
headers=dict(_response.headers),
|
|
1111
|
+
body=typing.cast(
|
|
1112
|
+
typing.Any,
|
|
1113
|
+
parse_obj_as(
|
|
1114
|
+
type_=typing.Any, # type: ignore
|
|
1115
|
+
object_=_response.json(),
|
|
1116
|
+
),
|
|
1117
|
+
),
|
|
1118
|
+
)
|
|
1119
|
+
if _response.status_code == 503:
|
|
1120
|
+
raise ServiceUnavailableError(
|
|
1121
|
+
headers=dict(_response.headers),
|
|
1122
|
+
body=typing.cast(
|
|
1123
|
+
typing.Any,
|
|
1124
|
+
parse_obj_as(
|
|
1125
|
+
type_=typing.Any, # type: ignore
|
|
1126
|
+
object_=_response.json(),
|
|
1127
|
+
),
|
|
1128
|
+
),
|
|
1129
|
+
)
|
|
1130
|
+
if _response.status_code == 504:
|
|
1131
|
+
raise GatewayTimeoutError(
|
|
1132
|
+
headers=dict(_response.headers),
|
|
1133
|
+
body=typing.cast(
|
|
1134
|
+
typing.Any,
|
|
1135
|
+
parse_obj_as(
|
|
1136
|
+
type_=typing.Any, # type: ignore
|
|
1137
|
+
object_=_response.json(),
|
|
1138
|
+
),
|
|
1139
|
+
),
|
|
1140
|
+
)
|
|
1141
|
+
_response_json = _response.json()
|
|
1142
|
+
except JSONDecodeError:
|
|
1143
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1144
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1145
|
+
|
|
1146
|
+
async def get_training_assignments_stream(
|
|
1147
|
+
self,
|
|
1148
|
+
*,
|
|
1149
|
+
start_time: str,
|
|
1150
|
+
after: typing.Optional[str] = None,
|
|
1151
|
+
end_time: typing.Optional[str] = None,
|
|
1152
|
+
learner_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
1153
|
+
course_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
1154
|
+
status: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
1155
|
+
is_overdue: typing.Optional[bool] = None,
|
|
1156
|
+
category_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
|
|
1157
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1158
|
+
) -> AsyncHttpResponse[TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody]:
|
|
1159
|
+
"""
|
|
1160
|
+
Returns all training assignments data that has been created or modified for your organization based on the time parameters passed in. Results are paginated and are sorted by last modified date. If you include an endTime, the endpoint will return data up until that point (exclusive). If you don't include an endTime, the API will continue to poll with the pagination cursor that gets returned on every call. The hasNextPage response value will be true if there is no endTime specified and endCursor is nonempty.
|
|
1161
|
+
|
|
1162
|
+
<b>Rate limit:</b> 5 requests/sec (learn more about rate limits <a href="https://developers.samsara.com/docs/rate-limits" target="_blank">here</a>).
|
|
1163
|
+
|
|
1164
|
+
To use this endpoint, select **Read Training Assignments** under the Training Assignments category when creating or editing an API token. <a href="https://developers.samsara.com/docs/authentication#scopes-for-api-tokens" target="_blank">Learn More.</a>
|
|
1165
|
+
|
|
1166
|
+
|
|
1167
|
+
**Submit Feedback**: Likes, dislikes, and API feature requests should be filed as feedback in our <a href="https://forms.gle/zkD4NCH7HjKb7mm69" target="_blank">API feedback form</a>. If you encountered an issue or noticed inaccuracies in the API documentation, please <a href="https://www.samsara.com/help" target="_blank">submit a case</a> to our support team.
|
|
1168
|
+
|
|
1169
|
+
Parameters
|
|
1170
|
+
----------
|
|
1171
|
+
start_time : str
|
|
1172
|
+
A start time in RFC 3339 format. Defaults to now if not provided. Millisecond precision and timezones are supported. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).
|
|
1173
|
+
|
|
1174
|
+
after : typing.Optional[str]
|
|
1175
|
+
If specified, this should be the endCursor value from the previous page of results. When present, this request will return the next page of results that occur immediately after the previous page of results.
|
|
1176
|
+
|
|
1177
|
+
end_time : typing.Optional[str]
|
|
1178
|
+
An end time in RFC 3339 format. Defaults to now if not provided. Millisecond precision and timezones are supported. (Examples: 2019-06-13T19:08:25Z, 2019-06-13T19:08:25.455Z, OR 2015-09-15T14:00:12-04:00).
|
|
1179
|
+
|
|
1180
|
+
learner_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
1181
|
+
Optional string of comma separated learner IDs. If learner ID is present, training assignments for the specified learner(s) will be returned. Max value for this value is 100 objects. Example: `learnerIds=driver-281474,driver-46282156`
|
|
1182
|
+
|
|
1183
|
+
course_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
1184
|
+
Optional string of comma separated course IDs. If course ID is present, training assignments for the specified course ID(s) will be returned. Max value for this value is 100 objects. Defaults to returning all courses. Example: `courseIds=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
1185
|
+
|
|
1186
|
+
status : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
1187
|
+
Optional string of comma separated values. If status is present, training assignments for the specified status(s) will be returned. Valid values: "notStarted", "inProgress", "completed". Defaults to returning all courses.
|
|
1188
|
+
|
|
1189
|
+
is_overdue : typing.Optional[bool]
|
|
1190
|
+
Optional boolean value. If present, training assignments for the specified overdue status will be returned. Valid values: true, false. Defaults to returning all assignments.
|
|
1191
|
+
|
|
1192
|
+
category_ids : typing.Optional[typing.Union[str, typing.Sequence[str]]]
|
|
1193
|
+
Optional string of comma separated category IDs. If category ID is present, training assignments for the specified category ID(s) will be returned. Max value for this value is 100 objects. Example: `categoryIds=a4db8702-79d5-4396-a717-e301d52ecc11,c6490f6a-d84e-49b5-b0ad-b6baae304075`
|
|
1194
|
+
|
|
1195
|
+
request_options : typing.Optional[RequestOptions]
|
|
1196
|
+
Request-specific configuration.
|
|
1197
|
+
|
|
1198
|
+
Returns
|
|
1199
|
+
-------
|
|
1200
|
+
AsyncHttpResponse[TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody]
|
|
1201
|
+
OK response.
|
|
1202
|
+
"""
|
|
1203
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1204
|
+
"training-assignments/stream",
|
|
1205
|
+
method="GET",
|
|
1206
|
+
params={
|
|
1207
|
+
"after": after,
|
|
1208
|
+
"startTime": start_time,
|
|
1209
|
+
"endTime": end_time,
|
|
1210
|
+
"learnerIds": learner_ids,
|
|
1211
|
+
"courseIds": course_ids,
|
|
1212
|
+
"status": status,
|
|
1213
|
+
"isOverdue": is_overdue,
|
|
1214
|
+
"categoryIds": category_ids,
|
|
1215
|
+
},
|
|
1216
|
+
request_options=request_options,
|
|
1217
|
+
)
|
|
1218
|
+
try:
|
|
1219
|
+
if 200 <= _response.status_code < 300:
|
|
1220
|
+
_data = typing.cast(
|
|
1221
|
+
TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody,
|
|
1222
|
+
parse_obj_as(
|
|
1223
|
+
type_=TrainingAssignmentsGetTrainingAssignmentsStreamResponseBody, # type: ignore
|
|
1224
|
+
object_=_response.json(),
|
|
1225
|
+
),
|
|
1226
|
+
)
|
|
1227
|
+
return AsyncHttpResponse(response=_response, data=_data)
|
|
1228
|
+
if _response.status_code == 401:
|
|
1229
|
+
raise UnauthorizedError(
|
|
1230
|
+
headers=dict(_response.headers),
|
|
1231
|
+
body=typing.cast(
|
|
1232
|
+
typing.Any,
|
|
1233
|
+
parse_obj_as(
|
|
1234
|
+
type_=typing.Any, # type: ignore
|
|
1235
|
+
object_=_response.json(),
|
|
1236
|
+
),
|
|
1237
|
+
),
|
|
1238
|
+
)
|
|
1239
|
+
if _response.status_code == 404:
|
|
1240
|
+
raise NotFoundError(
|
|
1241
|
+
headers=dict(_response.headers),
|
|
1242
|
+
body=typing.cast(
|
|
1243
|
+
typing.Any,
|
|
1244
|
+
parse_obj_as(
|
|
1245
|
+
type_=typing.Any, # type: ignore
|
|
1246
|
+
object_=_response.json(),
|
|
1247
|
+
),
|
|
1248
|
+
),
|
|
1249
|
+
)
|
|
1250
|
+
if _response.status_code == 405:
|
|
1251
|
+
raise MethodNotAllowedError(
|
|
1252
|
+
headers=dict(_response.headers),
|
|
1253
|
+
body=typing.cast(
|
|
1254
|
+
typing.Any,
|
|
1255
|
+
parse_obj_as(
|
|
1256
|
+
type_=typing.Any, # type: ignore
|
|
1257
|
+
object_=_response.json(),
|
|
1258
|
+
),
|
|
1259
|
+
),
|
|
1260
|
+
)
|
|
1261
|
+
if _response.status_code == 429:
|
|
1262
|
+
raise TooManyRequestsError(
|
|
1263
|
+
headers=dict(_response.headers),
|
|
1264
|
+
body=typing.cast(
|
|
1265
|
+
typing.Any,
|
|
1266
|
+
parse_obj_as(
|
|
1267
|
+
type_=typing.Any, # type: ignore
|
|
1268
|
+
object_=_response.json(),
|
|
1269
|
+
),
|
|
1270
|
+
),
|
|
1271
|
+
)
|
|
1272
|
+
if _response.status_code == 500:
|
|
1273
|
+
raise InternalServerError(
|
|
1274
|
+
headers=dict(_response.headers),
|
|
1275
|
+
body=typing.cast(
|
|
1276
|
+
typing.Any,
|
|
1277
|
+
parse_obj_as(
|
|
1278
|
+
type_=typing.Any, # type: ignore
|
|
1279
|
+
object_=_response.json(),
|
|
1280
|
+
),
|
|
1281
|
+
),
|
|
1282
|
+
)
|
|
1283
|
+
if _response.status_code == 501:
|
|
1284
|
+
raise NotImplementedError(
|
|
1285
|
+
headers=dict(_response.headers),
|
|
1286
|
+
body=typing.cast(
|
|
1287
|
+
typing.Any,
|
|
1288
|
+
parse_obj_as(
|
|
1289
|
+
type_=typing.Any, # type: ignore
|
|
1290
|
+
object_=_response.json(),
|
|
1291
|
+
),
|
|
1292
|
+
),
|
|
1293
|
+
)
|
|
1294
|
+
if _response.status_code == 502:
|
|
1295
|
+
raise BadGatewayError(
|
|
1296
|
+
headers=dict(_response.headers),
|
|
1297
|
+
body=typing.cast(
|
|
1298
|
+
typing.Any,
|
|
1299
|
+
parse_obj_as(
|
|
1300
|
+
type_=typing.Any, # type: ignore
|
|
1301
|
+
object_=_response.json(),
|
|
1302
|
+
),
|
|
1303
|
+
),
|
|
1304
|
+
)
|
|
1305
|
+
if _response.status_code == 503:
|
|
1306
|
+
raise ServiceUnavailableError(
|
|
1307
|
+
headers=dict(_response.headers),
|
|
1308
|
+
body=typing.cast(
|
|
1309
|
+
typing.Any,
|
|
1310
|
+
parse_obj_as(
|
|
1311
|
+
type_=typing.Any, # type: ignore
|
|
1312
|
+
object_=_response.json(),
|
|
1313
|
+
),
|
|
1314
|
+
),
|
|
1315
|
+
)
|
|
1316
|
+
if _response.status_code == 504:
|
|
1317
|
+
raise GatewayTimeoutError(
|
|
1318
|
+
headers=dict(_response.headers),
|
|
1319
|
+
body=typing.cast(
|
|
1320
|
+
typing.Any,
|
|
1321
|
+
parse_obj_as(
|
|
1322
|
+
type_=typing.Any, # type: ignore
|
|
1323
|
+
object_=_response.json(),
|
|
1324
|
+
),
|
|
1325
|
+
),
|
|
1326
|
+
)
|
|
1327
|
+
_response_json = _response.json()
|
|
1328
|
+
except JSONDecodeError:
|
|
1329
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1330
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|