samsara-api 0.0.1__py3-none-any.whl → 0.0.2__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 +298 -38
- samsara/alerts/configurations/client.py +25 -11
- samsara/alerts/configurations/raw_client.py +47 -8
- samsara/alerts/incidents/client.py +21 -11
- samsara/alerts/incidents/raw_client.py +43 -9
- samsara/assets/client.py +21 -11
- samsara/assets/location_and_speed/client.py +21 -13
- samsara/assets/location_and_speed/raw_client.py +53 -9
- samsara/assets/raw_client.py +53 -8
- samsara/attributes/client.py +21 -13
- samsara/attributes/raw_client.py +41 -8
- samsara/cameras/media/client.py +2 -2
- samsara/cameras/media/raw_client.py +2 -2
- samsara/cameras/media/retrieval/client.py +2 -12
- samsara/cameras/media/types/media_list_request_trigger_reasons_item.py +8 -1
- samsara/carrier_proposed_assignments/client.py +21 -11
- samsara/carrier_proposed_assignments/raw_client.py +43 -8
- samsara/client.py +15 -6
- samsara/coaching/driver_coach_assignments/client.py +22 -12
- samsara/coaching/driver_coach_assignments/raw_client.py +45 -8
- samsara/coaching/sessions/client.py +21 -13
- samsara/coaching/sessions/raw_client.py +51 -9
- samsara/contacts/client.py +21 -11
- samsara/contacts/raw_client.py +39 -8
- samsara/core/client_wrapper.py +2 -2
- samsara/defect_types/client.py +21 -11
- samsara/defect_types/raw_client.py +41 -9
- samsara/defects/client.py +124 -9
- samsara/defects/raw_client.py +356 -6
- samsara/devices/client.py +21 -11
- samsara/devices/raw_client.py +45 -9
- samsara/document_types/client.py +21 -11
- samsara/document_types/raw_client.py +37 -9
- samsara/documents/client.py +21 -11
- samsara/documents/raw_client.py +45 -8
- samsara/driver_trailer_assignments/client.py +23 -13
- samsara/driver_trailer_assignments/raw_client.py +43 -8
- samsara/drivers/__init__.py +1 -3
- samsara/drivers/client.py +21 -21
- samsara/drivers/raw_client.py +51 -8
- samsara/dvirs/client.py +124 -9
- samsara/dvirs/raw_client.py +356 -6
- samsara/equipment/__init__.py +2 -2
- samsara/equipment/client.py +23 -21
- samsara/equipment/locations/client.py +62 -34
- samsara/equipment/locations/raw_client.py +132 -27
- samsara/equipment/raw_client.py +45 -18
- samsara/equipment/stats/__init__.py +2 -2
- samsara/equipment/stats/client.py +81 -53
- samsara/equipment/stats/raw_client.py +157 -46
- samsara/equipment/stats/types/__init__.py +2 -2
- samsara/equipment/stats/types/{stats_get_request_types_item.py → stats_list_request_types_item.py} +1 -1
- samsara/form_submissions/client.py +46 -54
- samsara/form_submissions/pdf_exports/client.py +14 -22
- samsara/form_submissions/pdf_exports/raw_client.py +10 -18
- samsara/form_submissions/raw_client.py +74 -47
- samsara/forms/client.py +138 -0
- samsara/{beta → forms}/raw_client.py +37 -62
- samsara/function.py +99 -0
- samsara/gateways/client.py +21 -11
- samsara/gateways/raw_client.py +39 -8
- samsara/hos/__init__.py +3 -0
- samsara/hos/client.py +218 -11
- samsara/hos/raw_client.py +485 -8
- samsara/hos/types/__init__.py +7 -0
- samsara/hos/types/hos_daily_logs_request_driver_activation_status.py +5 -0
- samsara/idling/__init__.py +7 -0
- samsara/idling/client.py +287 -0
- samsara/idling/raw_client.py +521 -0
- samsara/idling/types/__init__.py +7 -0
- samsara/idling/types/idling_list_request_pto_state.py +5 -0
- samsara/inputs/client.py +21 -11
- samsara/inputs/raw_client.py +51 -9
- samsara/issues/client.py +27 -29
- samsara/issues/raw_client.py +53 -26
- samsara/live_shares/client.py +21 -13
- samsara/live_shares/raw_client.py +43 -8
- samsara/maintenance/service_tasks/client.py +21 -11
- samsara/maintenance/service_tasks/raw_client.py +41 -8
- samsara/maintenance/work_orders/client.py +40 -22
- samsara/maintenance/work_orders/raw_client.py +84 -16
- samsara/readings/client.py +524 -0
- samsara/readings/raw_client.py +1214 -0
- samsara/reports/drivers/fuel_energy/client.py +6 -6
- samsara/reports/drivers/fuel_energy/raw_client.py +2 -2
- samsara/reports/ifta/__init__.py +4 -4
- samsara/reports/ifta/vehicle/__init__.py +2 -2
- samsara/reports/ifta/vehicle/client.py +21 -21
- samsara/reports/ifta/vehicle/raw_client.py +17 -17
- samsara/reports/ifta/vehicle/types/__init__.py +4 -4
- samsara/reports/ifta/vehicle/types/{vehicle_get_request_fuel_type.py → vehicle_list_request_fuel_type.py} +1 -1
- samsara/reports/ifta/vehicle/types/{vehicle_get_request_month.py → vehicle_list_request_month.py} +1 -1
- samsara/reports/ifta/vehicle/types/vehicle_list_request_quarter.py +5 -0
- samsara/reports/vehicles/__init__.py +2 -2
- samsara/reports/vehicles/fuel_energy/__init__.py +2 -2
- samsara/reports/vehicles/fuel_energy/client.py +11 -11
- samsara/reports/vehicles/fuel_energy/raw_client.py +7 -7
- samsara/reports/vehicles/fuel_energy/types/__init__.py +2 -2
- samsara/reports/vehicles/fuel_energy/types/fuel_energy_list_request_energy_type.py +5 -0
- samsara/reports/vehicles/idling/client.py +27 -15
- samsara/reports/vehicles/idling/raw_client.py +59 -11
- samsara/routes/client.py +21 -11
- samsara/routes/raw_client.py +43 -8
- samsara/safety_events/audit_logs/client.py +21 -13
- samsara/safety_events/audit_logs/raw_client.py +39 -9
- samsara/safety_events/client.py +21 -11
- samsara/safety_events/raw_client.py +47 -9
- samsara/speeding_intervals/client.py +25 -17
- samsara/speeding_intervals/raw_client.py +55 -13
- samsara/tachograph/__init__.py +7 -0
- samsara/tachograph/client.py +44 -0
- samsara/{drivers/tachograph_files → tachograph/driver}/client.py +162 -15
- samsara/{drivers/tachograph_files → tachograph/driver}/raw_client.py +153 -4
- samsara/tachograph/raw_client.py +13 -0
- samsara/{vehicles/tachograph_files → tachograph/vehicles}/client.py +15 -15
- samsara/{vehicles/tachograph_files → tachograph/vehicles}/raw_client.py +4 -4
- samsara/tags/client.py +21 -11
- samsara/tags/raw_client.py +39 -8
- samsara/trailers/client.py +21 -11
- samsara/trailers/raw_client.py +43 -8
- samsara/training_courses/client.py +21 -11
- samsara/training_courses/raw_client.py +43 -9
- samsara/trips/client.py +21 -11
- samsara/trips/raw_client.py +49 -9
- samsara/types/__init__.py +406 -50
- samsara/types/advanced_idling_get_idling_events_bad_gateway_error_response_body.py +33 -0
- samsara/types/advanced_idling_get_idling_events_gateway_timeout_error_response_body.py +33 -0
- 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
- samsara/types/advanced_idling_get_idling_events_method_not_allowed_error_response_body.py +33 -0
- 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
- 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
- samsara/types/advanced_idling_get_idling_events_response_body.py +26 -0
- 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
- 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
- samsara/types/advanced_idling_get_idling_events_unauthorized_error_response_body.py +33 -0
- samsara/types/alert_object_asset_response_body.py +63 -0
- samsara/types/{assets_create_asset_response_body_type.py → alert_object_asset_response_body_type.py} +1 -1
- samsara/types/assets_create_asset_response_body.py +2 -87
- samsara/types/assets_update_asset_response_body.py +2 -87
- samsara/types/continuous_reading_alert_threshold_response_body.py +49 -0
- samsara/types/continuous_reading_alert_threshold_response_body_operation.py +7 -0
- samsara/types/continuous_reading_alert_threshold_response_body_unit.py +62 -0
- samsara/types/device_response_response_body.py +1 -1
- samsara/types/device_response_response_body_model.py +1 -0
- samsara/types/dvir_defect_get_defect_bad_gateway_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_gateway_timeout_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_internal_server_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_method_not_allowed_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_not_found_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_not_implemented_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_response_body.py +91 -0
- samsara/types/dvir_defect_get_defect_service_unavailable_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_too_many_requests_error_response_body.py +33 -0
- samsara/types/dvir_defect_get_defect_unauthorized_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_bad_gateway_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_gateway_timeout_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_internal_server_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_method_not_allowed_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_not_found_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_not_implemented_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_response_body.py +99 -0
- samsara/types/dvir_get_dvir_response_body_safety_status.py +5 -0
- samsara/types/dvir_get_dvir_response_body_type.py +5 -0
- samsara/types/dvir_get_dvir_service_unavailable_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_too_many_requests_error_response_body.py +33 -0
- samsara/types/dvir_get_dvir_unauthorized_error_response_body.py +33 -0
- samsara/types/enum_reading_alert_threshold_response_body.py +31 -0
- samsara/types/enum_value_response_body.py +31 -0
- samsara/types/equipment_gateway_engine_seconds.py +1 -1
- samsara/types/equipment_gateway_j_1939_engine_seconds.py +1 -1
- samsara/types/equipment_obd_engine_seconds.py +1 -1
- samsara/types/event_location_response_body.py +31 -0
- samsara/types/form_submission_request_field_input_object_request_body.py +7 -1
- samsara/types/form_submission_request_field_input_object_request_body_type.py +3 -1
- samsara/types/{hos_daily_logs_update_shipping_docs_response_body.py → form_submission_request_geofence_object_request_body.py} +9 -3
- samsara/types/form_submission_request_geofence_value_object_request_body.py +24 -0
- samsara/types/form_submission_response_object_response_body.py +8 -0
- samsara/types/{form_template_reference_object_request_body.py → form_template_request_object_request_body.py} +6 -4
- samsara/types/form_template_response_object_response_body.py +74 -0
- samsara/types/form_template_section_object_response_body.py +47 -0
- samsara/types/form_templates_get_form_templates_bad_gateway_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_gateway_timeout_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_internal_server_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_method_not_allowed_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_not_found_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_not_implemented_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_response_body.py +26 -0
- samsara/types/form_templates_get_form_templates_service_unavailable_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_too_many_requests_error_response_body.py +33 -0
- samsara/types/form_templates_get_form_templates_unauthorized_error_response_body.py +33 -0
- samsara/types/forms_action_object_response_body.py +43 -0
- samsara/types/forms_action_object_response_body_type.py +7 -0
- samsara/types/forms_approval_config_object_response_body.py +32 -0
- samsara/types/forms_asset_object_response_body.py +8 -1
- samsara/types/forms_check_boxes_value_object_response_body.py +7 -0
- samsara/types/forms_condition_object_response_body.py +36 -0
- samsara/types/forms_condition_object_response_body_type.py +7 -0
- samsara/types/forms_conditional_action_object_response_body.py +30 -0
- samsara/types/forms_field_definition_object_response_body.py +143 -0
- samsara/types/forms_field_definition_object_response_body_allowed_asset_types_item.py +7 -0
- samsara/types/forms_field_definition_object_response_body_allowed_date_time_value_type.py +7 -0
- samsara/types/forms_field_definition_object_response_body_type.py +22 -0
- samsara/types/forms_field_input_object_response_body.py +7 -4
- samsara/types/forms_field_input_object_response_body_type.py +20 -0
- samsara/types/forms_geofence_object_response_body.py +53 -0
- samsara/types/forms_geofence_object_response_body_entry_type.py +5 -0
- samsara/types/forms_geofence_value_object_response_body.py +24 -0
- samsara/types/forms_multiple_choice_value_object_response_body.py +8 -1
- samsara/types/forms_product_submission_approval_details_object_response_body.py +26 -0
- samsara/types/forms_select_option_object_response_body.py +47 -0
- samsara/types/forms_single_approval_config_object_response_body.py +33 -0
- samsara/types/forms_table_cell_object_response_body.py +3 -4
- samsara/types/forms_table_cell_object_response_body_type.py +8 -0
- samsara/types/forms_table_column_object_response_body.py +3 -4
- samsara/types/forms_table_column_object_response_body_type.py +8 -0
- samsara/types/forms_table_field_definition_object_response_body.py +91 -0
- samsara/types/forms_table_field_definition_object_response_body_allowed_date_time_value_type.py +7 -0
- samsara/types/forms_table_field_definition_object_response_body_type.py +8 -0
- samsara/types/fuel_cost_object_response_body.py +32 -0
- samsara/types/fuel_cost_object_response_body_currency.py +5 -0
- samsara/types/fuel_volume_response_body.py +28 -0
- samsara/types/fuel_volume_response_body_unit.py +5 -0
- samsara/types/gaseous_fuel_cost_object_response_body.py +32 -0
- samsara/types/gaseous_fuel_cost_object_response_body_currency.py +7 -0
- samsara/types/gateway_details_response_response_body.py +14 -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/idling_event_object_response_body.py +101 -0
- samsara/types/idling_event_object_response_body_address_type.py +17 -0
- samsara/types/inline_response_2005.py +24 -0
- samsara/types/inline_response_2006.py +24 -0
- samsara/types/reading_definition_response_body.py +59 -0
- samsara/types/reading_history_response_body.py +47 -0
- samsara/types/reading_snapshot_response_body.py +52 -0
- samsara/types/reading_trigger_continuous_value_object_request_body.py +51 -0
- samsara/types/reading_trigger_continuous_value_object_request_body_operation.py +7 -0
- samsara/types/reading_trigger_continuous_value_object_request_body_unit.py +62 -0
- samsara/types/reading_trigger_continuous_value_object_response_body.py +51 -0
- samsara/types/reading_trigger_continuous_value_object_response_body_operation.py +7 -0
- samsara/types/reading_trigger_continuous_value_object_response_body_unit.py +62 -0
- samsara/types/reading_trigger_details_object_request_body.py +48 -0
- samsara/types/reading_trigger_details_object_response_body.py +48 -0
- samsara/types/reading_trigger_details_response_body.py +38 -0
- samsara/types/reading_trigger_enum_value_object_request_body.py +31 -0
- samsara/types/reading_trigger_enum_value_object_response_body.py +31 -0
- samsara/types/reading_type_response_body.py +34 -0
- samsara/types/reading_type_response_body_data_type.py +5 -0
- samsara/types/readings_get_readings_history_bad_gateway_error_response_body.py +33 -0
- 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
- samsara/types/readings_get_readings_history_internal_server_error_response_body.py +33 -0
- samsara/types/readings_get_readings_history_method_not_allowed_error_response_body.py +33 -0
- samsara/types/readings_get_readings_history_not_found_error_response_body.py +33 -0
- samsara/types/readings_get_readings_history_not_implemented_error_response_body.py +33 -0
- samsara/types/readings_get_readings_history_response_body.py +26 -0
- samsara/types/readings_get_readings_history_service_unavailable_error_response_body.py +33 -0
- samsara/types/readings_get_readings_history_too_many_requests_error_response_body.py +33 -0
- samsara/types/readings_get_readings_history_unauthorized_error_response_body.py +33 -0
- samsara/types/readings_get_readings_snapshot_bad_gateway_error_response_body.py +33 -0
- samsara/types/readings_get_readings_snapshot_gateway_timeout_error_response_body.py +33 -0
- samsara/types/readings_get_readings_snapshot_internal_server_error_response_body.py +33 -0
- samsara/types/readings_get_readings_snapshot_method_not_allowed_error_response_body.py +33 -0
- samsara/types/readings_get_readings_snapshot_not_found_error_response_body.py +33 -0
- samsara/types/readings_get_readings_snapshot_not_implemented_error_response_body.py +33 -0
- samsara/types/readings_get_readings_snapshot_response_body.py +26 -0
- samsara/types/readings_get_readings_snapshot_service_unavailable_error_response_body.py +33 -0
- 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
- samsara/types/readings_get_readings_snapshot_unauthorized_error_response_body.py +33 -0
- samsara/types/readings_list_readings_definitions_bad_gateway_error_response_body.py +33 -0
- 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
- samsara/types/readings_list_readings_definitions_internal_server_error_response_body.py +33 -0
- samsara/types/readings_list_readings_definitions_method_not_allowed_error_response_body.py +33 -0
- samsara/types/readings_list_readings_definitions_not_found_error_response_body.py +33 -0
- samsara/types/readings_list_readings_definitions_not_implemented_error_response_body.py +33 -0
- samsara/types/readings_list_readings_definitions_response_body.py +26 -0
- samsara/types/readings_list_readings_definitions_service_unavailable_error_response_body.py +33 -0
- 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
- samsara/types/readings_list_readings_definitions_unauthorized_error_response_body.py +33 -0
- samsara/types/safety_score_configuration_settings_object_response_body.py +7 -0
- samsara/types/single_approval_requirements_object_response_body.py +28 -0
- samsara/types/sudden_fuel_level_drop_response_body.py +33 -0
- samsara/types/sudden_fuel_level_rise_response_body.py +33 -0
- samsara/types/trigger_params_object_request_body.py +2 -0
- samsara/types/trigger_params_object_response_body.py +2 -0
- samsara/types/unit_response_body.py +39 -0
- samsara/types/unit_response_body_base_unit.py +62 -0
- samsara/types/unit_response_body_measurement_type.py +28 -0
- samsara/types/uploaded_media_object_response_body.py +1 -1
- samsara/types/uploaded_media_object_response_body_trigger_reason.py +8 -1
- samsara/types/v_1_message.py +29 -0
- samsara/types/v_1_message_response.py +41 -0
- samsara/types/v_1_message_sender.py +27 -0
- samsara/types/v_1_messages.py +7 -0
- samsara/types/v_1_messages_response.py +7 -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_geofence_event_response_object_response_body.py +6 -0
- samsara/types/workflow_incident_details_object_response_body.py +2 -0
- samsara/types/workflow_trigger_object_request_body.py +1 -0
- samsara/types/workflow_trigger_object_response_body.py +1 -0
- samsara/user_roles/client.py +21 -11
- samsara/user_roles/raw_client.py +39 -9
- samsara/users/client.py +21 -11
- samsara/users/raw_client.py +39 -8
- samsara/v_1_messages/__init__.py +4 -0
- samsara/v_1_messages/client.py +258 -0
- samsara/v_1_messages/raw_client.py +273 -0
- samsara/vehicles/__init__.py +1 -2
- samsara/vehicles/client.py +31 -16
- samsara/vehicles/immobilizer/client.py +21 -13
- samsara/vehicles/immobilizer/raw_client.py +43 -9
- samsara/vehicles/locations/client.py +60 -32
- samsara/vehicles/locations/raw_client.py +132 -25
- samsara/vehicles/raw_client.py +61 -8
- samsara/vehicles/stats/client.py +66 -38
- samsara/vehicles/stats/raw_client.py +148 -31
- samsara/webhooks/client.py +21 -11
- samsara/webhooks/raw_client.py +41 -8
- samsara/webhooks/types/webhooks_post_webhooks_request_body_event_types_item.py +1 -0
- samsara_api-0.0.2.dist-info/METADATA +29 -0
- {samsara_api-0.0.1.dist-info → samsara_api-0.0.2.dist-info}/RECORD +328 -193
- samsara/beta/client.py +0 -161
- samsara/drivers/tachograph_activity/client.py +0 -186
- samsara/drivers/tachograph_activity/raw_client.py +0 -169
- samsara/hours_of_service/__init__.py +0 -7
- samsara/hours_of_service/client.py +0 -229
- samsara/hours_of_service/raw_client.py +0 -425
- samsara/hours_of_service/types/__init__.py +0 -9
- samsara/hours_of_service/types/hours_of_service_get_daily_logs_request_driver_activation_status.py +0 -7
- samsara/reports/ifta/vehicle/types/vehicle_get_request_quarter.py +0 -5
- samsara/reports/vehicles/fuel_energy/types/fuel_energy_get_request_energy_type.py +0 -5
- samsara/types/assets_create_asset_response_body_regulation_mode.py +0 -7
- samsara/types/assets_update_asset_response_body_regulation_mode.py +0 -7
- samsara/types/assets_update_asset_response_body_type.py +0 -7
- samsara/types/patch_shipping_docs_response_body_response_body.py +0 -93
- samsara_api-0.0.1.dist-info/METADATA +0 -214
- /samsara/{beta → forms}/__init__.py +0 -0
- /samsara/{drivers/tachograph_activity → readings}/__init__.py +0 -0
- /samsara/{drivers/tachograph_files → tachograph/driver}/__init__.py +0 -0
- /samsara/{vehicles/tachograph_files → tachograph/vehicles}/__init__.py +0 -0
- {samsara_api-0.0.1.dist-info → samsara_api-0.0.2.dist-info}/LICENSE +0 -0
- {samsara_api-0.0.1.dist-info → samsara_api-0.0.2.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,1214 @@
|
|
|
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.pagination import AsyncPager, BaseHttpResponse, SyncPager
|
|
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.reading_definition_response_body import ReadingDefinitionResponseBody
|
|
21
|
+
from ..types.reading_history_response_body import ReadingHistoryResponseBody
|
|
22
|
+
from ..types.reading_snapshot_response_body import ReadingSnapshotResponseBody
|
|
23
|
+
from ..types.readings_get_readings_history_response_body import ReadingsGetReadingsHistoryResponseBody
|
|
24
|
+
from ..types.readings_get_readings_snapshot_response_body import ReadingsGetReadingsSnapshotResponseBody
|
|
25
|
+
from ..types.readings_list_readings_definitions_response_body import ReadingsListReadingsDefinitionsResponseBody
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
class RawReadingsClient:
|
|
29
|
+
def __init__(self, *, client_wrapper: SyncClientWrapper):
|
|
30
|
+
self._client_wrapper = client_wrapper
|
|
31
|
+
|
|
32
|
+
def definitions(
|
|
33
|
+
self,
|
|
34
|
+
*,
|
|
35
|
+
after: typing.Optional[str] = None,
|
|
36
|
+
ids: typing.Optional[str] = None,
|
|
37
|
+
entity_types: typing.Optional[str] = None,
|
|
38
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
39
|
+
) -> SyncPager[ReadingDefinitionResponseBody]:
|
|
40
|
+
"""
|
|
41
|
+
An introspection endpoint for discovering the set of readings including their name, description, data type, unit, and other metadata.
|
|
42
|
+
|
|
43
|
+
<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>).
|
|
44
|
+
|
|
45
|
+
To use this endpoint, select **Read Readings** under the Closed Beta 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>
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
**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.
|
|
49
|
+
|
|
50
|
+
Parameters
|
|
51
|
+
----------
|
|
52
|
+
after : typing.Optional[str]
|
|
53
|
+
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.
|
|
54
|
+
|
|
55
|
+
ids : typing.Optional[str]
|
|
56
|
+
A String of comma separated reading IDs. Include up to 50 readings IDs. If not set, all readings are returned.
|
|
57
|
+
|
|
58
|
+
entity_types : typing.Optional[str]
|
|
59
|
+
A list of entity type to return readings for.
|
|
60
|
+
|
|
61
|
+
request_options : typing.Optional[RequestOptions]
|
|
62
|
+
Request-specific configuration.
|
|
63
|
+
|
|
64
|
+
Returns
|
|
65
|
+
-------
|
|
66
|
+
SyncPager[ReadingDefinitionResponseBody]
|
|
67
|
+
OK response.
|
|
68
|
+
"""
|
|
69
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
70
|
+
"readings/definitions",
|
|
71
|
+
method="GET",
|
|
72
|
+
params={
|
|
73
|
+
"after": after,
|
|
74
|
+
"ids": ids,
|
|
75
|
+
"entityTypes": entity_types,
|
|
76
|
+
},
|
|
77
|
+
request_options=request_options,
|
|
78
|
+
)
|
|
79
|
+
try:
|
|
80
|
+
if 200 <= _response.status_code < 300:
|
|
81
|
+
_parsed_response = typing.cast(
|
|
82
|
+
ReadingsListReadingsDefinitionsResponseBody,
|
|
83
|
+
parse_obj_as(
|
|
84
|
+
type_=ReadingsListReadingsDefinitionsResponseBody, # type: ignore
|
|
85
|
+
object_=_response.json(),
|
|
86
|
+
),
|
|
87
|
+
)
|
|
88
|
+
_items = _parsed_response.data
|
|
89
|
+
_has_next = False
|
|
90
|
+
_get_next = None
|
|
91
|
+
if _parsed_response.pagination is not None:
|
|
92
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
93
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
94
|
+
_get_next = lambda: self.definitions(
|
|
95
|
+
after=_parsed_next,
|
|
96
|
+
ids=ids,
|
|
97
|
+
entity_types=entity_types,
|
|
98
|
+
request_options=request_options,
|
|
99
|
+
)
|
|
100
|
+
return SyncPager(
|
|
101
|
+
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
|
|
102
|
+
)
|
|
103
|
+
if _response.status_code == 401:
|
|
104
|
+
raise UnauthorizedError(
|
|
105
|
+
headers=dict(_response.headers),
|
|
106
|
+
body=typing.cast(
|
|
107
|
+
typing.Optional[typing.Any],
|
|
108
|
+
parse_obj_as(
|
|
109
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
110
|
+
object_=_response.json(),
|
|
111
|
+
),
|
|
112
|
+
),
|
|
113
|
+
)
|
|
114
|
+
if _response.status_code == 404:
|
|
115
|
+
raise NotFoundError(
|
|
116
|
+
headers=dict(_response.headers),
|
|
117
|
+
body=typing.cast(
|
|
118
|
+
typing.Optional[typing.Any],
|
|
119
|
+
parse_obj_as(
|
|
120
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
121
|
+
object_=_response.json(),
|
|
122
|
+
),
|
|
123
|
+
),
|
|
124
|
+
)
|
|
125
|
+
if _response.status_code == 405:
|
|
126
|
+
raise MethodNotAllowedError(
|
|
127
|
+
headers=dict(_response.headers),
|
|
128
|
+
body=typing.cast(
|
|
129
|
+
typing.Optional[typing.Any],
|
|
130
|
+
parse_obj_as(
|
|
131
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
132
|
+
object_=_response.json(),
|
|
133
|
+
),
|
|
134
|
+
),
|
|
135
|
+
)
|
|
136
|
+
if _response.status_code == 429:
|
|
137
|
+
raise TooManyRequestsError(
|
|
138
|
+
headers=dict(_response.headers),
|
|
139
|
+
body=typing.cast(
|
|
140
|
+
typing.Optional[typing.Any],
|
|
141
|
+
parse_obj_as(
|
|
142
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
143
|
+
object_=_response.json(),
|
|
144
|
+
),
|
|
145
|
+
),
|
|
146
|
+
)
|
|
147
|
+
if _response.status_code == 500:
|
|
148
|
+
raise InternalServerError(
|
|
149
|
+
headers=dict(_response.headers),
|
|
150
|
+
body=typing.cast(
|
|
151
|
+
typing.Optional[typing.Any],
|
|
152
|
+
parse_obj_as(
|
|
153
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
154
|
+
object_=_response.json(),
|
|
155
|
+
),
|
|
156
|
+
),
|
|
157
|
+
)
|
|
158
|
+
if _response.status_code == 501:
|
|
159
|
+
raise NotImplementedError(
|
|
160
|
+
headers=dict(_response.headers),
|
|
161
|
+
body=typing.cast(
|
|
162
|
+
typing.Optional[typing.Any],
|
|
163
|
+
parse_obj_as(
|
|
164
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
165
|
+
object_=_response.json(),
|
|
166
|
+
),
|
|
167
|
+
),
|
|
168
|
+
)
|
|
169
|
+
if _response.status_code == 502:
|
|
170
|
+
raise BadGatewayError(
|
|
171
|
+
headers=dict(_response.headers),
|
|
172
|
+
body=typing.cast(
|
|
173
|
+
typing.Optional[typing.Any],
|
|
174
|
+
parse_obj_as(
|
|
175
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
176
|
+
object_=_response.json(),
|
|
177
|
+
),
|
|
178
|
+
),
|
|
179
|
+
)
|
|
180
|
+
if _response.status_code == 503:
|
|
181
|
+
raise ServiceUnavailableError(
|
|
182
|
+
headers=dict(_response.headers),
|
|
183
|
+
body=typing.cast(
|
|
184
|
+
typing.Optional[typing.Any],
|
|
185
|
+
parse_obj_as(
|
|
186
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
187
|
+
object_=_response.json(),
|
|
188
|
+
),
|
|
189
|
+
),
|
|
190
|
+
)
|
|
191
|
+
if _response.status_code == 504:
|
|
192
|
+
raise GatewayTimeoutError(
|
|
193
|
+
headers=dict(_response.headers),
|
|
194
|
+
body=typing.cast(
|
|
195
|
+
typing.Optional[typing.Any],
|
|
196
|
+
parse_obj_as(
|
|
197
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
198
|
+
object_=_response.json(),
|
|
199
|
+
),
|
|
200
|
+
),
|
|
201
|
+
)
|
|
202
|
+
_response_json = _response.json()
|
|
203
|
+
except JSONDecodeError:
|
|
204
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
205
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
206
|
+
|
|
207
|
+
def history(
|
|
208
|
+
self,
|
|
209
|
+
*,
|
|
210
|
+
reading_id: str,
|
|
211
|
+
entity_type: str,
|
|
212
|
+
after: typing.Optional[str] = None,
|
|
213
|
+
entity_ids: typing.Optional[str] = None,
|
|
214
|
+
external_ids: typing.Optional[str] = None,
|
|
215
|
+
start_time: typing.Optional[str] = None,
|
|
216
|
+
end_time: typing.Optional[str] = None,
|
|
217
|
+
feed: typing.Optional[bool] = None,
|
|
218
|
+
include_external_ids: typing.Optional[bool] = None,
|
|
219
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
220
|
+
) -> SyncPager[ReadingHistoryResponseBody]:
|
|
221
|
+
"""
|
|
222
|
+
Get the values of a reading for a set of entities within the specified time range. Returns a paginated response with data for the specified resource IDs where startTime <= happenedAtTime < endTime. End time of null implies endTime is infinite and all known readings are returned.
|
|
223
|
+
|
|
224
|
+
<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>).
|
|
225
|
+
|
|
226
|
+
To use this endpoint, select **Read Readings** under the Closed Beta 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>
|
|
227
|
+
|
|
228
|
+
|
|
229
|
+
**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.
|
|
230
|
+
|
|
231
|
+
Parameters
|
|
232
|
+
----------
|
|
233
|
+
reading_id : str
|
|
234
|
+
The reading ID to retrieve data for. Use /readings/definitions endpoint to get a list of valid reading IDs.
|
|
235
|
+
|
|
236
|
+
entity_type : str
|
|
237
|
+
A entity type of the entityIds or externalIds to fetch readings for. Use /readings/definitions endpoint to get a list of valid entity types.
|
|
238
|
+
|
|
239
|
+
after : typing.Optional[str]
|
|
240
|
+
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.
|
|
241
|
+
|
|
242
|
+
entity_ids : typing.Optional[str]
|
|
243
|
+
A filter on the data based on this comma-separated list of entity IDs or external IDs.
|
|
244
|
+
|
|
245
|
+
external_ids : typing.Optional[str]
|
|
246
|
+
A filter on the data based on this comma-separated list of external IDs.
|
|
247
|
+
|
|
248
|
+
start_time : typing.Optional[str]
|
|
249
|
+
A filter on the data that returns the last known data points with timestamps greater than or equal to this value. Must be a string in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
250
|
+
|
|
251
|
+
end_time : typing.Optional[str]
|
|
252
|
+
A filter on the data that returns the last known data points with timestamps less than or equal to this value. If not set, the time of the request is considered the endTime. Must be a string in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
253
|
+
|
|
254
|
+
feed : typing.Optional[bool]
|
|
255
|
+
Set to true to enable feed mode for continuous reading updates. When enabled, the API always includes an endCursor in the response. If hasNextPage is false, it indicates that no new data is currently available — wait at least 5 seconds before making the next request to avoid unnecessary polling.
|
|
256
|
+
|
|
257
|
+
include_external_ids : typing.Optional[bool]
|
|
258
|
+
Optional boolean indicating whether to return external IDs on supported entities
|
|
259
|
+
|
|
260
|
+
request_options : typing.Optional[RequestOptions]
|
|
261
|
+
Request-specific configuration.
|
|
262
|
+
|
|
263
|
+
Returns
|
|
264
|
+
-------
|
|
265
|
+
SyncPager[ReadingHistoryResponseBody]
|
|
266
|
+
OK response.
|
|
267
|
+
"""
|
|
268
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
269
|
+
"readings/history",
|
|
270
|
+
method="GET",
|
|
271
|
+
params={
|
|
272
|
+
"after": after,
|
|
273
|
+
"readingId": reading_id,
|
|
274
|
+
"entityIds": entity_ids,
|
|
275
|
+
"entityType": entity_type,
|
|
276
|
+
"externalIds": external_ids,
|
|
277
|
+
"startTime": start_time,
|
|
278
|
+
"endTime": end_time,
|
|
279
|
+
"feed": feed,
|
|
280
|
+
"includeExternalIds": include_external_ids,
|
|
281
|
+
},
|
|
282
|
+
request_options=request_options,
|
|
283
|
+
)
|
|
284
|
+
try:
|
|
285
|
+
if 200 <= _response.status_code < 300:
|
|
286
|
+
_parsed_response = typing.cast(
|
|
287
|
+
ReadingsGetReadingsHistoryResponseBody,
|
|
288
|
+
parse_obj_as(
|
|
289
|
+
type_=ReadingsGetReadingsHistoryResponseBody, # type: ignore
|
|
290
|
+
object_=_response.json(),
|
|
291
|
+
),
|
|
292
|
+
)
|
|
293
|
+
_items = _parsed_response.data
|
|
294
|
+
_has_next = False
|
|
295
|
+
_get_next = None
|
|
296
|
+
if _parsed_response.pagination is not None:
|
|
297
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
298
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
299
|
+
_get_next = lambda: self.history(
|
|
300
|
+
reading_id=reading_id,
|
|
301
|
+
entity_type=entity_type,
|
|
302
|
+
after=_parsed_next,
|
|
303
|
+
entity_ids=entity_ids,
|
|
304
|
+
external_ids=external_ids,
|
|
305
|
+
start_time=start_time,
|
|
306
|
+
end_time=end_time,
|
|
307
|
+
feed=feed,
|
|
308
|
+
include_external_ids=include_external_ids,
|
|
309
|
+
request_options=request_options,
|
|
310
|
+
)
|
|
311
|
+
return SyncPager(
|
|
312
|
+
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
|
|
313
|
+
)
|
|
314
|
+
if _response.status_code == 401:
|
|
315
|
+
raise UnauthorizedError(
|
|
316
|
+
headers=dict(_response.headers),
|
|
317
|
+
body=typing.cast(
|
|
318
|
+
typing.Optional[typing.Any],
|
|
319
|
+
parse_obj_as(
|
|
320
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
321
|
+
object_=_response.json(),
|
|
322
|
+
),
|
|
323
|
+
),
|
|
324
|
+
)
|
|
325
|
+
if _response.status_code == 404:
|
|
326
|
+
raise NotFoundError(
|
|
327
|
+
headers=dict(_response.headers),
|
|
328
|
+
body=typing.cast(
|
|
329
|
+
typing.Optional[typing.Any],
|
|
330
|
+
parse_obj_as(
|
|
331
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
332
|
+
object_=_response.json(),
|
|
333
|
+
),
|
|
334
|
+
),
|
|
335
|
+
)
|
|
336
|
+
if _response.status_code == 405:
|
|
337
|
+
raise MethodNotAllowedError(
|
|
338
|
+
headers=dict(_response.headers),
|
|
339
|
+
body=typing.cast(
|
|
340
|
+
typing.Optional[typing.Any],
|
|
341
|
+
parse_obj_as(
|
|
342
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
343
|
+
object_=_response.json(),
|
|
344
|
+
),
|
|
345
|
+
),
|
|
346
|
+
)
|
|
347
|
+
if _response.status_code == 429:
|
|
348
|
+
raise TooManyRequestsError(
|
|
349
|
+
headers=dict(_response.headers),
|
|
350
|
+
body=typing.cast(
|
|
351
|
+
typing.Optional[typing.Any],
|
|
352
|
+
parse_obj_as(
|
|
353
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
354
|
+
object_=_response.json(),
|
|
355
|
+
),
|
|
356
|
+
),
|
|
357
|
+
)
|
|
358
|
+
if _response.status_code == 500:
|
|
359
|
+
raise InternalServerError(
|
|
360
|
+
headers=dict(_response.headers),
|
|
361
|
+
body=typing.cast(
|
|
362
|
+
typing.Optional[typing.Any],
|
|
363
|
+
parse_obj_as(
|
|
364
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
365
|
+
object_=_response.json(),
|
|
366
|
+
),
|
|
367
|
+
),
|
|
368
|
+
)
|
|
369
|
+
if _response.status_code == 501:
|
|
370
|
+
raise NotImplementedError(
|
|
371
|
+
headers=dict(_response.headers),
|
|
372
|
+
body=typing.cast(
|
|
373
|
+
typing.Optional[typing.Any],
|
|
374
|
+
parse_obj_as(
|
|
375
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
376
|
+
object_=_response.json(),
|
|
377
|
+
),
|
|
378
|
+
),
|
|
379
|
+
)
|
|
380
|
+
if _response.status_code == 502:
|
|
381
|
+
raise BadGatewayError(
|
|
382
|
+
headers=dict(_response.headers),
|
|
383
|
+
body=typing.cast(
|
|
384
|
+
typing.Optional[typing.Any],
|
|
385
|
+
parse_obj_as(
|
|
386
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
387
|
+
object_=_response.json(),
|
|
388
|
+
),
|
|
389
|
+
),
|
|
390
|
+
)
|
|
391
|
+
if _response.status_code == 503:
|
|
392
|
+
raise ServiceUnavailableError(
|
|
393
|
+
headers=dict(_response.headers),
|
|
394
|
+
body=typing.cast(
|
|
395
|
+
typing.Optional[typing.Any],
|
|
396
|
+
parse_obj_as(
|
|
397
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
398
|
+
object_=_response.json(),
|
|
399
|
+
),
|
|
400
|
+
),
|
|
401
|
+
)
|
|
402
|
+
if _response.status_code == 504:
|
|
403
|
+
raise GatewayTimeoutError(
|
|
404
|
+
headers=dict(_response.headers),
|
|
405
|
+
body=typing.cast(
|
|
406
|
+
typing.Optional[typing.Any],
|
|
407
|
+
parse_obj_as(
|
|
408
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
409
|
+
object_=_response.json(),
|
|
410
|
+
),
|
|
411
|
+
),
|
|
412
|
+
)
|
|
413
|
+
_response_json = _response.json()
|
|
414
|
+
except JSONDecodeError:
|
|
415
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
416
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
417
|
+
|
|
418
|
+
def latest(
|
|
419
|
+
self,
|
|
420
|
+
*,
|
|
421
|
+
reading_ids: str,
|
|
422
|
+
entity_type: str,
|
|
423
|
+
after: typing.Optional[str] = None,
|
|
424
|
+
entity_ids: typing.Optional[str] = None,
|
|
425
|
+
external_ids: typing.Optional[str] = None,
|
|
426
|
+
as_of_time: typing.Optional[str] = None,
|
|
427
|
+
include_external_ids: typing.Optional[bool] = None,
|
|
428
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
429
|
+
) -> SyncPager[ReadingSnapshotResponseBody]:
|
|
430
|
+
"""
|
|
431
|
+
An endpoint to get the last value of a reading for a set of entities at the specified time.
|
|
432
|
+
|
|
433
|
+
<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>).
|
|
434
|
+
|
|
435
|
+
To use this endpoint, select **Read Readings** under the Closed Beta 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>
|
|
436
|
+
|
|
437
|
+
|
|
438
|
+
**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.
|
|
439
|
+
|
|
440
|
+
Parameters
|
|
441
|
+
----------
|
|
442
|
+
reading_ids : str
|
|
443
|
+
A collection of comma separated reading IDs. Include up to 3 readings IDs. Use /readings/definitions endpoint to get a list of valid reading IDs.
|
|
444
|
+
|
|
445
|
+
entity_type : str
|
|
446
|
+
A entity type of the entityIds or externalIds to fetch readings for. Use /readings/definitions endpoint to get a list of valid entity types.
|
|
447
|
+
|
|
448
|
+
after : typing.Optional[str]
|
|
449
|
+
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.
|
|
450
|
+
|
|
451
|
+
entity_ids : typing.Optional[str]
|
|
452
|
+
A filter on the data based on this comma-separated list of entity IDs or external IDs.
|
|
453
|
+
|
|
454
|
+
external_ids : typing.Optional[str]
|
|
455
|
+
A filter on the data based on this comma-separated list of external IDs.
|
|
456
|
+
|
|
457
|
+
as_of_time : typing.Optional[str]
|
|
458
|
+
A filter on the data that returns the last known data points with timestamps less than or equal to this value. Defaults to now if not provided. Must be a string in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
459
|
+
|
|
460
|
+
include_external_ids : typing.Optional[bool]
|
|
461
|
+
Optional boolean indicating whether to return external IDs on supported entities
|
|
462
|
+
|
|
463
|
+
request_options : typing.Optional[RequestOptions]
|
|
464
|
+
Request-specific configuration.
|
|
465
|
+
|
|
466
|
+
Returns
|
|
467
|
+
-------
|
|
468
|
+
SyncPager[ReadingSnapshotResponseBody]
|
|
469
|
+
OK response.
|
|
470
|
+
"""
|
|
471
|
+
_response = self._client_wrapper.httpx_client.request(
|
|
472
|
+
"readings/latest",
|
|
473
|
+
method="GET",
|
|
474
|
+
params={
|
|
475
|
+
"after": after,
|
|
476
|
+
"readingIds": reading_ids,
|
|
477
|
+
"entityIds": entity_ids,
|
|
478
|
+
"externalIds": external_ids,
|
|
479
|
+
"asOfTime": as_of_time,
|
|
480
|
+
"entityType": entity_type,
|
|
481
|
+
"includeExternalIds": include_external_ids,
|
|
482
|
+
},
|
|
483
|
+
request_options=request_options,
|
|
484
|
+
)
|
|
485
|
+
try:
|
|
486
|
+
if 200 <= _response.status_code < 300:
|
|
487
|
+
_parsed_response = typing.cast(
|
|
488
|
+
ReadingsGetReadingsSnapshotResponseBody,
|
|
489
|
+
parse_obj_as(
|
|
490
|
+
type_=ReadingsGetReadingsSnapshotResponseBody, # type: ignore
|
|
491
|
+
object_=_response.json(),
|
|
492
|
+
),
|
|
493
|
+
)
|
|
494
|
+
_items = _parsed_response.data
|
|
495
|
+
_has_next = False
|
|
496
|
+
_get_next = None
|
|
497
|
+
if _parsed_response.pagination is not None:
|
|
498
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
499
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
500
|
+
_get_next = lambda: self.latest(
|
|
501
|
+
reading_ids=reading_ids,
|
|
502
|
+
entity_type=entity_type,
|
|
503
|
+
after=_parsed_next,
|
|
504
|
+
entity_ids=entity_ids,
|
|
505
|
+
external_ids=external_ids,
|
|
506
|
+
as_of_time=as_of_time,
|
|
507
|
+
include_external_ids=include_external_ids,
|
|
508
|
+
request_options=request_options,
|
|
509
|
+
)
|
|
510
|
+
return SyncPager(
|
|
511
|
+
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
|
|
512
|
+
)
|
|
513
|
+
if _response.status_code == 401:
|
|
514
|
+
raise UnauthorizedError(
|
|
515
|
+
headers=dict(_response.headers),
|
|
516
|
+
body=typing.cast(
|
|
517
|
+
typing.Optional[typing.Any],
|
|
518
|
+
parse_obj_as(
|
|
519
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
520
|
+
object_=_response.json(),
|
|
521
|
+
),
|
|
522
|
+
),
|
|
523
|
+
)
|
|
524
|
+
if _response.status_code == 404:
|
|
525
|
+
raise NotFoundError(
|
|
526
|
+
headers=dict(_response.headers),
|
|
527
|
+
body=typing.cast(
|
|
528
|
+
typing.Optional[typing.Any],
|
|
529
|
+
parse_obj_as(
|
|
530
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
531
|
+
object_=_response.json(),
|
|
532
|
+
),
|
|
533
|
+
),
|
|
534
|
+
)
|
|
535
|
+
if _response.status_code == 405:
|
|
536
|
+
raise MethodNotAllowedError(
|
|
537
|
+
headers=dict(_response.headers),
|
|
538
|
+
body=typing.cast(
|
|
539
|
+
typing.Optional[typing.Any],
|
|
540
|
+
parse_obj_as(
|
|
541
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
542
|
+
object_=_response.json(),
|
|
543
|
+
),
|
|
544
|
+
),
|
|
545
|
+
)
|
|
546
|
+
if _response.status_code == 429:
|
|
547
|
+
raise TooManyRequestsError(
|
|
548
|
+
headers=dict(_response.headers),
|
|
549
|
+
body=typing.cast(
|
|
550
|
+
typing.Optional[typing.Any],
|
|
551
|
+
parse_obj_as(
|
|
552
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
553
|
+
object_=_response.json(),
|
|
554
|
+
),
|
|
555
|
+
),
|
|
556
|
+
)
|
|
557
|
+
if _response.status_code == 500:
|
|
558
|
+
raise InternalServerError(
|
|
559
|
+
headers=dict(_response.headers),
|
|
560
|
+
body=typing.cast(
|
|
561
|
+
typing.Optional[typing.Any],
|
|
562
|
+
parse_obj_as(
|
|
563
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
564
|
+
object_=_response.json(),
|
|
565
|
+
),
|
|
566
|
+
),
|
|
567
|
+
)
|
|
568
|
+
if _response.status_code == 501:
|
|
569
|
+
raise NotImplementedError(
|
|
570
|
+
headers=dict(_response.headers),
|
|
571
|
+
body=typing.cast(
|
|
572
|
+
typing.Optional[typing.Any],
|
|
573
|
+
parse_obj_as(
|
|
574
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
575
|
+
object_=_response.json(),
|
|
576
|
+
),
|
|
577
|
+
),
|
|
578
|
+
)
|
|
579
|
+
if _response.status_code == 502:
|
|
580
|
+
raise BadGatewayError(
|
|
581
|
+
headers=dict(_response.headers),
|
|
582
|
+
body=typing.cast(
|
|
583
|
+
typing.Optional[typing.Any],
|
|
584
|
+
parse_obj_as(
|
|
585
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
586
|
+
object_=_response.json(),
|
|
587
|
+
),
|
|
588
|
+
),
|
|
589
|
+
)
|
|
590
|
+
if _response.status_code == 503:
|
|
591
|
+
raise ServiceUnavailableError(
|
|
592
|
+
headers=dict(_response.headers),
|
|
593
|
+
body=typing.cast(
|
|
594
|
+
typing.Optional[typing.Any],
|
|
595
|
+
parse_obj_as(
|
|
596
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
597
|
+
object_=_response.json(),
|
|
598
|
+
),
|
|
599
|
+
),
|
|
600
|
+
)
|
|
601
|
+
if _response.status_code == 504:
|
|
602
|
+
raise GatewayTimeoutError(
|
|
603
|
+
headers=dict(_response.headers),
|
|
604
|
+
body=typing.cast(
|
|
605
|
+
typing.Optional[typing.Any],
|
|
606
|
+
parse_obj_as(
|
|
607
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
608
|
+
object_=_response.json(),
|
|
609
|
+
),
|
|
610
|
+
),
|
|
611
|
+
)
|
|
612
|
+
_response_json = _response.json()
|
|
613
|
+
except JSONDecodeError:
|
|
614
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
615
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
616
|
+
|
|
617
|
+
|
|
618
|
+
class AsyncRawReadingsClient:
|
|
619
|
+
def __init__(self, *, client_wrapper: AsyncClientWrapper):
|
|
620
|
+
self._client_wrapper = client_wrapper
|
|
621
|
+
|
|
622
|
+
async def definitions(
|
|
623
|
+
self,
|
|
624
|
+
*,
|
|
625
|
+
after: typing.Optional[str] = None,
|
|
626
|
+
ids: typing.Optional[str] = None,
|
|
627
|
+
entity_types: typing.Optional[str] = None,
|
|
628
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
629
|
+
) -> AsyncPager[ReadingDefinitionResponseBody]:
|
|
630
|
+
"""
|
|
631
|
+
An introspection endpoint for discovering the set of readings including their name, description, data type, unit, and other metadata.
|
|
632
|
+
|
|
633
|
+
<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>).
|
|
634
|
+
|
|
635
|
+
To use this endpoint, select **Read Readings** under the Closed Beta 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>
|
|
636
|
+
|
|
637
|
+
|
|
638
|
+
**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.
|
|
639
|
+
|
|
640
|
+
Parameters
|
|
641
|
+
----------
|
|
642
|
+
after : typing.Optional[str]
|
|
643
|
+
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.
|
|
644
|
+
|
|
645
|
+
ids : typing.Optional[str]
|
|
646
|
+
A String of comma separated reading IDs. Include up to 50 readings IDs. If not set, all readings are returned.
|
|
647
|
+
|
|
648
|
+
entity_types : typing.Optional[str]
|
|
649
|
+
A list of entity type to return readings for.
|
|
650
|
+
|
|
651
|
+
request_options : typing.Optional[RequestOptions]
|
|
652
|
+
Request-specific configuration.
|
|
653
|
+
|
|
654
|
+
Returns
|
|
655
|
+
-------
|
|
656
|
+
AsyncPager[ReadingDefinitionResponseBody]
|
|
657
|
+
OK response.
|
|
658
|
+
"""
|
|
659
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
660
|
+
"readings/definitions",
|
|
661
|
+
method="GET",
|
|
662
|
+
params={
|
|
663
|
+
"after": after,
|
|
664
|
+
"ids": ids,
|
|
665
|
+
"entityTypes": entity_types,
|
|
666
|
+
},
|
|
667
|
+
request_options=request_options,
|
|
668
|
+
)
|
|
669
|
+
try:
|
|
670
|
+
if 200 <= _response.status_code < 300:
|
|
671
|
+
_parsed_response = typing.cast(
|
|
672
|
+
ReadingsListReadingsDefinitionsResponseBody,
|
|
673
|
+
parse_obj_as(
|
|
674
|
+
type_=ReadingsListReadingsDefinitionsResponseBody, # type: ignore
|
|
675
|
+
object_=_response.json(),
|
|
676
|
+
),
|
|
677
|
+
)
|
|
678
|
+
_items = _parsed_response.data
|
|
679
|
+
_has_next = False
|
|
680
|
+
_get_next = None
|
|
681
|
+
if _parsed_response.pagination is not None:
|
|
682
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
683
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
684
|
+
|
|
685
|
+
async def _get_next():
|
|
686
|
+
return await self.definitions(
|
|
687
|
+
after=_parsed_next,
|
|
688
|
+
ids=ids,
|
|
689
|
+
entity_types=entity_types,
|
|
690
|
+
request_options=request_options,
|
|
691
|
+
)
|
|
692
|
+
|
|
693
|
+
return AsyncPager(
|
|
694
|
+
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
|
|
695
|
+
)
|
|
696
|
+
if _response.status_code == 401:
|
|
697
|
+
raise UnauthorizedError(
|
|
698
|
+
headers=dict(_response.headers),
|
|
699
|
+
body=typing.cast(
|
|
700
|
+
typing.Optional[typing.Any],
|
|
701
|
+
parse_obj_as(
|
|
702
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
703
|
+
object_=_response.json(),
|
|
704
|
+
),
|
|
705
|
+
),
|
|
706
|
+
)
|
|
707
|
+
if _response.status_code == 404:
|
|
708
|
+
raise NotFoundError(
|
|
709
|
+
headers=dict(_response.headers),
|
|
710
|
+
body=typing.cast(
|
|
711
|
+
typing.Optional[typing.Any],
|
|
712
|
+
parse_obj_as(
|
|
713
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
714
|
+
object_=_response.json(),
|
|
715
|
+
),
|
|
716
|
+
),
|
|
717
|
+
)
|
|
718
|
+
if _response.status_code == 405:
|
|
719
|
+
raise MethodNotAllowedError(
|
|
720
|
+
headers=dict(_response.headers),
|
|
721
|
+
body=typing.cast(
|
|
722
|
+
typing.Optional[typing.Any],
|
|
723
|
+
parse_obj_as(
|
|
724
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
725
|
+
object_=_response.json(),
|
|
726
|
+
),
|
|
727
|
+
),
|
|
728
|
+
)
|
|
729
|
+
if _response.status_code == 429:
|
|
730
|
+
raise TooManyRequestsError(
|
|
731
|
+
headers=dict(_response.headers),
|
|
732
|
+
body=typing.cast(
|
|
733
|
+
typing.Optional[typing.Any],
|
|
734
|
+
parse_obj_as(
|
|
735
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
736
|
+
object_=_response.json(),
|
|
737
|
+
),
|
|
738
|
+
),
|
|
739
|
+
)
|
|
740
|
+
if _response.status_code == 500:
|
|
741
|
+
raise InternalServerError(
|
|
742
|
+
headers=dict(_response.headers),
|
|
743
|
+
body=typing.cast(
|
|
744
|
+
typing.Optional[typing.Any],
|
|
745
|
+
parse_obj_as(
|
|
746
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
747
|
+
object_=_response.json(),
|
|
748
|
+
),
|
|
749
|
+
),
|
|
750
|
+
)
|
|
751
|
+
if _response.status_code == 501:
|
|
752
|
+
raise NotImplementedError(
|
|
753
|
+
headers=dict(_response.headers),
|
|
754
|
+
body=typing.cast(
|
|
755
|
+
typing.Optional[typing.Any],
|
|
756
|
+
parse_obj_as(
|
|
757
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
758
|
+
object_=_response.json(),
|
|
759
|
+
),
|
|
760
|
+
),
|
|
761
|
+
)
|
|
762
|
+
if _response.status_code == 502:
|
|
763
|
+
raise BadGatewayError(
|
|
764
|
+
headers=dict(_response.headers),
|
|
765
|
+
body=typing.cast(
|
|
766
|
+
typing.Optional[typing.Any],
|
|
767
|
+
parse_obj_as(
|
|
768
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
769
|
+
object_=_response.json(),
|
|
770
|
+
),
|
|
771
|
+
),
|
|
772
|
+
)
|
|
773
|
+
if _response.status_code == 503:
|
|
774
|
+
raise ServiceUnavailableError(
|
|
775
|
+
headers=dict(_response.headers),
|
|
776
|
+
body=typing.cast(
|
|
777
|
+
typing.Optional[typing.Any],
|
|
778
|
+
parse_obj_as(
|
|
779
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
780
|
+
object_=_response.json(),
|
|
781
|
+
),
|
|
782
|
+
),
|
|
783
|
+
)
|
|
784
|
+
if _response.status_code == 504:
|
|
785
|
+
raise GatewayTimeoutError(
|
|
786
|
+
headers=dict(_response.headers),
|
|
787
|
+
body=typing.cast(
|
|
788
|
+
typing.Optional[typing.Any],
|
|
789
|
+
parse_obj_as(
|
|
790
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
791
|
+
object_=_response.json(),
|
|
792
|
+
),
|
|
793
|
+
),
|
|
794
|
+
)
|
|
795
|
+
_response_json = _response.json()
|
|
796
|
+
except JSONDecodeError:
|
|
797
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
798
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
799
|
+
|
|
800
|
+
async def history(
|
|
801
|
+
self,
|
|
802
|
+
*,
|
|
803
|
+
reading_id: str,
|
|
804
|
+
entity_type: str,
|
|
805
|
+
after: typing.Optional[str] = None,
|
|
806
|
+
entity_ids: typing.Optional[str] = None,
|
|
807
|
+
external_ids: typing.Optional[str] = None,
|
|
808
|
+
start_time: typing.Optional[str] = None,
|
|
809
|
+
end_time: typing.Optional[str] = None,
|
|
810
|
+
feed: typing.Optional[bool] = None,
|
|
811
|
+
include_external_ids: typing.Optional[bool] = None,
|
|
812
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
813
|
+
) -> AsyncPager[ReadingHistoryResponseBody]:
|
|
814
|
+
"""
|
|
815
|
+
Get the values of a reading for a set of entities within the specified time range. Returns a paginated response with data for the specified resource IDs where startTime <= happenedAtTime < endTime. End time of null implies endTime is infinite and all known readings are returned.
|
|
816
|
+
|
|
817
|
+
<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>).
|
|
818
|
+
|
|
819
|
+
To use this endpoint, select **Read Readings** under the Closed Beta 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>
|
|
820
|
+
|
|
821
|
+
|
|
822
|
+
**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.
|
|
823
|
+
|
|
824
|
+
Parameters
|
|
825
|
+
----------
|
|
826
|
+
reading_id : str
|
|
827
|
+
The reading ID to retrieve data for. Use /readings/definitions endpoint to get a list of valid reading IDs.
|
|
828
|
+
|
|
829
|
+
entity_type : str
|
|
830
|
+
A entity type of the entityIds or externalIds to fetch readings for. Use /readings/definitions endpoint to get a list of valid entity types.
|
|
831
|
+
|
|
832
|
+
after : typing.Optional[str]
|
|
833
|
+
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.
|
|
834
|
+
|
|
835
|
+
entity_ids : typing.Optional[str]
|
|
836
|
+
A filter on the data based on this comma-separated list of entity IDs or external IDs.
|
|
837
|
+
|
|
838
|
+
external_ids : typing.Optional[str]
|
|
839
|
+
A filter on the data based on this comma-separated list of external IDs.
|
|
840
|
+
|
|
841
|
+
start_time : typing.Optional[str]
|
|
842
|
+
A filter on the data that returns the last known data points with timestamps greater than or equal to this value. Must be a string in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
843
|
+
|
|
844
|
+
end_time : typing.Optional[str]
|
|
845
|
+
A filter on the data that returns the last known data points with timestamps less than or equal to this value. If not set, the time of the request is considered the endTime. Must be a string in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
846
|
+
|
|
847
|
+
feed : typing.Optional[bool]
|
|
848
|
+
Set to true to enable feed mode for continuous reading updates. When enabled, the API always includes an endCursor in the response. If hasNextPage is false, it indicates that no new data is currently available — wait at least 5 seconds before making the next request to avoid unnecessary polling.
|
|
849
|
+
|
|
850
|
+
include_external_ids : typing.Optional[bool]
|
|
851
|
+
Optional boolean indicating whether to return external IDs on supported entities
|
|
852
|
+
|
|
853
|
+
request_options : typing.Optional[RequestOptions]
|
|
854
|
+
Request-specific configuration.
|
|
855
|
+
|
|
856
|
+
Returns
|
|
857
|
+
-------
|
|
858
|
+
AsyncPager[ReadingHistoryResponseBody]
|
|
859
|
+
OK response.
|
|
860
|
+
"""
|
|
861
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
862
|
+
"readings/history",
|
|
863
|
+
method="GET",
|
|
864
|
+
params={
|
|
865
|
+
"after": after,
|
|
866
|
+
"readingId": reading_id,
|
|
867
|
+
"entityIds": entity_ids,
|
|
868
|
+
"entityType": entity_type,
|
|
869
|
+
"externalIds": external_ids,
|
|
870
|
+
"startTime": start_time,
|
|
871
|
+
"endTime": end_time,
|
|
872
|
+
"feed": feed,
|
|
873
|
+
"includeExternalIds": include_external_ids,
|
|
874
|
+
},
|
|
875
|
+
request_options=request_options,
|
|
876
|
+
)
|
|
877
|
+
try:
|
|
878
|
+
if 200 <= _response.status_code < 300:
|
|
879
|
+
_parsed_response = typing.cast(
|
|
880
|
+
ReadingsGetReadingsHistoryResponseBody,
|
|
881
|
+
parse_obj_as(
|
|
882
|
+
type_=ReadingsGetReadingsHistoryResponseBody, # type: ignore
|
|
883
|
+
object_=_response.json(),
|
|
884
|
+
),
|
|
885
|
+
)
|
|
886
|
+
_items = _parsed_response.data
|
|
887
|
+
_has_next = False
|
|
888
|
+
_get_next = None
|
|
889
|
+
if _parsed_response.pagination is not None:
|
|
890
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
891
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
892
|
+
|
|
893
|
+
async def _get_next():
|
|
894
|
+
return await self.history(
|
|
895
|
+
reading_id=reading_id,
|
|
896
|
+
entity_type=entity_type,
|
|
897
|
+
after=_parsed_next,
|
|
898
|
+
entity_ids=entity_ids,
|
|
899
|
+
external_ids=external_ids,
|
|
900
|
+
start_time=start_time,
|
|
901
|
+
end_time=end_time,
|
|
902
|
+
feed=feed,
|
|
903
|
+
include_external_ids=include_external_ids,
|
|
904
|
+
request_options=request_options,
|
|
905
|
+
)
|
|
906
|
+
|
|
907
|
+
return AsyncPager(
|
|
908
|
+
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
|
|
909
|
+
)
|
|
910
|
+
if _response.status_code == 401:
|
|
911
|
+
raise UnauthorizedError(
|
|
912
|
+
headers=dict(_response.headers),
|
|
913
|
+
body=typing.cast(
|
|
914
|
+
typing.Optional[typing.Any],
|
|
915
|
+
parse_obj_as(
|
|
916
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
917
|
+
object_=_response.json(),
|
|
918
|
+
),
|
|
919
|
+
),
|
|
920
|
+
)
|
|
921
|
+
if _response.status_code == 404:
|
|
922
|
+
raise NotFoundError(
|
|
923
|
+
headers=dict(_response.headers),
|
|
924
|
+
body=typing.cast(
|
|
925
|
+
typing.Optional[typing.Any],
|
|
926
|
+
parse_obj_as(
|
|
927
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
928
|
+
object_=_response.json(),
|
|
929
|
+
),
|
|
930
|
+
),
|
|
931
|
+
)
|
|
932
|
+
if _response.status_code == 405:
|
|
933
|
+
raise MethodNotAllowedError(
|
|
934
|
+
headers=dict(_response.headers),
|
|
935
|
+
body=typing.cast(
|
|
936
|
+
typing.Optional[typing.Any],
|
|
937
|
+
parse_obj_as(
|
|
938
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
939
|
+
object_=_response.json(),
|
|
940
|
+
),
|
|
941
|
+
),
|
|
942
|
+
)
|
|
943
|
+
if _response.status_code == 429:
|
|
944
|
+
raise TooManyRequestsError(
|
|
945
|
+
headers=dict(_response.headers),
|
|
946
|
+
body=typing.cast(
|
|
947
|
+
typing.Optional[typing.Any],
|
|
948
|
+
parse_obj_as(
|
|
949
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
950
|
+
object_=_response.json(),
|
|
951
|
+
),
|
|
952
|
+
),
|
|
953
|
+
)
|
|
954
|
+
if _response.status_code == 500:
|
|
955
|
+
raise InternalServerError(
|
|
956
|
+
headers=dict(_response.headers),
|
|
957
|
+
body=typing.cast(
|
|
958
|
+
typing.Optional[typing.Any],
|
|
959
|
+
parse_obj_as(
|
|
960
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
961
|
+
object_=_response.json(),
|
|
962
|
+
),
|
|
963
|
+
),
|
|
964
|
+
)
|
|
965
|
+
if _response.status_code == 501:
|
|
966
|
+
raise NotImplementedError(
|
|
967
|
+
headers=dict(_response.headers),
|
|
968
|
+
body=typing.cast(
|
|
969
|
+
typing.Optional[typing.Any],
|
|
970
|
+
parse_obj_as(
|
|
971
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
972
|
+
object_=_response.json(),
|
|
973
|
+
),
|
|
974
|
+
),
|
|
975
|
+
)
|
|
976
|
+
if _response.status_code == 502:
|
|
977
|
+
raise BadGatewayError(
|
|
978
|
+
headers=dict(_response.headers),
|
|
979
|
+
body=typing.cast(
|
|
980
|
+
typing.Optional[typing.Any],
|
|
981
|
+
parse_obj_as(
|
|
982
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
983
|
+
object_=_response.json(),
|
|
984
|
+
),
|
|
985
|
+
),
|
|
986
|
+
)
|
|
987
|
+
if _response.status_code == 503:
|
|
988
|
+
raise ServiceUnavailableError(
|
|
989
|
+
headers=dict(_response.headers),
|
|
990
|
+
body=typing.cast(
|
|
991
|
+
typing.Optional[typing.Any],
|
|
992
|
+
parse_obj_as(
|
|
993
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
994
|
+
object_=_response.json(),
|
|
995
|
+
),
|
|
996
|
+
),
|
|
997
|
+
)
|
|
998
|
+
if _response.status_code == 504:
|
|
999
|
+
raise GatewayTimeoutError(
|
|
1000
|
+
headers=dict(_response.headers),
|
|
1001
|
+
body=typing.cast(
|
|
1002
|
+
typing.Optional[typing.Any],
|
|
1003
|
+
parse_obj_as(
|
|
1004
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1005
|
+
object_=_response.json(),
|
|
1006
|
+
),
|
|
1007
|
+
),
|
|
1008
|
+
)
|
|
1009
|
+
_response_json = _response.json()
|
|
1010
|
+
except JSONDecodeError:
|
|
1011
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1012
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|
|
1013
|
+
|
|
1014
|
+
async def latest(
|
|
1015
|
+
self,
|
|
1016
|
+
*,
|
|
1017
|
+
reading_ids: str,
|
|
1018
|
+
entity_type: str,
|
|
1019
|
+
after: typing.Optional[str] = None,
|
|
1020
|
+
entity_ids: typing.Optional[str] = None,
|
|
1021
|
+
external_ids: typing.Optional[str] = None,
|
|
1022
|
+
as_of_time: typing.Optional[str] = None,
|
|
1023
|
+
include_external_ids: typing.Optional[bool] = None,
|
|
1024
|
+
request_options: typing.Optional[RequestOptions] = None,
|
|
1025
|
+
) -> AsyncPager[ReadingSnapshotResponseBody]:
|
|
1026
|
+
"""
|
|
1027
|
+
An endpoint to get the last value of a reading for a set of entities at the specified time.
|
|
1028
|
+
|
|
1029
|
+
<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>).
|
|
1030
|
+
|
|
1031
|
+
To use this endpoint, select **Read Readings** under the Closed Beta 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>
|
|
1032
|
+
|
|
1033
|
+
|
|
1034
|
+
**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.
|
|
1035
|
+
|
|
1036
|
+
Parameters
|
|
1037
|
+
----------
|
|
1038
|
+
reading_ids : str
|
|
1039
|
+
A collection of comma separated reading IDs. Include up to 3 readings IDs. Use /readings/definitions endpoint to get a list of valid reading IDs.
|
|
1040
|
+
|
|
1041
|
+
entity_type : str
|
|
1042
|
+
A entity type of the entityIds or externalIds to fetch readings for. Use /readings/definitions endpoint to get a list of valid entity types.
|
|
1043
|
+
|
|
1044
|
+
after : typing.Optional[str]
|
|
1045
|
+
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.
|
|
1046
|
+
|
|
1047
|
+
entity_ids : typing.Optional[str]
|
|
1048
|
+
A filter on the data based on this comma-separated list of entity IDs or external IDs.
|
|
1049
|
+
|
|
1050
|
+
external_ids : typing.Optional[str]
|
|
1051
|
+
A filter on the data based on this comma-separated list of external IDs.
|
|
1052
|
+
|
|
1053
|
+
as_of_time : typing.Optional[str]
|
|
1054
|
+
A filter on the data that returns the last known data points with timestamps less than or equal to this value. Defaults to now if not provided. Must be a string in RFC 3339 format. Millisecond precision and timezones are supported.
|
|
1055
|
+
|
|
1056
|
+
include_external_ids : typing.Optional[bool]
|
|
1057
|
+
Optional boolean indicating whether to return external IDs on supported entities
|
|
1058
|
+
|
|
1059
|
+
request_options : typing.Optional[RequestOptions]
|
|
1060
|
+
Request-specific configuration.
|
|
1061
|
+
|
|
1062
|
+
Returns
|
|
1063
|
+
-------
|
|
1064
|
+
AsyncPager[ReadingSnapshotResponseBody]
|
|
1065
|
+
OK response.
|
|
1066
|
+
"""
|
|
1067
|
+
_response = await self._client_wrapper.httpx_client.request(
|
|
1068
|
+
"readings/latest",
|
|
1069
|
+
method="GET",
|
|
1070
|
+
params={
|
|
1071
|
+
"after": after,
|
|
1072
|
+
"readingIds": reading_ids,
|
|
1073
|
+
"entityIds": entity_ids,
|
|
1074
|
+
"externalIds": external_ids,
|
|
1075
|
+
"asOfTime": as_of_time,
|
|
1076
|
+
"entityType": entity_type,
|
|
1077
|
+
"includeExternalIds": include_external_ids,
|
|
1078
|
+
},
|
|
1079
|
+
request_options=request_options,
|
|
1080
|
+
)
|
|
1081
|
+
try:
|
|
1082
|
+
if 200 <= _response.status_code < 300:
|
|
1083
|
+
_parsed_response = typing.cast(
|
|
1084
|
+
ReadingsGetReadingsSnapshotResponseBody,
|
|
1085
|
+
parse_obj_as(
|
|
1086
|
+
type_=ReadingsGetReadingsSnapshotResponseBody, # type: ignore
|
|
1087
|
+
object_=_response.json(),
|
|
1088
|
+
),
|
|
1089
|
+
)
|
|
1090
|
+
_items = _parsed_response.data
|
|
1091
|
+
_has_next = False
|
|
1092
|
+
_get_next = None
|
|
1093
|
+
if _parsed_response.pagination is not None:
|
|
1094
|
+
_parsed_next = _parsed_response.pagination.end_cursor
|
|
1095
|
+
_has_next = _parsed_next is not None and _parsed_next != ""
|
|
1096
|
+
|
|
1097
|
+
async def _get_next():
|
|
1098
|
+
return await self.latest(
|
|
1099
|
+
reading_ids=reading_ids,
|
|
1100
|
+
entity_type=entity_type,
|
|
1101
|
+
after=_parsed_next,
|
|
1102
|
+
entity_ids=entity_ids,
|
|
1103
|
+
external_ids=external_ids,
|
|
1104
|
+
as_of_time=as_of_time,
|
|
1105
|
+
include_external_ids=include_external_ids,
|
|
1106
|
+
request_options=request_options,
|
|
1107
|
+
)
|
|
1108
|
+
|
|
1109
|
+
return AsyncPager(
|
|
1110
|
+
has_next=_has_next, items=_items, get_next=_get_next, response=BaseHttpResponse(response=_response)
|
|
1111
|
+
)
|
|
1112
|
+
if _response.status_code == 401:
|
|
1113
|
+
raise UnauthorizedError(
|
|
1114
|
+
headers=dict(_response.headers),
|
|
1115
|
+
body=typing.cast(
|
|
1116
|
+
typing.Optional[typing.Any],
|
|
1117
|
+
parse_obj_as(
|
|
1118
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1119
|
+
object_=_response.json(),
|
|
1120
|
+
),
|
|
1121
|
+
),
|
|
1122
|
+
)
|
|
1123
|
+
if _response.status_code == 404:
|
|
1124
|
+
raise NotFoundError(
|
|
1125
|
+
headers=dict(_response.headers),
|
|
1126
|
+
body=typing.cast(
|
|
1127
|
+
typing.Optional[typing.Any],
|
|
1128
|
+
parse_obj_as(
|
|
1129
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1130
|
+
object_=_response.json(),
|
|
1131
|
+
),
|
|
1132
|
+
),
|
|
1133
|
+
)
|
|
1134
|
+
if _response.status_code == 405:
|
|
1135
|
+
raise MethodNotAllowedError(
|
|
1136
|
+
headers=dict(_response.headers),
|
|
1137
|
+
body=typing.cast(
|
|
1138
|
+
typing.Optional[typing.Any],
|
|
1139
|
+
parse_obj_as(
|
|
1140
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1141
|
+
object_=_response.json(),
|
|
1142
|
+
),
|
|
1143
|
+
),
|
|
1144
|
+
)
|
|
1145
|
+
if _response.status_code == 429:
|
|
1146
|
+
raise TooManyRequestsError(
|
|
1147
|
+
headers=dict(_response.headers),
|
|
1148
|
+
body=typing.cast(
|
|
1149
|
+
typing.Optional[typing.Any],
|
|
1150
|
+
parse_obj_as(
|
|
1151
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1152
|
+
object_=_response.json(),
|
|
1153
|
+
),
|
|
1154
|
+
),
|
|
1155
|
+
)
|
|
1156
|
+
if _response.status_code == 500:
|
|
1157
|
+
raise InternalServerError(
|
|
1158
|
+
headers=dict(_response.headers),
|
|
1159
|
+
body=typing.cast(
|
|
1160
|
+
typing.Optional[typing.Any],
|
|
1161
|
+
parse_obj_as(
|
|
1162
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1163
|
+
object_=_response.json(),
|
|
1164
|
+
),
|
|
1165
|
+
),
|
|
1166
|
+
)
|
|
1167
|
+
if _response.status_code == 501:
|
|
1168
|
+
raise NotImplementedError(
|
|
1169
|
+
headers=dict(_response.headers),
|
|
1170
|
+
body=typing.cast(
|
|
1171
|
+
typing.Optional[typing.Any],
|
|
1172
|
+
parse_obj_as(
|
|
1173
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1174
|
+
object_=_response.json(),
|
|
1175
|
+
),
|
|
1176
|
+
),
|
|
1177
|
+
)
|
|
1178
|
+
if _response.status_code == 502:
|
|
1179
|
+
raise BadGatewayError(
|
|
1180
|
+
headers=dict(_response.headers),
|
|
1181
|
+
body=typing.cast(
|
|
1182
|
+
typing.Optional[typing.Any],
|
|
1183
|
+
parse_obj_as(
|
|
1184
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1185
|
+
object_=_response.json(),
|
|
1186
|
+
),
|
|
1187
|
+
),
|
|
1188
|
+
)
|
|
1189
|
+
if _response.status_code == 503:
|
|
1190
|
+
raise ServiceUnavailableError(
|
|
1191
|
+
headers=dict(_response.headers),
|
|
1192
|
+
body=typing.cast(
|
|
1193
|
+
typing.Optional[typing.Any],
|
|
1194
|
+
parse_obj_as(
|
|
1195
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1196
|
+
object_=_response.json(),
|
|
1197
|
+
),
|
|
1198
|
+
),
|
|
1199
|
+
)
|
|
1200
|
+
if _response.status_code == 504:
|
|
1201
|
+
raise GatewayTimeoutError(
|
|
1202
|
+
headers=dict(_response.headers),
|
|
1203
|
+
body=typing.cast(
|
|
1204
|
+
typing.Optional[typing.Any],
|
|
1205
|
+
parse_obj_as(
|
|
1206
|
+
type_=typing.Optional[typing.Any], # type: ignore
|
|
1207
|
+
object_=_response.json(),
|
|
1208
|
+
),
|
|
1209
|
+
),
|
|
1210
|
+
)
|
|
1211
|
+
_response_json = _response.json()
|
|
1212
|
+
except JSONDecodeError:
|
|
1213
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response.text)
|
|
1214
|
+
raise ApiError(status_code=_response.status_code, headers=dict(_response.headers), body=_response_json)
|