samsara-api 0.0.1__py3-none-any.whl → 0.0.3__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 (346) hide show
  1. samsara/__init__.py +298 -38
  2. samsara/alerts/configurations/client.py +25 -11
  3. samsara/alerts/configurations/raw_client.py +47 -8
  4. samsara/alerts/incidents/client.py +21 -11
  5. samsara/alerts/incidents/raw_client.py +43 -9
  6. samsara/assets/client.py +21 -11
  7. samsara/assets/location_and_speed/client.py +21 -13
  8. samsara/assets/location_and_speed/raw_client.py +53 -9
  9. samsara/assets/raw_client.py +53 -8
  10. samsara/attributes/client.py +21 -13
  11. samsara/attributes/raw_client.py +41 -8
  12. samsara/cameras/media/client.py +2 -2
  13. samsara/cameras/media/raw_client.py +2 -2
  14. samsara/cameras/media/retrieval/client.py +2 -12
  15. samsara/cameras/media/types/media_list_request_trigger_reasons_item.py +8 -1
  16. samsara/carrier_proposed_assignments/client.py +21 -11
  17. samsara/carrier_proposed_assignments/raw_client.py +43 -8
  18. samsara/client.py +15 -6
  19. samsara/coaching/driver_coach_assignments/client.py +22 -12
  20. samsara/coaching/driver_coach_assignments/raw_client.py +45 -8
  21. samsara/coaching/sessions/client.py +21 -13
  22. samsara/coaching/sessions/raw_client.py +51 -9
  23. samsara/contacts/client.py +21 -11
  24. samsara/contacts/raw_client.py +39 -8
  25. samsara/core/client_wrapper.py +2 -2
  26. samsara/defect_types/client.py +21 -11
  27. samsara/defect_types/raw_client.py +41 -9
  28. samsara/defects/client.py +124 -9
  29. samsara/defects/raw_client.py +356 -6
  30. samsara/devices/client.py +21 -11
  31. samsara/devices/raw_client.py +45 -9
  32. samsara/document_types/client.py +21 -11
  33. samsara/document_types/raw_client.py +37 -9
  34. samsara/documents/client.py +21 -11
  35. samsara/documents/raw_client.py +45 -8
  36. samsara/driver_trailer_assignments/client.py +23 -13
  37. samsara/driver_trailer_assignments/raw_client.py +43 -8
  38. samsara/drivers/__init__.py +1 -3
  39. samsara/drivers/client.py +21 -21
  40. samsara/drivers/raw_client.py +51 -8
  41. samsara/dvirs/client.py +124 -9
  42. samsara/dvirs/raw_client.py +356 -6
  43. samsara/equipment/__init__.py +2 -2
  44. samsara/equipment/client.py +23 -21
  45. samsara/equipment/locations/client.py +62 -34
  46. samsara/equipment/locations/raw_client.py +132 -27
  47. samsara/equipment/raw_client.py +45 -18
  48. samsara/equipment/stats/__init__.py +2 -2
  49. samsara/equipment/stats/client.py +81 -53
  50. samsara/equipment/stats/raw_client.py +157 -46
  51. samsara/equipment/stats/types/__init__.py +2 -2
  52. samsara/equipment/stats/types/{stats_get_request_types_item.py → stats_list_request_types_item.py} +1 -1
  53. samsara/form_submissions/client.py +46 -54
  54. samsara/form_submissions/pdf_exports/client.py +14 -22
  55. samsara/form_submissions/pdf_exports/raw_client.py +10 -18
  56. samsara/form_submissions/raw_client.py +74 -47
  57. samsara/forms/client.py +138 -0
  58. samsara/{beta → forms}/raw_client.py +37 -62
  59. samsara/function.py +99 -0
  60. samsara/gateways/client.py +21 -11
  61. samsara/gateways/raw_client.py +39 -8
  62. samsara/hos/__init__.py +3 -0
  63. samsara/hos/client.py +218 -11
  64. samsara/hos/raw_client.py +485 -8
  65. samsara/hos/types/__init__.py +7 -0
  66. samsara/hos/types/hos_daily_logs_request_driver_activation_status.py +5 -0
  67. samsara/idling/__init__.py +7 -0
  68. samsara/idling/client.py +287 -0
  69. samsara/idling/raw_client.py +521 -0
  70. samsara/idling/types/__init__.py +7 -0
  71. samsara/idling/types/idling_list_request_pto_state.py +5 -0
  72. samsara/inputs/client.py +21 -11
  73. samsara/inputs/raw_client.py +51 -9
  74. samsara/issues/client.py +27 -29
  75. samsara/issues/raw_client.py +53 -26
  76. samsara/live_shares/client.py +21 -13
  77. samsara/live_shares/raw_client.py +43 -8
  78. samsara/maintenance/service_tasks/client.py +21 -11
  79. samsara/maintenance/service_tasks/raw_client.py +41 -8
  80. samsara/maintenance/work_orders/client.py +40 -22
  81. samsara/maintenance/work_orders/raw_client.py +84 -16
  82. samsara/readings/client.py +524 -0
  83. samsara/readings/raw_client.py +1214 -0
  84. samsara/reports/drivers/fuel_energy/client.py +6 -6
  85. samsara/reports/drivers/fuel_energy/raw_client.py +2 -2
  86. samsara/reports/ifta/__init__.py +4 -4
  87. samsara/reports/ifta/vehicle/__init__.py +2 -2
  88. samsara/reports/ifta/vehicle/client.py +21 -21
  89. samsara/reports/ifta/vehicle/raw_client.py +17 -17
  90. samsara/reports/ifta/vehicle/types/__init__.py +4 -4
  91. samsara/reports/ifta/vehicle/types/{vehicle_get_request_fuel_type.py → vehicle_list_request_fuel_type.py} +1 -1
  92. samsara/reports/ifta/vehicle/types/{vehicle_get_request_month.py → vehicle_list_request_month.py} +1 -1
  93. samsara/reports/ifta/vehicle/types/vehicle_list_request_quarter.py +5 -0
  94. samsara/reports/vehicles/__init__.py +2 -2
  95. samsara/reports/vehicles/fuel_energy/__init__.py +2 -2
  96. samsara/reports/vehicles/fuel_energy/client.py +11 -11
  97. samsara/reports/vehicles/fuel_energy/raw_client.py +7 -7
  98. samsara/reports/vehicles/fuel_energy/types/__init__.py +2 -2
  99. samsara/reports/vehicles/fuel_energy/types/fuel_energy_list_request_energy_type.py +5 -0
  100. samsara/reports/vehicles/idling/client.py +27 -15
  101. samsara/reports/vehicles/idling/raw_client.py +59 -11
  102. samsara/routes/client.py +21 -11
  103. samsara/routes/raw_client.py +43 -8
  104. samsara/safety_events/audit_logs/client.py +21 -13
  105. samsara/safety_events/audit_logs/raw_client.py +39 -9
  106. samsara/safety_events/client.py +21 -11
  107. samsara/safety_events/raw_client.py +47 -9
  108. samsara/speeding_intervals/client.py +25 -17
  109. samsara/speeding_intervals/raw_client.py +55 -13
  110. samsara/tachograph/__init__.py +7 -0
  111. samsara/tachograph/client.py +44 -0
  112. samsara/{drivers/tachograph_files → tachograph/driver}/client.py +162 -15
  113. samsara/{drivers/tachograph_files → tachograph/driver}/raw_client.py +153 -4
  114. samsara/tachograph/raw_client.py +13 -0
  115. samsara/{vehicles/tachograph_files → tachograph/vehicles}/client.py +15 -15
  116. samsara/{vehicles/tachograph_files → tachograph/vehicles}/raw_client.py +4 -4
  117. samsara/tags/client.py +21 -11
  118. samsara/tags/raw_client.py +39 -8
  119. samsara/trailers/client.py +21 -11
  120. samsara/trailers/raw_client.py +43 -8
  121. samsara/training_courses/client.py +21 -11
  122. samsara/training_courses/raw_client.py +43 -9
  123. samsara/trips/client.py +21 -11
  124. samsara/trips/raw_client.py +49 -9
  125. samsara/types/__init__.py +406 -50
  126. samsara/types/advanced_idling_get_idling_events_bad_gateway_error_response_body.py +33 -0
  127. samsara/types/advanced_idling_get_idling_events_gateway_timeout_error_response_body.py +33 -0
  128. samsara/types/{hos_daily_logs_update_shipping_docs_internal_server_error_response_body.py → advanced_idling_get_idling_events_internal_server_error_response_body.py} +1 -1
  129. samsara/types/advanced_idling_get_idling_events_method_not_allowed_error_response_body.py +33 -0
  130. samsara/types/{hos_daily_logs_update_shipping_docs_not_found_error_response_body.py → advanced_idling_get_idling_events_not_found_error_response_body.py} +1 -1
  131. samsara/types/{hos_daily_logs_update_shipping_docs_not_implemented_error_response_body.py → advanced_idling_get_idling_events_not_implemented_error_response_body.py} +1 -1
  132. samsara/types/advanced_idling_get_idling_events_response_body.py +26 -0
  133. samsara/types/{hos_daily_logs_update_shipping_docs_service_unavailable_error_response_body.py → advanced_idling_get_idling_events_service_unavailable_error_response_body.py} +1 -1
  134. samsara/types/{hos_daily_logs_update_shipping_docs_gateway_timeout_error_response_body.py → advanced_idling_get_idling_events_too_many_requests_error_response_body.py} +2 -2
  135. samsara/types/advanced_idling_get_idling_events_unauthorized_error_response_body.py +33 -0
  136. samsara/types/alert_object_asset_response_body.py +63 -0
  137. samsara/types/{assets_create_asset_response_body_type.py → alert_object_asset_response_body_type.py} +1 -1
  138. samsara/types/assets_create_asset_response_body.py +2 -87
  139. samsara/types/assets_update_asset_response_body.py +2 -87
  140. samsara/types/continuous_reading_alert_threshold_response_body.py +49 -0
  141. samsara/types/continuous_reading_alert_threshold_response_body_operation.py +7 -0
  142. samsara/types/continuous_reading_alert_threshold_response_body_unit.py +62 -0
  143. samsara/types/device_response_response_body.py +1 -1
  144. samsara/types/device_response_response_body_model.py +1 -0
  145. samsara/types/dvir_defect_get_defect_bad_gateway_error_response_body.py +33 -0
  146. samsara/types/dvir_defect_get_defect_gateway_timeout_error_response_body.py +33 -0
  147. samsara/types/dvir_defect_get_defect_internal_server_error_response_body.py +33 -0
  148. samsara/types/dvir_defect_get_defect_method_not_allowed_error_response_body.py +33 -0
  149. samsara/types/dvir_defect_get_defect_not_found_error_response_body.py +33 -0
  150. samsara/types/dvir_defect_get_defect_not_implemented_error_response_body.py +33 -0
  151. samsara/types/dvir_defect_get_defect_response_body.py +91 -0
  152. samsara/types/dvir_defect_get_defect_service_unavailable_error_response_body.py +33 -0
  153. samsara/types/dvir_defect_get_defect_too_many_requests_error_response_body.py +33 -0
  154. samsara/types/dvir_defect_get_defect_unauthorized_error_response_body.py +33 -0
  155. samsara/types/dvir_get_dvir_bad_gateway_error_response_body.py +33 -0
  156. samsara/types/dvir_get_dvir_gateway_timeout_error_response_body.py +33 -0
  157. samsara/types/dvir_get_dvir_internal_server_error_response_body.py +33 -0
  158. samsara/types/dvir_get_dvir_method_not_allowed_error_response_body.py +33 -0
  159. samsara/types/dvir_get_dvir_not_found_error_response_body.py +33 -0
  160. samsara/types/dvir_get_dvir_not_implemented_error_response_body.py +33 -0
  161. samsara/types/dvir_get_dvir_response_body.py +99 -0
  162. samsara/types/dvir_get_dvir_response_body_safety_status.py +5 -0
  163. samsara/types/dvir_get_dvir_response_body_type.py +5 -0
  164. samsara/types/dvir_get_dvir_service_unavailable_error_response_body.py +33 -0
  165. samsara/types/dvir_get_dvir_too_many_requests_error_response_body.py +33 -0
  166. samsara/types/dvir_get_dvir_unauthorized_error_response_body.py +33 -0
  167. samsara/types/enum_reading_alert_threshold_response_body.py +31 -0
  168. samsara/types/enum_value_response_body.py +31 -0
  169. samsara/types/equipment_gateway_engine_seconds.py +1 -1
  170. samsara/types/equipment_gateway_j_1939_engine_seconds.py +1 -1
  171. samsara/types/equipment_obd_engine_seconds.py +1 -1
  172. samsara/types/event_location_response_body.py +31 -0
  173. samsara/types/form_submission_request_field_input_object_request_body.py +7 -1
  174. samsara/types/form_submission_request_field_input_object_request_body_type.py +3 -1
  175. samsara/types/{hos_daily_logs_update_shipping_docs_response_body.py → form_submission_request_geofence_object_request_body.py} +9 -3
  176. samsara/types/form_submission_request_geofence_value_object_request_body.py +24 -0
  177. samsara/types/form_submission_response_object_response_body.py +8 -0
  178. samsara/types/{form_template_reference_object_request_body.py → form_template_request_object_request_body.py} +6 -4
  179. samsara/types/form_template_response_object_response_body.py +74 -0
  180. samsara/types/form_template_section_object_response_body.py +47 -0
  181. samsara/types/form_templates_get_form_templates_bad_gateway_error_response_body.py +33 -0
  182. samsara/types/form_templates_get_form_templates_gateway_timeout_error_response_body.py +33 -0
  183. samsara/types/form_templates_get_form_templates_internal_server_error_response_body.py +33 -0
  184. samsara/types/form_templates_get_form_templates_method_not_allowed_error_response_body.py +33 -0
  185. samsara/types/form_templates_get_form_templates_not_found_error_response_body.py +33 -0
  186. samsara/types/form_templates_get_form_templates_not_implemented_error_response_body.py +33 -0
  187. samsara/types/form_templates_get_form_templates_response_body.py +26 -0
  188. samsara/types/form_templates_get_form_templates_service_unavailable_error_response_body.py +33 -0
  189. samsara/types/form_templates_get_form_templates_too_many_requests_error_response_body.py +33 -0
  190. samsara/types/form_templates_get_form_templates_unauthorized_error_response_body.py +33 -0
  191. samsara/types/forms_action_object_response_body.py +43 -0
  192. samsara/types/forms_action_object_response_body_type.py +7 -0
  193. samsara/types/forms_approval_config_object_response_body.py +32 -0
  194. samsara/types/forms_asset_object_response_body.py +8 -1
  195. samsara/types/forms_check_boxes_value_object_response_body.py +7 -0
  196. samsara/types/forms_condition_object_response_body.py +36 -0
  197. samsara/types/forms_condition_object_response_body_type.py +7 -0
  198. samsara/types/forms_conditional_action_object_response_body.py +30 -0
  199. samsara/types/forms_field_definition_object_response_body.py +143 -0
  200. samsara/types/forms_field_definition_object_response_body_allowed_asset_types_item.py +7 -0
  201. samsara/types/forms_field_definition_object_response_body_allowed_date_time_value_type.py +7 -0
  202. samsara/types/forms_field_definition_object_response_body_type.py +22 -0
  203. samsara/types/forms_field_input_object_response_body.py +7 -4
  204. samsara/types/forms_field_input_object_response_body_type.py +20 -0
  205. samsara/types/forms_geofence_object_response_body.py +53 -0
  206. samsara/types/forms_geofence_object_response_body_entry_type.py +5 -0
  207. samsara/types/forms_geofence_value_object_response_body.py +24 -0
  208. samsara/types/forms_multiple_choice_value_object_response_body.py +8 -1
  209. samsara/types/forms_product_submission_approval_details_object_response_body.py +26 -0
  210. samsara/types/forms_select_option_object_response_body.py +47 -0
  211. samsara/types/forms_single_approval_config_object_response_body.py +33 -0
  212. samsara/types/forms_table_cell_object_response_body.py +3 -4
  213. samsara/types/forms_table_cell_object_response_body_type.py +8 -0
  214. samsara/types/forms_table_column_object_response_body.py +3 -4
  215. samsara/types/forms_table_column_object_response_body_type.py +8 -0
  216. samsara/types/forms_table_field_definition_object_response_body.py +91 -0
  217. samsara/types/forms_table_field_definition_object_response_body_allowed_date_time_value_type.py +7 -0
  218. samsara/types/forms_table_field_definition_object_response_body_type.py +8 -0
  219. samsara/types/fuel_cost_object_response_body.py +32 -0
  220. samsara/types/fuel_cost_object_response_body_currency.py +5 -0
  221. samsara/types/fuel_volume_response_body.py +28 -0
  222. samsara/types/fuel_volume_response_body_unit.py +5 -0
  223. samsara/types/gaseous_fuel_cost_object_response_body.py +32 -0
  224. samsara/types/gaseous_fuel_cost_object_response_body_currency.py +7 -0
  225. samsara/types/gateway_details_response_response_body.py +14 -0
  226. samsara/types/harsh_event_trigger_details_object_request_body_types_item.py +1 -0
  227. samsara/types/harsh_event_trigger_details_object_response_body_types_item.py +1 -0
  228. samsara/types/idling_event_object_response_body.py +101 -0
  229. samsara/types/idling_event_object_response_body_address_type.py +17 -0
  230. samsara/types/inline_response_2005.py +24 -0
  231. samsara/types/inline_response_2006.py +24 -0
  232. samsara/types/reading_definition_response_body.py +59 -0
  233. samsara/types/reading_history_response_body.py +47 -0
  234. samsara/types/reading_snapshot_response_body.py +52 -0
  235. samsara/types/reading_trigger_continuous_value_object_request_body.py +51 -0
  236. samsara/types/reading_trigger_continuous_value_object_request_body_operation.py +7 -0
  237. samsara/types/reading_trigger_continuous_value_object_request_body_unit.py +62 -0
  238. samsara/types/reading_trigger_continuous_value_object_response_body.py +51 -0
  239. samsara/types/reading_trigger_continuous_value_object_response_body_operation.py +7 -0
  240. samsara/types/reading_trigger_continuous_value_object_response_body_unit.py +62 -0
  241. samsara/types/reading_trigger_details_object_request_body.py +48 -0
  242. samsara/types/reading_trigger_details_object_response_body.py +48 -0
  243. samsara/types/reading_trigger_details_response_body.py +38 -0
  244. samsara/types/reading_trigger_enum_value_object_request_body.py +31 -0
  245. samsara/types/reading_trigger_enum_value_object_response_body.py +31 -0
  246. samsara/types/reading_type_response_body.py +34 -0
  247. samsara/types/reading_type_response_body_data_type.py +5 -0
  248. samsara/types/readings_get_readings_history_bad_gateway_error_response_body.py +33 -0
  249. samsara/types/{hos_daily_logs_update_shipping_docs_bad_gateway_error_response_body.py → readings_get_readings_history_gateway_timeout_error_response_body.py} +2 -2
  250. samsara/types/readings_get_readings_history_internal_server_error_response_body.py +33 -0
  251. samsara/types/readings_get_readings_history_method_not_allowed_error_response_body.py +33 -0
  252. samsara/types/readings_get_readings_history_not_found_error_response_body.py +33 -0
  253. samsara/types/readings_get_readings_history_not_implemented_error_response_body.py +33 -0
  254. samsara/types/readings_get_readings_history_response_body.py +26 -0
  255. samsara/types/readings_get_readings_history_service_unavailable_error_response_body.py +33 -0
  256. samsara/types/readings_get_readings_history_too_many_requests_error_response_body.py +33 -0
  257. samsara/types/readings_get_readings_history_unauthorized_error_response_body.py +33 -0
  258. samsara/types/readings_get_readings_snapshot_bad_gateway_error_response_body.py +33 -0
  259. samsara/types/readings_get_readings_snapshot_gateway_timeout_error_response_body.py +33 -0
  260. samsara/types/readings_get_readings_snapshot_internal_server_error_response_body.py +33 -0
  261. samsara/types/readings_get_readings_snapshot_method_not_allowed_error_response_body.py +33 -0
  262. samsara/types/readings_get_readings_snapshot_not_found_error_response_body.py +33 -0
  263. samsara/types/readings_get_readings_snapshot_not_implemented_error_response_body.py +33 -0
  264. samsara/types/readings_get_readings_snapshot_response_body.py +26 -0
  265. samsara/types/readings_get_readings_snapshot_service_unavailable_error_response_body.py +33 -0
  266. samsara/types/{hos_daily_logs_update_shipping_docs_unauthorized_error_response_body.py → readings_get_readings_snapshot_too_many_requests_error_response_body.py} +2 -2
  267. samsara/types/readings_get_readings_snapshot_unauthorized_error_response_body.py +33 -0
  268. samsara/types/readings_list_readings_definitions_bad_gateway_error_response_body.py +33 -0
  269. samsara/types/{hos_daily_logs_update_shipping_docs_too_many_requests_error_response_body.py → readings_list_readings_definitions_gateway_timeout_error_response_body.py} +2 -2
  270. samsara/types/readings_list_readings_definitions_internal_server_error_response_body.py +33 -0
  271. samsara/types/readings_list_readings_definitions_method_not_allowed_error_response_body.py +33 -0
  272. samsara/types/readings_list_readings_definitions_not_found_error_response_body.py +33 -0
  273. samsara/types/readings_list_readings_definitions_not_implemented_error_response_body.py +33 -0
  274. samsara/types/readings_list_readings_definitions_response_body.py +26 -0
  275. samsara/types/readings_list_readings_definitions_service_unavailable_error_response_body.py +33 -0
  276. samsara/types/{hos_daily_logs_update_shipping_docs_method_not_allowed_error_response_body.py → readings_list_readings_definitions_too_many_requests_error_response_body.py} +2 -2
  277. samsara/types/readings_list_readings_definitions_unauthorized_error_response_body.py +33 -0
  278. samsara/types/safety_score_configuration_settings_object_response_body.py +7 -0
  279. samsara/types/single_approval_requirements_object_response_body.py +28 -0
  280. samsara/types/sudden_fuel_level_drop_response_body.py +33 -0
  281. samsara/types/sudden_fuel_level_rise_response_body.py +33 -0
  282. samsara/types/trigger_params_object_request_body.py +2 -0
  283. samsara/types/trigger_params_object_response_body.py +2 -0
  284. samsara/types/unit_response_body.py +39 -0
  285. samsara/types/unit_response_body_base_unit.py +62 -0
  286. samsara/types/unit_response_body_measurement_type.py +28 -0
  287. samsara/types/uploaded_media_object_response_body.py +1 -1
  288. samsara/types/uploaded_media_object_response_body_trigger_reason.py +8 -1
  289. samsara/types/v_1_message.py +29 -0
  290. samsara/types/v_1_message_response.py +41 -0
  291. samsara/types/v_1_message_sender.py +27 -0
  292. samsara/types/v_1_messages.py +7 -0
  293. samsara/types/v_1_messages_response.py +7 -0
  294. samsara/types/webhook_response_response_body_event_types_item.py +1 -0
  295. samsara/types/webhooks_get_webhook_response_body_event_types_item.py +1 -0
  296. samsara/types/webhooks_patch_webhook_response_body_event_types_item.py +1 -0
  297. samsara/types/webhooks_post_webhooks_response_body_event_types_item.py +1 -0
  298. samsara/types/work_order_item_object_request_body.py +1 -1
  299. samsara/types/work_order_item_object_request_body_type.py +10 -1
  300. samsara/types/work_order_item_object_response_body.py +1 -1
  301. samsara/types/work_order_item_object_response_body_type.py +10 -1
  302. samsara/types/workflow_geofence_event_response_object_response_body.py +6 -0
  303. samsara/types/workflow_incident_details_object_response_body.py +2 -0
  304. samsara/types/workflow_trigger_object_request_body.py +1 -0
  305. samsara/types/workflow_trigger_object_response_body.py +1 -0
  306. samsara/user_roles/client.py +21 -11
  307. samsara/user_roles/raw_client.py +39 -9
  308. samsara/users/client.py +21 -11
  309. samsara/users/raw_client.py +39 -8
  310. samsara/v_1_messages/__init__.py +4 -0
  311. samsara/v_1_messages/client.py +258 -0
  312. samsara/v_1_messages/raw_client.py +273 -0
  313. samsara/vehicles/__init__.py +1 -2
  314. samsara/vehicles/client.py +31 -16
  315. samsara/vehicles/immobilizer/client.py +21 -13
  316. samsara/vehicles/immobilizer/raw_client.py +43 -9
  317. samsara/vehicles/locations/client.py +60 -32
  318. samsara/vehicles/locations/raw_client.py +132 -25
  319. samsara/vehicles/raw_client.py +61 -8
  320. samsara/vehicles/stats/client.py +66 -38
  321. samsara/vehicles/stats/raw_client.py +148 -31
  322. samsara/webhooks/client.py +21 -11
  323. samsara/webhooks/raw_client.py +41 -8
  324. samsara/webhooks/types/webhooks_post_webhooks_request_body_event_types_item.py +1 -0
  325. {samsara_api-0.0.1.dist-info → samsara_api-0.0.3.dist-info}/METADATA +25 -18
  326. {samsara_api-0.0.1.dist-info → samsara_api-0.0.3.dist-info}/RECORD +332 -197
  327. samsara/beta/client.py +0 -161
  328. samsara/drivers/tachograph_activity/client.py +0 -186
  329. samsara/drivers/tachograph_activity/raw_client.py +0 -169
  330. samsara/hours_of_service/__init__.py +0 -7
  331. samsara/hours_of_service/client.py +0 -229
  332. samsara/hours_of_service/raw_client.py +0 -425
  333. samsara/hours_of_service/types/__init__.py +0 -9
  334. samsara/hours_of_service/types/hours_of_service_get_daily_logs_request_driver_activation_status.py +0 -7
  335. samsara/reports/ifta/vehicle/types/vehicle_get_request_quarter.py +0 -5
  336. samsara/reports/vehicles/fuel_energy/types/fuel_energy_get_request_energy_type.py +0 -5
  337. samsara/types/assets_create_asset_response_body_regulation_mode.py +0 -7
  338. samsara/types/assets_update_asset_response_body_regulation_mode.py +0 -7
  339. samsara/types/assets_update_asset_response_body_type.py +0 -7
  340. samsara/types/patch_shipping_docs_response_body_response_body.py +0 -93
  341. /samsara/{beta → forms}/__init__.py +0 -0
  342. /samsara/{drivers/tachograph_activity → readings}/__init__.py +0 -0
  343. /samsara/{drivers/tachograph_files → tachograph/driver}/__init__.py +0 -0
  344. /samsara/{vehicles/tachograph_files → tachograph/vehicles}/__init__.py +0 -0
  345. {samsara_api-0.0.1.dist-info → samsara_api-0.0.3.dist-info}/LICENSE +0 -0
  346. {samsara_api-0.0.1.dist-info → samsara_api-0.0.3.dist-info}/WHEEL +0 -0
