samsara-api 4.0.1__py3-none-any.whl → 4.1.0__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (135) hide show
  1. samsara/__init__.py +138 -0
  2. samsara/client.py +19 -0
  3. samsara/core/client_wrapper.py +2 -2
  4. samsara/route_events/__init__.py +4 -0
  5. samsara/route_events/client.py +176 -0
  6. samsara/route_events/raw_client.py +362 -0
  7. samsara/types/__init__.py +155 -0
  8. samsara/types/door_open_response_body.py +28 -0
  9. samsara/types/route_event_details_response_body.py +36 -0
  10. samsara/types/route_event_response_response_body.py +56 -0
  11. samsara/types/route_event_response_response_body_event_type.py +17 -0
  12. samsara/types/route_event_route_response_response_body.py +35 -0
  13. samsara/types/route_event_stop_response_response_body.py +35 -0
  14. samsara/types/routes_get_route_events_stream_bad_gateway_error_response_body.py +33 -0
  15. samsara/types/routes_get_route_events_stream_gateway_timeout_error_response_body.py +33 -0
  16. samsara/types/routes_get_route_events_stream_internal_server_error_response_body.py +33 -0
  17. samsara/types/routes_get_route_events_stream_method_not_allowed_error_response_body.py +33 -0
  18. samsara/types/routes_get_route_events_stream_not_found_error_response_body.py +33 -0
  19. samsara/types/routes_get_route_events_stream_not_implemented_error_response_body.py +33 -0
  20. samsara/types/routes_get_route_events_stream_response_body.py +26 -0
  21. samsara/types/routes_get_route_events_stream_service_unavailable_error_response_body.py +33 -0
  22. samsara/types/routes_get_route_events_stream_too_many_requests_error_response_body.py +33 -0
  23. samsara/types/routes_get_route_events_stream_unauthorized_error_response_body.py +33 -0
  24. samsara/types/safety_event.py +6 -6
  25. samsara/types/safety_event_driver.py +5 -0
  26. samsara/types/safety_event_location.py +5 -0
  27. samsara/types/safety_event_vehicle.py +5 -0
  28. samsara/types/stop_eta_updated_event_details_response_body.py +33 -0
  29. samsara/types/stop_task_completed_event_details_response_body.py +36 -0
  30. samsara/types/stop_task_completed_event_details_response_body_task_type.py +5 -0
  31. samsara/types/stop_task_skipped_event_details_response_body.py +36 -0
  32. samsara/types/stop_task_skipped_event_details_response_body_task_type.py +5 -0
  33. samsara/types/vehicle.py +28 -16
  34. samsara/types/vehicle_aux_input_type_1.py +5 -0
  35. samsara/types/vehicle_aux_input_type_10.py +5 -0
  36. samsara/types/vehicle_aux_input_type_11.py +5 -0
  37. samsara/types/vehicle_aux_input_type_12.py +5 -0
  38. samsara/types/vehicle_aux_input_type_13.py +5 -0
  39. samsara/types/vehicle_aux_input_type_2.py +5 -0
  40. samsara/types/vehicle_aux_input_type_3.py +5 -0
  41. samsara/types/vehicle_aux_input_type_4.py +5 -0
  42. samsara/types/vehicle_aux_input_type_5.py +5 -0
  43. samsara/types/vehicle_aux_input_type_6.py +5 -0
  44. samsara/types/vehicle_aux_input_type_7.py +5 -0
  45. samsara/types/vehicle_aux_input_type_8.py +5 -0
  46. samsara/types/vehicle_aux_input_type_9.py +5 -0
  47. samsara/types/vehicle_location.py +6 -4
  48. samsara/types/vehicle_location_reverse_geo.py +5 -0
  49. samsara/types/vehicle_location_time.py +5 -0
  50. samsara/types/vehicle_static_assigned_driver.py +5 -0
  51. samsara/types/vehicle_stats_ambient_air_temp_milli_c.py +2 -2
  52. samsara/types/vehicle_stats_ambient_air_temp_milli_c_with_decoration.py +2 -2
  53. samsara/types/vehicle_stats_barometric_pressure_pa.py +2 -2
  54. samsara/types/vehicle_stats_barometric_pressure_pa_with_decoration.py +2 -2
  55. samsara/types/vehicle_stats_battery_voltage.py +2 -2
  56. samsara/types/vehicle_stats_battery_voltage_with_decoration.py +2 -2
  57. samsara/types/vehicle_stats_decorations.py +4 -0
  58. samsara/types/vehicle_stats_decorations_gps.py +4 -2
  59. samsara/types/vehicle_stats_def_level_milli_percent.py +2 -2
  60. samsara/types/vehicle_stats_def_level_milli_percent_with_decoration.py +2 -2
  61. samsara/types/vehicle_stats_ecu_door_status.py +29 -0
  62. samsara/types/vehicle_stats_ecu_door_status_value.py +5 -0
  63. samsara/types/vehicle_stats_ecu_speed_mph.py +2 -2
  64. samsara/types/vehicle_stats_ecu_speed_mph_with_decoration.py +2 -2
  65. samsara/types/vehicle_stats_engine_coolant_temp_milli_c.py +2 -2
  66. samsara/types/vehicle_stats_engine_coolant_temp_milli_c_with_decoration.py +2 -2
  67. samsara/types/vehicle_stats_engine_load_percent.py +2 -2
  68. samsara/types/vehicle_stats_engine_load_percent_with_decoration.py +2 -2
  69. samsara/types/vehicle_stats_engine_oil_pressure_k_pa.py +2 -2
  70. samsara/types/vehicle_stats_engine_oil_pressure_k_pa_with_decoration.py +2 -2
  71. samsara/types/vehicle_stats_engine_rpm.py +2 -2
  72. samsara/types/vehicle_stats_engine_rpm_with_decoration.py +2 -2
  73. samsara/types/vehicle_stats_engine_state.py +2 -2
  74. samsara/types/vehicle_stats_engine_state_with_decoration.py +2 -2
  75. samsara/types/vehicle_stats_ev_average_battery_temperature_milli_celsius.py +2 -2
  76. samsara/types/vehicle_stats_ev_battery_current_milli_amp.py +2 -2
  77. samsara/types/vehicle_stats_ev_battery_state_of_health_milli_percent.py +2 -2
  78. samsara/types/vehicle_stats_ev_battery_voltage_milli_volt.py +2 -2
  79. samsara/types/vehicle_stats_ev_charging_current_milli_amp.py +2 -2
  80. samsara/types/vehicle_stats_ev_charging_energy_micro_wh.py +2 -2
  81. samsara/types/vehicle_stats_ev_charging_status.py +2 -2
  82. samsara/types/vehicle_stats_ev_charging_voltage_milli_volt.py +2 -2
  83. samsara/types/vehicle_stats_ev_consumed_energy_micro_wh.py +2 -2
  84. samsara/types/vehicle_stats_ev_distance_driven_meters.py +2 -2
  85. samsara/types/vehicle_stats_ev_regenerated_energy_micro_wh.py +2 -2
  86. samsara/types/vehicle_stats_ev_state_of_charge_milli_percent.py +2 -2
  87. samsara/types/vehicle_stats_fault_codes_with_decoration.py +2 -2
  88. samsara/types/vehicle_stats_fuel_consumed_milliliters.py +2 -2
  89. samsara/types/vehicle_stats_fuel_consumed_milliliters_with_decoration.py +2 -2
  90. samsara/types/vehicle_stats_fuel_percent.py +2 -2
  91. samsara/types/vehicle_stats_fuel_percent_with_decoration.py +2 -2
  92. samsara/types/vehicle_stats_gps.py +6 -4
  93. samsara/types/vehicle_stats_gps_distance_meters.py +2 -2
  94. samsara/types/vehicle_stats_gps_distance_meters_with_decoration.py +2 -2
  95. samsara/types/vehicle_stats_gps_odometer_meters.py +2 -2
  96. samsara/types/vehicle_stats_gps_odometer_meters_with_decoration.py +2 -2
  97. samsara/types/vehicle_stats_idling_duration_milliseconds.py +2 -2
  98. samsara/types/vehicle_stats_idling_duration_milliseconds_with_decoration.py +2 -2
  99. samsara/types/vehicle_stats_intake_manifold_temp_milli_c.py +2 -2
  100. samsara/types/vehicle_stats_intake_manifold_temp_milli_c_with_decoration.py +2 -2
  101. samsara/types/vehicle_stats_list_gps.py +6 -4
  102. samsara/types/vehicle_stats_list_response_data.py +8 -0
  103. samsara/types/vehicle_stats_obd_engine_seconds.py +2 -2
  104. samsara/types/vehicle_stats_obd_engine_seconds_with_decoration.py +2 -2
  105. samsara/types/vehicle_stats_obd_odometer_meters.py +2 -2
  106. samsara/types/vehicle_stats_obd_odometer_meters_with_decoration.py +2 -2
  107. samsara/types/vehicle_stats_response_data.py +4 -0
  108. samsara/types/vehicle_stats_response_ecu_door_status.py +32 -0
  109. samsara/types/vehicle_stats_response_ecu_door_status_value.py +5 -0
  110. samsara/types/vehicle_stats_seatbelt_driver.py +2 -2
  111. samsara/types/vehicle_stats_spreader_active.py +2 -2
  112. samsara/types/vehicle_stats_spreader_air_temp.py +2 -2
  113. samsara/types/vehicle_stats_spreader_blast_state.py +2 -2
  114. samsara/types/vehicle_stats_spreader_granular_name.py +2 -2
  115. samsara/types/vehicle_stats_spreader_granular_rate.py +2 -2
  116. samsara/types/vehicle_stats_spreader_liquid_name.py +2 -2
  117. samsara/types/vehicle_stats_spreader_liquid_rate.py +2 -2
  118. samsara/types/vehicle_stats_spreader_on_state.py +2 -2
  119. samsara/types/vehicle_stats_spreader_plow_status.py +2 -2
  120. samsara/types/vehicle_stats_spreader_prewet_name.py +2 -2
  121. samsara/types/vehicle_stats_spreader_prewet_rate.py +2 -2
  122. samsara/types/vehicle_stats_spreader_road_temp.py +2 -2
  123. samsara/types/vehicle_stats_time.py +5 -0
  124. samsara/types/workflow_incident_details_object_response_body.py +4 -0
  125. samsara/vehicle_stats/client.py +10 -0
  126. samsara/vehicle_stats/raw_client.py +10 -0
  127. samsara/vehicle_stats/types/get_vehicle_stats_feed_request_decorations_item.py +1 -0
  128. samsara/vehicle_stats/types/get_vehicle_stats_feed_request_types_item.py +1 -0
  129. samsara/vehicle_stats/types/get_vehicle_stats_history_request_decorations_item.py +1 -0
  130. samsara/vehicle_stats/types/get_vehicle_stats_history_request_types_item.py +1 -0
  131. samsara/vehicle_stats/types/get_vehicle_stats_request_types_item.py +1 -0
  132. {samsara_api-4.0.1.dist-info → samsara_api-4.1.0.dist-info}/METADATA +1 -1
  133. {samsara_api-4.0.1.dist-info → samsara_api-4.1.0.dist-info}/RECORD +135 -87
  134. {samsara_api-4.0.1.dist-info → samsara_api-4.1.0.dist-info}/LICENSE +0 -0
  135. {samsara_api-4.0.1.dist-info → samsara_api-4.1.0.dist-info}/WHEEL +0 -0