@@ -5,7 +5,7 @@ from json.decoder import JSONDecodeError
5
5
 
6
6
  from ...core.api_error import ApiError
7
7
  from ...core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
- from ...core.http_response import AsyncHttpResponse, HttpResponse
8
+ from ...core.pagination import AsyncPager, BaseHttpResponse, SyncPager
9
9
  from ...core.pydantic_utilities import parse_obj_as
10
10
  from ...core.request_options import RequestOptions
11
11
  from ...errors.bad_gateway_error import BadGatewayError
@@ -17,6 +17,7 @@ from ...errors.not_implemented_error import NotImplementedError
17
17
  from ...errors.service_unavailable_error import ServiceUnavailableError
18
18
  from ...errors.too_many_requests_error import TooManyRequestsError
19
19
  from ...errors.unauthorized_error import UnauthorizedError
20
+ from ...types.safety_event_activity_feed_item_response_body import SafetyEventActivityFeedItemResponseBody
20
21
  from ...types.safety_events_get_safety_activity_event_feed_response_body import (
21
22
  SafetyEventsGetSafetyActivityEventFeedResponseBody,
22
23
  )
@@ -32,7 +33,7 @@ class RawAuditLogsClient:
32
33
  after: typing.Optional[str] = None,
33
34
  start_time: typing.Optional[str] = None,
34
35
  request_options: typing.Optional[RequestOptions] = None,
35
- ) -> HttpResponse[SafetyEventsGetSafetyActivityEventFeedResponseBody]:
36
+ ) -> SyncPager[SafetyEventActivityFeedItemResponseBody]:
36
37
  """
37
38
  Get continuous safety events. The safety activity event feed offers a change-log for safety events. Use this endpoint to subscribe to safety event changes. See documentation below for all supported change-log types.
38
39
 
@@ -62,7 +63,7 @@ class RawAuditLogsClient:
62
63
 
63
64
  Returns
64
65
  -------
65
- HttpResponse[SafetyEventsGetSafetyActivityEventFeedResponseBody]
66
+ SyncPager[SafetyEventActivityFeedItemResponseBody]
66
67
  OK response.
67
68
  """
68
69
  _response = self._client_wrapper.httpx_client.request(
@@ -76,14 +77,27 @@ class RawAuditLogsClient:
76
77
  )
77
78
  try:
78
79
  if 200 <= _response.status_code < 300:
79
- _data = typing.cast(
80
+ _parsed_response = typing.cast(
80
81
  SafetyEventsGetSafetyActivityEventFeedResponseBody,
81
82
  parse_obj_as(
82
83
  type_=SafetyEventsGetSafetyActivityEventFeedResponseBody, # type: ignore
83
84
  object_=_response.json(),
84
85
  ),
85
86
  )
86
- return HttpResponse(response=_response, data=_data)
87
+ _items = _parsed_response.data
88
+ _has_next = False
89
+ _get_next = None
90
+ if _parsed_response.pagination is not None:
91
+ _parsed_next = _parsed_response.pagination.end_cursor
92
+ _has_next = _parsed_next is not None and _parsed_next != ""
93
+ _get_next = lambda: self.feed(
94
+ after=_parsed_next,
95
+ start_time=start_time,
96
+ request_options=request_options,
97
+ )
98
+ return SyncPager(
99
+ has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
100
+ )
87
101
  if _response.status_code == 401:
88
102
  raise UnauthorizedError(
89
103
  headers=dict(_response.headers),
@@ -199,7 +213,7 @@ class AsyncRawAuditLogsClient:
199
213
  after: typing.Optional[str] = None,
200
214
  start_time: typing.Optional[str] = None,
201
215
  request_options: typing.Optional[RequestOptions] = None,
202
- ) -> AsyncHttpResponse[SafetyEventsGetSafetyActivityEventFeedResponseBody]:
216
+ ) -> AsyncPager[SafetyEventActivityFeedItemResponseBody]:
203
217
  """
204
218
  Get continuous safety events. The safety activity event feed offers a change-log for safety events. Use this endpoint to subscribe to safety event changes. See documentation below for all supported change-log types.
205
219
 
@@ -229,7 +243,7 @@ class AsyncRawAuditLogsClient:
229
243
 
230
244
  Returns
231
245
  -------
232
- AsyncHttpResponse[SafetyEventsGetSafetyActivityEventFeedResponseBody]
246
+ AsyncPager[SafetyEventActivityFeedItemResponseBody]
233
247
  OK response.
234
248
  """