@@ -0,0 +1,362 @@
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.routes_get_route_events_stream_response_body import RoutesGetRouteEventsStreamResponseBody
21
+
22
+
23
+ class RawRouteEventsClient:
24
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
25
+ self._client_wrapper = client_wrapper
26
+
27
+ def get_route_events_stream(
28
+ self,
29
+ *,
30
+ after: typing.Optional[str] = None,
31
+ start_time: typing.Optional[str] = None,
32
+ limit: typing.Optional[int] = None,
33
+ include_external_ids: typing.Optional[bool] = None,
34
+ request_options: typing.Optional[RequestOptions] = None,
35
+ ) -> HttpResponse[RoutesGetRouteEventsStreamResponseBody]:
36
+ """
37
+ Subscribes to a feed of immutable, append-only updates for routes. The initial request to this feed endpoint returns a cursor, which can be used in subsequent requests to fetch events on all routes that occurred after the last retrieved event. An initial request (with empty after and startTime parameters) will return events from the past 24 hours.
38
+
39
+ <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>).
40
+
41
+ To use this endpoint, select **Read Routes** under the Driver Workflow 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>
42
+
43
+
44
+ **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.
45
+
46
+ Parameters
47
+ ----------
48
+ after : typing.Optional[str]
49
+ 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.
50
+
51
+ start_time : typing.Optional[str]
52
+ A start time in RFC 3339 format. Defaults to 24 hours ago if not provided. Millisecond precision and timezones are supported. (Examples: 2025-07-01T19:08:25Z, 2025-07-01T19:08:25.455Z, OR 2025-07-01T14:00:12-04:00). Cannot be more than 7 days in the past.
53
+
54
+ limit : typing.Optional[int]
55
+ The limit for how many events will be in the response. Default and max for this value is 200 events.
56
+
57
+ include_external_ids : typing.Optional[bool]
58
+ Optional boolean indicating whether to return external IDs on supported entities
59
+
60
+ request_options : typing.Optional[RequestOptions]
61
+ Request-specific configuration.
62
+
63
+ Returns
64
+ -------
65
+ HttpResponse[RoutesGetRouteEventsStreamResponseBody]
66
+ OK response.
67
+ """
68
+ _response = self._client_wrapper.httpx_client.request(
69
+ "route-events/stream",
70
+ method="GET",
71
+ params={
72
+ "after": after,
73
+ "startTime": start_time,
74
+ "limit": limit,
75
+ "includeExternalIds": include_external_ids,
76
+ },
77
+ request_options=request_options,
78
+ )
79
+ try:
80
+ if 200 <= _response.status_code < 300:
81
+ _data = typing.cast(
82
+ RoutesGetRouteEventsStreamResponseBody,
83
+ parse_obj_as(
84
+ type_=RoutesGetRouteEventsStreamResponseBody, # type: ignore
85
+ object_=_response.json(),
86
+ ),
87
+ )
88
+ return HttpResponse(response=_response, data=_data)
89
+ if _response.status_code == 401:
90
+ raise UnauthorizedError(
91
+ headers=dict(_response.headers),
92
+ body=typing.cast(
93
+ typing.Optional[typing.Any],
94
+ parse_obj_as(
95
+ type_=typing.Optional[typing.Any], # type: ignore
96
+ object_=_response.json(),
97
+ ),
98
+ ),
99
+ )
100
+ if _response.status_code == 404:
101
+ raise NotFoundError(
102
+ headers=dict(_response.headers),
103
+ body=typing.cast(
104
+ typing.Optional[typing.Any],
105
+ parse_obj_as(
106
+ type_=typing.Optional[typing.Any], # type: ignore
107
+ object_=_response.json(),
108
+ ),
109
+ ),
110
+ )
111
+ if _response.status_code == 405:
112
+ raise MethodNotAllowedError(
113
+ headers=dict(_response.headers),
114
+ body=typing.cast(
115
+ typing.Optional[typing.Any],
116
+ parse_obj_as(
117
+ type_=typing.Optional[typing.Any], # type: ignore
118
+ object_=_response.json(),
119
+ ),
120
+ ),
121
+ )
122
+ if _response.status_code == 429:
123
+ raise TooManyRequestsError(
124
+ headers=dict(_response.headers),
125
+ body=typing.cast(
126
+ typing.Optional[typing.Any],
127
+ parse_obj_as(
128
+ type_=typing.Optional[typing.Any], # type: ignore
129
+ object_=_response.json(),
130
+ ),
131
+ ),
132
+ )
133
+ if _response.status_code == 500:
134
+ raise InternalServerError(
135
+ headers=dict(_response.headers),
136
+ body=typing.cast(
137
+ typing.Optional[typing.Any],
138
+ parse_obj_as(
139
+ type_=typing.Optional[typing.Any], # type: ignore
140
+ object_=_response.json(),
141
+ ),
142
+ ),
143
+ )
144
+ if _response.status_code == 501:
145
+ raise NotImplementedError(
146
+ headers=dict(_response.headers),
147
+ body=typing.cast(
148
+ typing.Optional[typing.Any],
149
+ parse_obj_as(
150
+ type_=typing.Optional[typing.Any], # type: ignore
151
+ object_=_response.json(),
152
+ ),
153
+ ),
154
+ )
155
+ if _response.status_code == 502:
156
+ raise BadGatewayError(
157
+ headers=dict(_response.headers),
158
+ body=typing.cast(
159
+ typing.Optional[typing.Any],
160
+ parse_obj_as(
161
+ type_=typing.Optional[typing.Any], # type: ignore
162
+ object_=_response.json(),
163
+ ),
164
+ ),
165
+ )
166
+ if _response.status_code == 503:
167
+ raise ServiceUnavailableError(
168
+ headers=dict(_response.headers),
169
+ body=typing.cast(
170
+ typing.Optional[typing.Any],
171
+ parse_obj_as(
172
+ type_=typing.Optional[typing.Any], # type: ignore
173
+ object_=_response.json(),
174
+ ),
175
+ ),
176
+ )
177
+ if _response.status_code == 504:
178
+ raise GatewayTimeoutError(
179
+ headers=dict(_response.headers),
180
+ body=typing.cast(
181
+ typing.Optional[typing.Any],
182
+ parse_obj_as(
183
+ type_=typing.Optional[typing.Any], # type: ignore
184
+ object_=_response.json(),
185
+ ),
186
+ ),
187
+ )
188
+ _response_json = _response.json()
189
+ except JSONDecodeError:
190
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
191
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
192
+
193
+
194
+ class AsyncRawRouteEventsClient:
195
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
196
+ self._client_wrapper = client_wrapper
197
+
198
+ async def get_route_events_stream(
199
+ self,
200
+ *,
201
+ after: typing.Optional[str] = None,
202
+ start_time: typing.Optional[str] = None,
203
+ limit: typing.Optional[int] = None,
204
+ include_external_ids: typing.Optional[bool] = None,
205
+ request_options: typing.Optional[RequestOptions] = None,
206
+ ) -> AsyncHttpResponse[RoutesGetRouteEventsStreamResponseBody]:
207
+ """
208
+ Subscribes to a feed of immutable, append-only updates for routes. The initial request to this feed endpoint returns a cursor, which can be used in subsequent requests to fetch events on all routes that occurred after the last retrieved event. An initial request (with empty after and startTime parameters) will return events from the past 24 hours.
209
+
210
+ <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>).
211
+
212
+ To use this endpoint, select **Read Routes** under the Driver Workflow 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>
213
+
214
+
215
+ **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.
216
+
217
+ Parameters
218
+ ----------
219
+ after : typing.Optional[str]
220
+ 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.
221
+
222
+ start_time : typing.Optional[str]
223
+ A start time in RFC 3339 format. Defaults to 24 hours ago if not provided. Millisecond precision and timezones are supported. (Examples: 2025-07-01T19:08:25Z, 2025-07-01T19:08:25.455Z, OR 2025-07-01T14:00:12-04:00). Cannot be more than 7 days in the past.
224
+
225
+ limit : typing.Optional[int]
226
+ The limit for how many events will be in the response. Default and max for this value is 200 events.
227
+
228
+ include_external_ids : typing.Optional[bool]
229
+ Optional boolean indicating whether to return external IDs on supported entities
230
+
231
+ request_options : typing.Optional[RequestOptions]
232
+ Request-specific configuration.
233
+
234
+ Returns
235
+ -------
236
+ AsyncHttpResponse[RoutesGetRouteEventsStreamResponseBody]
237
+ OK response.
238
+ """
239
+ _response = await self._client_wrapper.httpx_client.request(
240
+ "route-events/stream",
241
+ method="GET",
242
+ params={
243
+ "after": after,
244
+ "startTime": start_time,
245
+ "limit": limit,
246
+ "includeExternalIds": include_external_ids,
247
+ },
248
+ request_options=request_options,
249
+ )
250
+ try:
251
+ if 200 <= _response.status_code < 300:
252
+ _data = typing.cast(
253
+ RoutesGetRouteEventsStreamResponseBody,
254
+ parse_obj_as(
255
+ type_=RoutesGetRouteEventsStreamResponseBody, # type: ignore
256
+ object_=_response.json(),
257
+ ),
258
+ )
259
+ return AsyncHttpResponse(response=_response, data=_data)
260
+ if _response.status_code == 401:
261
+ raise UnauthorizedError(
262
+ headers=dict(_response.headers),
263
+ body=typing.cast(
264
+ typing.Optional[typing.Any],
265
+ parse_obj_as(
266
+ type_=typing.Optional[typing.Any], # type: ignore
267
+ object_=_response.json(),
268
+ ),
269
+ ),
270
+ )
271
+ if _response.status_code == 404:
272
+ raise NotFoundError(
273
+ headers=dict(_response.headers),
274
+ body=typing.cast(
275
+ typing.Optional[typing.Any],
276
+ parse_obj_as(
277
+ type_=typing.Optional[typing.Any], # type: ignore
278
+ object_=_response.json(),
279
+ ),
280
+ ),
281
+ )
282
+ if _response.status_code == 405:
283
+ raise MethodNotAllowedError(
284
+ headers=dict(_response.headers),
285
+ body=typing.cast(
286
+ typing.Optional[typing.Any],
287
+ parse_obj_as(
288
+ type_=typing.Optional[typing.Any], # type: ignore
289
+ object_=_response.json(),
290
+ ),
291
+ ),
292
+ )
293
+ if _response.status_code == 429:
294
+ raise TooManyRequestsError(
295
+ headers=dict(_response.headers),
296
+ body=typing.cast(
297
+ typing.Optional[typing.Any],
298
+ parse_obj_as(
299
+ type_=typing.Optional[typing.Any], # type: ignore
300
+ object_=_response.json(),
301
+ ),
302
+ ),
303
+ )
304
+ if _response.status_code == 500:
305
+ raise InternalServerError(
306
+ headers=dict(_response.headers),
307
+ body=typing.cast(
308
+ typing.Optional[typing.Any],
309
+ parse_obj_as(
310
+ type_=typing.Optional[typing.Any], # type: ignore
311
+ object_=_response.json(),
312
+ ),
313
+ ),
314
+ )
315
+ if _response.status_code == 501:
316
+ raise NotImplementedError(
317
+ headers=dict(_response.headers),
318
+ body=typing.cast(
319
+ typing.Optional[typing.Any],
320
+ parse_obj_as(
321
+ type_=typing.Optional[typing.Any], # type: ignore
322
+ object_=_response.json(),
323
+ ),
324
+ ),
325
+ )
326
+ if _response.status_code == 502:
327
+ raise BadGatewayError(
328
+ headers=dict(_response.headers),
329
+ body=typing.cast(
330
+ typing.Optional[typing.Any],
331
+ parse_obj_as(
332
+ type_=typing.Optional[typing.Any], # type: ignore
333
+ object_=_response.json(),
334
+ ),
335
+ ),
336
+ )
337
+ if _response.status_code == 503:
338
+ raise ServiceUnavailableError(
339
+ headers=dict(_response.headers),
340
+ body=typing.cast(
341
+ typing.Optional[typing.Any],
342
+ parse_obj_as(
343
+ type_=typing.Optional[typing.Any], # type: ignore
344
+ object_=_response.json(),
345
+ ),
346
+ ),
347
+ )
348
+ if _response.status_code == 504:
349
+ raise GatewayTimeoutError(
350
+ headers=dict(_response.headers),
351
+ body=typing.cast(
352
+ typing.Optional[typing.Any],
353
+ parse_obj_as(
354
+ type_=typing.Optional[typing.Any], # type: ignore
355
+ object_=_response.json(),
356
+ ),
357
+ ),
358
+ )
359
+ _response_json = _response.json()
360
+ except JSONDecodeError:
361
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
362
+ raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)