235
249
  _response = await self._client_wrapper.httpx_client.request(
@@ -243,14 +257,30 @@ class AsyncRawAuditLogsClient:
243
257
  )
244
258
  try:
245
259
  if 200 <= _response.status_code < 300:
246
- _data = typing.cast(
260
+ _parsed_response = typing.cast(
247
261
  SafetyEventsGetSafetyActivityEventFeedResponseBody,
248
262
  parse_obj_as(
249
263
  type_=SafetyEventsGetSafetyActivityEventFeedResponseBody, # type: ignore
250
264
  object_=_response.json(),
251
265
  ),
252
266
  )
253
- return AsyncHttpResponse(response=_response, data=_data)
267
+ _items = _parsed_response.data
268
+ _has_next = False
269
+ _get_next = None
270
+ if _parsed_response.pagination is not None:
271
+ _parsed_next = _parsed_response.pagination.end_cursor
272
+ _has_next = _parsed_next is not None and _parsed_next != ""
273
+
274
+ async def _get_next():
275
+ return await self.feed(
276
+ after=_parsed_next,
277
+ start_time=start_time,
278
+ request_options=request_options,
279
+ )
280
+
281
+ return AsyncPager(
282
+ has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
283
+ )
254
284
  if _response.status_code == 401:
255
285
  raise UnauthorizedError(
256
286
  headers=dict(_response.headers),
@@ -3,8 +3,9 @@
3
3
  import typing
4
4
 
5
5
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.pagination import AsyncPager, SyncPager
6
7
  from ..core.request_options import RequestOptions
7
- from ..types.safety_events_list_response import SafetyEventsListResponse
8
+ from ..types.safety_event import SafetyEvent
8
9
  from .audit_logs.client import AsyncAuditLogsClient, AuditLogsClient
9
10
  from .raw_client import AsyncRawSafetyEventsClient, RawSafetyEventsClient
10
11
 
@@ -35,7 +36,7 @@ class SafetyEventsClient:
35
36
  parent_tag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
36
37
  vehicle_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
37
38
  request_options: typing.Optional[RequestOptions] = None,
38
- ) -> SafetyEventsListResponse:
39
+ ) -> SyncPager[SafetyEvent]:
39
40
  """
40
41
  Fetch safety events for the organization in a given time period.
41
42
 
@@ -68,7 +69,7 @@ class SafetyEventsClient:
68
69
 
69
70
  Returns
70
71
  -------
71
- SafetyEventsListResponse
72
+ SyncPager[SafetyEvent]
72
73
  List of safety events from given time period.
73
74
 
74
75
  Examples
@@ -78,12 +79,17 @@ class SafetyEventsClient:
78
79
  client = Samsara(
79
80
  token="YOUR_TOKEN",
80
81
  )
81
- client.safety_events.list(
82
+ response = client.safety_events.list(
82
83
  start_time="startTime",
83
84
  end_time="endTime",
84
85
  )
86
+ for item in response:
87
+ yield item
88
+ # alternatively, you can paginate page-by-page
89
+ for page in response.iter_pages():
90
+ yield page
85
91
  """
86
- _response = self._raw_client.list(
92
+ return self._raw_client.list(
87
93
  start_time=start_time,
88
94
  end_time=end_time,
89
95
  after=after,
@@ -92,7 +98,6 @@ class SafetyEventsClient:
92
98
  vehicle_ids=vehicle_ids,
93
99
  request_options=request_options,
94
100
  )
95
- return _response.data
96
101
 
97
102
 
98
103
  class AsyncSafetyEventsClient:
@@ -121,7 +126,7 @@ class AsyncSafetyEventsClient:
121
126
  parent_tag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
122
127
  vehicle_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
123
128
  request_options: typing.Optional[RequestOptions] = None,
124
- ) -> SafetyEventsListResponse:
129
+ ) -> AsyncPager[SafetyEvent]:
125
130
  """
126
131
  Fetch safety events for the organization in a given time period.
127
132
 
@@ -154,7 +159,7 @@ class AsyncSafetyEventsClient:
154
159
 
155
160
  Returns
156
161
  -------
157
- SafetyEventsListResponse
162
+ AsyncPager[SafetyEvent]
158
163
  List of safety events from given time period.
159
164
 
160
165
  Examples
@@ -169,15 +174,21 @@ class AsyncSafetyEventsClient:
169
174
 
170
175
 
171
176
  async def main() -> None:
172
- await client.safety_events.list(
177
+ response = await client.safety_events.list(
173
178
  start_time="startTime",
174
179
  end_time="endTime",
175
180
  )
181
+ async for item in response:
182
+ yield item
183
+
184
+ # alternatively, you can paginate page-by-page
185
+ async for page in response.iter_pages():
186
+ yield page
176
187
 
177
188
 
178
189
  asyncio.run(main())
179
190
  """
180
- _response = await self._raw_client.list(
191
+ return await self._raw_client.list(
181
192
  start_time=start_time,
182
193
  end_time=end_time,
183
194
  after=after,
@@ -186,4 +197,3 @@ class AsyncSafetyEventsClient:
186
197
  vehicle_ids=vehicle_ids,
187
198
  request_options=request_options,
188
199
  )
189
- return _response.data
@@ -5,9 +5,10 @@ from json.decoder import JSONDecodeError
5
5
 
6
6
  from ..core.api_error import ApiError
7
7
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
- from ..core.http_response import AsyncHttpResponse, HttpResponse
8
+ from ..core.pagination import AsyncPager, BaseHttpResponse, SyncPager
9
9
  from ..core.pydantic_utilities import parse_obj_as
10
10
  from ..core.request_options import RequestOptions
11
+ from ..types.safety_event import SafetyEvent
11
12
  from ..types.safety_events_list_response import SafetyEventsListResponse
12
13
 
13
14
 
@@ -25,7 +26,7 @@ class RawSafetyEventsClient:
25
26
  parent_tag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
26
27
  vehicle_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
27
28
  request_options: typing.Optional[RequestOptions] = None,
28
- ) -> HttpResponse[SafetyEventsListResponse]:
29
+ ) -> SyncPager[SafetyEvent]:
29
30
  """
30
31
  Fetch safety events for the organization in a given time period.
31
32
 
@@ -58,7 +59,7 @@ class RawSafetyEventsClient:
58
59
 
59
60
  Returns
60
61
  -------
61
- HttpResponse[SafetyEventsListResponse]
62
+ SyncPager[SafetyEvent]
62
63
  List of safety events from given time period.
63
64
  """
64
65
  _response = self._client_wrapper.httpx_client.request(
@@ -76,14 +77,31 @@ class RawSafetyEventsClient:
76
77
  )
77
78
  try:
78
79
  if 200 <= _response.status_code < 300:
79
- _data = typing.cast(
80
+ _parsed_response = typing.cast(
80
81
  SafetyEventsListResponse,
81
82
  parse_obj_as(
82
83
  type_=SafetyEventsListResponse, # type: ignore
83
84
  object_=_response.json(),
84
85
  ),
85
86
  )
86
- return HttpResponse(response=_response, data=_data)
87
+ _items = _parsed_response.data
88
+ _has_next = False
89
+ _get_next = None
90
+ if _parsed_response.pagination is not None:
91
+ _parsed_next = _parsed_response.pagination.end_cursor
92
+ _has_next = _parsed_next is not None and _parsed_next != ""
93
+ _get_next = lambda: self.list(
94
+ start_time=start_time,
95
+ end_time=end_time,
96
+ after=_parsed_next,
97
+ tag_ids=tag_ids,
98
+ parent_tag_ids=parent_tag_ids,
99
+ vehicle_ids=vehicle_ids,
100
+ request_options=request_options,
101
+ )
102
+ return SyncPager(
103
+ has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
104
+ )
87
105
  _response_json = _response.json()
88
106
  except JSONDecodeError:
89
107
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
@@ -104,7 +122,7 @@ class AsyncRawSafetyEventsClient:
104
122
  parent_tag_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
105
123
  vehicle_ids: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
106
124
  request_options: typing.Optional[RequestOptions] = None,
107
- ) -> AsyncHttpResponse[SafetyEventsListResponse]:
125
+ ) -> AsyncPager[SafetyEvent]:
108
126
  """
109
127
  Fetch safety events for the organization in a given time period.
110
128
 
@@ -137,7 +155,7 @@ class AsyncRawSafetyEventsClient:
137
155
 
138
156
  Returns
139
157
  -------
140
- AsyncHttpResponse[SafetyEventsListResponse]
158
+ AsyncPager[SafetyEvent]
141
159
  List of safety events from given time period.
142
160
  """
143
161
  _response = await self._client_wrapper.httpx_client.request(
@@ -155,14 +173,34 @@ class AsyncRawSafetyEventsClient:
155
173
  )
156
174
  try:
157
175
  if 200 <= _response.status_code < 300:
158
- _data = typing.cast(
176
+ _parsed_response = typing.cast(
159
177
  SafetyEventsListResponse,
160
178
  parse_obj_as(
161
179
  type_=SafetyEventsListResponse, # type: ignore
162
180
  object_=_response.json(),
163
181
  ),
164
182
  )
165
- return AsyncHttpResponse(response=_response, data=_data)
183
+ _items = _parsed_response.data
184
+ _has_next = False
185
+ _get_next = None
186
+ if _parsed_response.pagination is not None:
187
+ _parsed_next = _parsed_response.pagination.end_cursor
188
+ _has_next = _parsed_next is not None and _parsed_next != ""
189
+
190
+ async def _get_next():
191
+ return await self.list(
192
+ start_time=start_time,
193
+ end_time=end_time,
194
+ after=_parsed_next,
195
+ tag_ids=tag_ids,
196
+ parent_tag_ids=parent_tag_ids,
197
+ vehicle_ids=vehicle_ids,
198
+ request_options=request_options,
199
+ )
200
+
201
+ return AsyncPager(
202
+ has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
203
+ )
166
204
  _response_json = _response.json()
167
205
  except JSONDecodeError:
168
206
  raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
@@ -3,10 +3,9 @@
3
3
  import typing
4
4
 
5
5
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
6
+ from ..core.pagination import AsyncPager, SyncPager
6
7
  from ..core.request_options import RequestOptions
7
- from ..types.speeding_intervals_get_speeding_intervals_response_body import (
8
- SpeedingIntervalsGetSpeedingIntervalsResponseBody,
9
- )
8
+ from ..types.trip_speeding_intervals_response_body import TripSpeedingIntervalsResponseBody
10
9
  from .raw_client import AsyncRawSpeedingIntervalsClient, RawSpeedingIntervalsClient
11
10
  from .types.speeding_intervals_stream_request_query_by import SpeedingIntervalsStreamRequestQueryBy
12
11
 
@@ -38,9 +37,9 @@ class SpeedingIntervalsClient:
38
37
  after: typing.Optional[str] = None,
39
38
  severity_levels: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
40
39
  request_options: typing.Optional[RequestOptions] = None,
41
- ) -> SpeedingIntervalsGetSpeedingIntervalsResponseBody:
40
+ ) -> SyncPager[TripSpeedingIntervalsResponseBody]:
42
41
  """
43
- This endpoint will return all speeding intervals associated with trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Results are paginated.
42
+ This endpoint will return all speeding intervals associated with all trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Trips with no speeding intervals detected will be returned with an empty list of intervals. Results are paginated.
44
43
 
45
44
  <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>).
46
45
 
@@ -73,14 +72,14 @@ class SpeedingIntervalsClient:
73
72
  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.
74
73
 
75
74
  severity_levels : typing.Optional[typing.Union[str, typing.Sequence[str]]]
76
- Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”.
75
+ Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”. This filter does not exclude trips that have no speeding intervals.
77
76
 
78
77
  request_options : typing.Optional[RequestOptions]
79
78
  Request-specific configuration.
80
79
 
81
80
  Returns
82
81
  -------
83
- SpeedingIntervalsGetSpeedingIntervalsResponseBody
82
+ SyncPager[TripSpeedingIntervalsResponseBody]
84
83
  OK response.
85
84
 
86
85
  Examples
@@ -90,11 +89,16 @@ class SpeedingIntervalsClient:
90
89
  client = Samsara(
91
90
  token="YOUR_TOKEN",
92
91
  )
93
- client.speeding_intervals.stream(
92
+ response = client.speeding_intervals.stream(
94
93
  start_time="startTime",
95
94
  )
95
+ for item in response:
96
+ yield item
97
+ # alternatively, you can paginate page-by-page
98
+ for page in response.iter_pages():
99
+ yield page
96
100
  """
97
- _response = self._raw_client.stream(
101
+ return self._raw_client.stream(
98
102
  start_time=start_time,
99
103
  asset_ids=asset_ids,
100
104
  end_time=end_time,
@@ -105,7 +109,6 @@ class SpeedingIntervalsClient:
105
109
  severity_levels=severity_levels,
106
110
  request_options=request_options,
107
111
  )
108
- return _response.data
109
112
 
110
113
 
111
114
  class AsyncSpeedingIntervalsClient:
@@ -135,9 +138,9 @@ class AsyncSpeedingIntervalsClient:
135
138
  after: typing.Optional[str] = None,
136
139
  severity_levels: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
137
140
  request_options: typing.Optional[RequestOptions] = None,
138
- ) -> SpeedingIntervalsGetSpeedingIntervalsResponseBody:
141
+ ) -> AsyncPager[TripSpeedingIntervalsResponseBody]:
139
142
  """
140
- This endpoint will return all speeding intervals associated with trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Results are paginated.
143
+ This endpoint will return all speeding intervals associated with all trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Trips with no speeding intervals detected will be returned with an empty list of intervals. Results are paginated.
141
144
 
142
145
  <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>).
143
146
 
@@ -170,14 +173,14 @@ class AsyncSpeedingIntervalsClient:
170
173
  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.
171
174
 
172
175
  severity_levels : typing.Optional[typing.Union[str, typing.Sequence[str]]]
173
- Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”.
176
+ Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”. This filter does not exclude trips that have no speeding intervals.
174
177
 
175
178
  request_options : typing.Optional[RequestOptions]
176
179
  Request-specific configuration.
177
180
 
178
181
  Returns
179
182
  -------
180
- SpeedingIntervalsGetSpeedingIntervalsResponseBody
183
+ AsyncPager[TripSpeedingIntervalsResponseBody]
181
184
  OK response.
182
185
 
183
186
  Examples
@@ -192,14 +195,20 @@ class AsyncSpeedingIntervalsClient:
192
195
 
193
196
 
194
197
  async def main() -> None:
195
- await client.speeding_intervals.stream(
198
+ response = await client.speeding_intervals.stream(
196
199
  start_time="startTime",
197
200
  )
201
+ async for item in response:
202
+ yield item
203
+
204
+ # alternatively, you can paginate page-by-page
205
+ async for page in response.iter_pages():
206
+ yield page
198
207
 
199
208
 
200
209
  asyncio.run(main())
201
210
  """
202
- _response = await self._raw_client.stream(
211
+ return await self._raw_client.stream(
203
212
  start_time=start_time,
204
213
  asset_ids=asset_ids,
205
214
  end_time=end_time,
@@ -210,4 +219,3 @@ class AsyncSpeedingIntervalsClient:
210
219
  severity_levels=severity_levels,
211
220
  request_options=request_options,
212
221
  )
213
- return _response.data
@@ -5,7 +5,7 @@ from json.decoder import JSONDecodeError
5
5
 
6
6
  from ..core.api_error import ApiError
7
7
  from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
8
- from ..core.http_response import AsyncHttpResponse, HttpResponse
8
+ from ..core.pagination import AsyncPager, BaseHttpResponse, SyncPager
9
9
  from ..core.pydantic_utilities import parse_obj_as
10
10
  from ..core.request_options import RequestOptions
11
11
  from ..errors.bad_gateway_error import BadGatewayError
@@ -20,6 +20,7 @@ from ..errors.unauthorized_error import UnauthorizedError
20
20
  from ..types.speeding_intervals_get_speeding_intervals_response_body import (
21
21
  SpeedingIntervalsGetSpeedingIntervalsResponseBody,
22
22
  )
23
+ from ..types.trip_speeding_intervals_response_body import TripSpeedingIntervalsResponseBody
23
24
  from .types.speeding_intervals_stream_request_query_by import SpeedingIntervalsStreamRequestQueryBy
24
25
 
25
26
 
@@ -39,9 +40,9 @@ class RawSpeedingIntervalsClient:
39
40
  after: typing.Optional[str] = None,
40
41
  severity_levels: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
41
42
  request_options: typing.Optional[RequestOptions] = None,
42
- ) -> HttpResponse[SpeedingIntervalsGetSpeedingIntervalsResponseBody]:
43
+ ) -> SyncPager[TripSpeedingIntervalsResponseBody]:
43
44
  """
44
- This endpoint will return all speeding intervals associated with trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Results are paginated.
45
+ This endpoint will return all speeding intervals associated with all trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Trips with no speeding intervals detected will be returned with an empty list of intervals. Results are paginated.
45
46
 
46
47
  <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>).
47
48
 
@@ -74,14 +75,14 @@ class RawSpeedingIntervalsClient:
74
75
  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.
75
76
 
76
77
  severity_levels : typing.Optional[typing.Union[str, typing.Sequence[str]]]
77
- Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”.
78
+ Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”. This filter does not exclude trips that have no speeding intervals.
78
79
 
79
80
  request_options : typing.Optional[RequestOptions]
80
81
  Request-specific configuration.
81
82
 
82
83
  Returns
83
84
  -------
84
- HttpResponse[SpeedingIntervalsGetSpeedingIntervalsResponseBody]
85
+ SyncPager[TripSpeedingIntervalsResponseBody]
85
86
  OK response.
86
87
  """
87
88
  _response = self._client_wrapper.httpx_client.request(
@@ -101,14 +102,33 @@ class RawSpeedingIntervalsClient:
101
102
  )
102
103
  try:
103
104
  if 200 <= _response.status_code < 300:
104
- _data = typing.cast(
105
+ _parsed_response = typing.cast(
105
106
  SpeedingIntervalsGetSpeedingIntervalsResponseBody,
106
107
  parse_obj_as(
107
108
  type_=SpeedingIntervalsGetSpeedingIntervalsResponseBody, # type: ignore
108
109
  object_=_response.json(),
109
110
  ),
110
111
  )
111
- return HttpResponse(response=_response, data=_data)
112
+ _items = _parsed_response.data
113
+ _has_next = False
114
+ _get_next = None
115
+ if _parsed_response.pagination is not None:
116
+ _parsed_next = _parsed_response.pagination.end_cursor
117
+ _has_next = _parsed_next is not None and _parsed_next != ""
118
+ _get_next = lambda: self.stream(
119
+ start_time=start_time,
120
+ asset_ids=asset_ids,
121
+ end_time=end_time,
122
+ query_by=query_by,
123
+ include_asset=include_asset,
124
+ include_driver_id=include_driver_id,
125
+ after=_parsed_next,
126
+ severity_levels=severity_levels,
127
+ request_options=request_options,
128
+ )
129
+ return SyncPager(
130
+ has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
131
+ )
112
132
  if _response.status_code == 401:
113
133
  raise UnauthorizedError(
114
134
  headers=dict(_response.headers),
@@ -230,9 +250,9 @@ class AsyncRawSpeedingIntervalsClient:
230
250
  after: typing.Optional[str] = None,
231
251
  severity_levels: typing.Optional[typing.Union[str, typing.Sequence[str]]] = None,
232
252
  request_options: typing.Optional[RequestOptions] = None,
233
- ) -> AsyncHttpResponse[SpeedingIntervalsGetSpeedingIntervalsResponseBody]:
253
+ ) -> AsyncPager[TripSpeedingIntervalsResponseBody]:
234
254
  """
235
- This endpoint will return all speeding intervals associated with trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Results are paginated.
255
+ This endpoint will return all speeding intervals associated with all trips that have been collected for your organization based on the time parameters passed in. Only completed trips are included. Trips with no speeding intervals detected will be returned with an empty list of intervals. Results are paginated.
236
256
 
237
257
  <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>).
238
258
 
@@ -265,14 +285,14 @@ class AsyncRawSpeedingIntervalsClient:
265
285
  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.
266
286
 
267
287
  severity_levels : typing.Optional[typing.Union[str, typing.Sequence[str]]]
268
- Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”.
288
+ Optional string of comma-separated severity levels to filter speeding intervals by. Valid values: “light”, ”moderate”, ”heavy”, “severe”. This filter does not exclude trips that have no speeding intervals.
269
289
 
270
290
  request_options : typing.Optional[RequestOptions]
271
291
  Request-specific configuration.
272
292
 
273
293
  Returns
274
294
  -------
275
- AsyncHttpResponse[SpeedingIntervalsGetSpeedingIntervalsResponseBody]
295
+ AsyncPager[TripSpeedingIntervalsResponseBody]
276
296
  OK response.
277
297
  """
278
298
  _response = await self._client_wrapper.httpx_client.request(
@@ -292,14 +312,36 @@ class AsyncRawSpeedingIntervalsClient:
292
312
  )
293
313
  try:
294
314
  if 200 <= _response.status_code < 300:
295
- _data = typing.cast(
315
+ _parsed_response = typing.cast(
296
316
  SpeedingIntervalsGetSpeedingIntervalsResponseBody,
297
317
  parse_obj_as(
298
318
  type_=SpeedingIntervalsGetSpeedingIntervalsResponseBody, # type: ignore
299
319
  object_=_response.json(),
300
320
  ),
301
321
  )
302
- return AsyncHttpResponse(response=_response, data=_data)
322
+ _items = _parsed_response.data
323
+ _has_next = False
324
+ _get_next = None
325
+ if _parsed_response.pagination is not None:
326
+ _parsed_next = _parsed_response.pagination.end_cursor
327
+ _has_next = _parsed_next is not None and _parsed_next != ""
328
+
329
+ async def _get_next():
330
+ return await self.stream(
331
+ start_time=start_time,
332
+ asset_ids=asset_ids,
333
+ end_time=end_time,
334
+ query_by=query_by,
335
+ include_asset=include_asset,
336
+ include_driver_id=include_driver_id,
337
+ after=_parsed_next,
338
+ severity_levels=severity_levels,
339
+ request_options=request_options,
340
+ )
341
+
342
+ return AsyncPager(
343
+ has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
344
+ )
303
345
  if _response.status_code == 401:
304
346
  raise UnauthorizedError(
305
347
  headers=dict(_response.headers),
@@ -0,0 +1,7 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ # isort: skip_file
4
+
5
+ from . import driver, vehicles
6
+
7
+ __all__ = ["driver", "vehicles"]
@@ -0,0 +1,44 @@
1
+ # This file was auto-generated by Fern from our API Definition.
2
+
3
+ from ..core.client_wrapper import AsyncClientWrapper, SyncClientWrapper
4
+ from .driver.client import AsyncDriverClient, DriverClient
5
+ from .raw_client import AsyncRawTachographClient, RawTachographClient
6
+ from .vehicles.client import AsyncVehiclesClient, VehiclesClient
7
+
8
+
9
+ class TachographClient:
10
+ def __init__(self, *, client_wrapper: SyncClientWrapper):
11
+ self._raw_client = RawTachographClient(client_wrapper=client_wrapper)
12
+ self.driver = DriverClient(client_wrapper=client_wrapper)
13
+
14
+ self.vehicles = VehiclesClient(client_wrapper=client_wrapper)
15
+
16
+ @property
17
+ def with_raw_response(self) -> RawTachographClient:
18
+ """
19
+ Retrieves a raw implementation of this client that returns raw responses.
20
+
21
+ Returns
22
+ -------
23
+ RawTachographClient
24
+ """
25
+ return self._raw_client
26
+
27
+
28
+ class AsyncTachographClient:
29
+ def __init__(self, *, client_wrapper: AsyncClientWrapper):
30
+ self._raw_client = AsyncRawTachographClient(client_wrapper=client_wrapper)
31
+ self.driver = AsyncDriverClient(client_wrapper=client_wrapper)
32
+
33
+ self.vehicles = AsyncVehiclesClient(client_wrapper=client_wrapper)
34
+
35
+ @property
36
+ def with_raw_response(self) -> AsyncRawTachographClient:
37
+ """
38
+ Retrieves a raw implementation of this client that returns raw responses.
39
+
40
+ Returns
41
+ -------
42
+ AsyncRawTachographClient
43
+ """
44
+ return self._raw_client