samsara-api 4.0.0__py3-none-any.whl → 4.1.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- samsara/__init__.py +138 -0
- samsara/client.py +19 -0
- samsara/core/client_wrapper.py +2 -2
- samsara/route_events/__init__.py +4 -0
- samsara/route_events/client.py +176 -0
- samsara/route_events/raw_client.py +362 -0
- samsara/types/__init__.py +155 -0
- samsara/types/door_open_response_body.py +28 -0
- samsara/types/route_event_details_response_body.py +36 -0
- samsara/types/route_event_response_response_body.py +56 -0
- samsara/types/route_event_response_response_body_event_type.py +17 -0
- samsara/types/route_event_route_response_response_body.py +35 -0
- samsara/types/route_event_stop_response_response_body.py +35 -0
- samsara/types/routes_get_route_events_stream_bad_gateway_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_gateway_timeout_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_internal_server_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_method_not_allowed_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_not_found_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_not_implemented_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_response_body.py +26 -0
- samsara/types/routes_get_route_events_stream_service_unavailable_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_too_many_requests_error_response_body.py +33 -0
- samsara/types/routes_get_route_events_stream_unauthorized_error_response_body.py +33 -0
- samsara/types/safety_event.py +6 -6
- samsara/types/safety_event_driver.py +5 -0
- samsara/types/safety_event_location.py +5 -0
- samsara/types/safety_event_vehicle.py +5 -0
- samsara/types/stop_eta_updated_event_details_response_body.py +33 -0
- samsara/types/stop_task_completed_event_details_response_body.py +36 -0
- samsara/types/stop_task_completed_event_details_response_body_task_type.py +5 -0
- samsara/types/stop_task_skipped_event_details_response_body.py +36 -0
- samsara/types/stop_task_skipped_event_details_response_body_task_type.py +5 -0
- samsara/types/vehicle.py +28 -16
- samsara/types/vehicle_aux_input_type_1.py +5 -0
- samsara/types/vehicle_aux_input_type_10.py +5 -0
- samsara/types/vehicle_aux_input_type_11.py +5 -0
- samsara/types/vehicle_aux_input_type_12.py +5 -0
- samsara/types/vehicle_aux_input_type_13.py +5 -0
- samsara/types/vehicle_aux_input_type_2.py +5 -0
- samsara/types/vehicle_aux_input_type_3.py +5 -0
- samsara/types/vehicle_aux_input_type_4.py +5 -0
- samsara/types/vehicle_aux_input_type_5.py +5 -0
- samsara/types/vehicle_aux_input_type_6.py +5 -0
- samsara/types/vehicle_aux_input_type_7.py +5 -0
- samsara/types/vehicle_aux_input_type_8.py +5 -0
- samsara/types/vehicle_aux_input_type_9.py +5 -0
- samsara/types/vehicle_location.py +6 -4
- samsara/types/vehicle_location_reverse_geo.py +5 -0
- samsara/types/vehicle_location_time.py +5 -0
- samsara/types/vehicle_static_assigned_driver.py +5 -0
- samsara/types/vehicle_stats_ambient_air_temp_milli_c.py +2 -2
- samsara/types/vehicle_stats_ambient_air_temp_milli_c_with_decoration.py +2 -2
- samsara/types/vehicle_stats_barometric_pressure_pa.py +2 -2
- samsara/types/vehicle_stats_barometric_pressure_pa_with_decoration.py +2 -2
- samsara/types/vehicle_stats_battery_voltage.py +2 -2
- samsara/types/vehicle_stats_battery_voltage_with_decoration.py +2 -2
- samsara/types/vehicle_stats_decorations.py +4 -0
- samsara/types/vehicle_stats_decorations_gps.py +4 -2
- samsara/types/vehicle_stats_def_level_milli_percent.py +2 -2
- samsara/types/vehicle_stats_def_level_milli_percent_with_decoration.py +2 -2
- samsara/types/vehicle_stats_ecu_door_status.py +29 -0
- samsara/types/vehicle_stats_ecu_door_status_value.py +5 -0
- samsara/types/vehicle_stats_ecu_speed_mph.py +2 -2
- samsara/types/vehicle_stats_ecu_speed_mph_with_decoration.py +2 -2
- samsara/types/vehicle_stats_engine_coolant_temp_milli_c.py +2 -2
- samsara/types/vehicle_stats_engine_coolant_temp_milli_c_with_decoration.py +2 -2
- samsara/types/vehicle_stats_engine_load_percent.py +2 -2
- samsara/types/vehicle_stats_engine_load_percent_with_decoration.py +2 -2
- samsara/types/vehicle_stats_engine_oil_pressure_k_pa.py +2 -2
- samsara/types/vehicle_stats_engine_oil_pressure_k_pa_with_decoration.py +2 -2
- samsara/types/vehicle_stats_engine_rpm.py +2 -2
- samsara/types/vehicle_stats_engine_rpm_with_decoration.py +2 -2
- samsara/types/vehicle_stats_engine_state.py +2 -2
- samsara/types/vehicle_stats_engine_state_with_decoration.py +2 -2
- samsara/types/vehicle_stats_ev_average_battery_temperature_milli_celsius.py +2 -2
- samsara/types/vehicle_stats_ev_battery_current_milli_amp.py +2 -2
- samsara/types/vehicle_stats_ev_battery_state_of_health_milli_percent.py +2 -2
- samsara/types/vehicle_stats_ev_battery_voltage_milli_volt.py +2 -2
- samsara/types/vehicle_stats_ev_charging_current_milli_amp.py +2 -2
- samsara/types/vehicle_stats_ev_charging_energy_micro_wh.py +2 -2
- samsara/types/vehicle_stats_ev_charging_status.py +2 -2
- samsara/types/vehicle_stats_ev_charging_voltage_milli_volt.py +2 -2
- samsara/types/vehicle_stats_ev_consumed_energy_micro_wh.py +2 -2
- samsara/types/vehicle_stats_ev_distance_driven_meters.py +2 -2
- samsara/types/vehicle_stats_ev_regenerated_energy_micro_wh.py +2 -2
- samsara/types/vehicle_stats_ev_state_of_charge_milli_percent.py +2 -2
- samsara/types/vehicle_stats_fault_codes_with_decoration.py +2 -2
- samsara/types/vehicle_stats_fuel_consumed_milliliters.py +2 -2
- samsara/types/vehicle_stats_fuel_consumed_milliliters_with_decoration.py +2 -2
- samsara/types/vehicle_stats_fuel_percent.py +2 -2
- samsara/types/vehicle_stats_fuel_percent_with_decoration.py +2 -2
- samsara/types/vehicle_stats_gps.py +6 -4
- samsara/types/vehicle_stats_gps_distance_meters.py +2 -2
- samsara/types/vehicle_stats_gps_distance_meters_with_decoration.py +2 -2
- samsara/types/vehicle_stats_gps_odometer_meters.py +2 -2
- samsara/types/vehicle_stats_gps_odometer_meters_with_decoration.py +2 -2
- samsara/types/vehicle_stats_idling_duration_milliseconds.py +2 -2
- samsara/types/vehicle_stats_idling_duration_milliseconds_with_decoration.py +2 -2
- samsara/types/vehicle_stats_intake_manifold_temp_milli_c.py +2 -2
- samsara/types/vehicle_stats_intake_manifold_temp_milli_c_with_decoration.py +2 -2
- samsara/types/vehicle_stats_list_gps.py +6 -4
- samsara/types/vehicle_stats_list_response_data.py +8 -0
- samsara/types/vehicle_stats_obd_engine_seconds.py +2 -2
- samsara/types/vehicle_stats_obd_engine_seconds_with_decoration.py +2 -2
- samsara/types/vehicle_stats_obd_odometer_meters.py +2 -2
- samsara/types/vehicle_stats_obd_odometer_meters_with_decoration.py +2 -2
- samsara/types/vehicle_stats_response_data.py +4 -0
- samsara/types/vehicle_stats_response_ecu_door_status.py +32 -0
- samsara/types/vehicle_stats_response_ecu_door_status_value.py +5 -0
- samsara/types/vehicle_stats_seatbelt_driver.py +2 -2
- samsara/types/vehicle_stats_spreader_active.py +2 -2
- samsara/types/vehicle_stats_spreader_air_temp.py +2 -2
- samsara/types/vehicle_stats_spreader_blast_state.py +2 -2
- samsara/types/vehicle_stats_spreader_granular_name.py +2 -2
- samsara/types/vehicle_stats_spreader_granular_rate.py +2 -2
- samsara/types/vehicle_stats_spreader_liquid_name.py +2 -2
- samsara/types/vehicle_stats_spreader_liquid_rate.py +2 -2
- samsara/types/vehicle_stats_spreader_on_state.py +2 -2
- samsara/types/vehicle_stats_spreader_plow_status.py +2 -2
- samsara/types/vehicle_stats_spreader_prewet_name.py +2 -2
- samsara/types/vehicle_stats_spreader_prewet_rate.py +2 -2
- samsara/types/vehicle_stats_spreader_road_temp.py +2 -2
- samsara/types/vehicle_stats_time.py +5 -0
- samsara/types/workflow_incident_details_object_response_body.py +4 -0
- samsara/vehicle_stats/client.py +10 -0
- samsara/vehicle_stats/raw_client.py +10 -0
- samsara/vehicle_stats/types/get_vehicle_stats_feed_request_decorations_item.py +1 -0
- samsara/vehicle_stats/types/get_vehicle_stats_feed_request_types_item.py +1 -0
- samsara/vehicle_stats/types/get_vehicle_stats_history_request_decorations_item.py +1 -0
- samsara/vehicle_stats/types/get_vehicle_stats_history_request_types_item.py +1 -0
- samsara/vehicle_stats/types/get_vehicle_stats_request_types_item.py +1 -0
- samsara_api-4.1.0.dist-info/METADATA +670 -0
- {samsara_api-4.0.0.dist-info → samsara_api-4.1.0.dist-info}/RECORD +135 -87
- samsara_api-4.0.0.dist-info/METADATA +0 -238
- {samsara_api-4.0.0.dist-info → samsara_api-4.1.0.dist-info}/LICENSE +0 -0
- {samsara_api-4.0.0.dist-info → samsara_api-4.1.0.dist-info}/WHEEL +0 -0
|
@@ -1,238 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.1
|
|
2
|
-
Name: samsara-api
|
|
3
|
-
Version: 4.0.0
|
|
4
|
-
Summary:
|
|
5
|
-
License: MIT
|
|
6
|
-
Requires-Python: >=3.8,<4.0
|
|
7
|
-
Classifier: Intended Audience :: Developers
|
|
8
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
9
|
-
Classifier: Operating System :: MacOS
|
|
10
|
-
Classifier: Operating System :: Microsoft :: Windows
|
|
11
|
-
Classifier: Operating System :: OS Independent
|
|
12
|
-
Classifier: Operating System :: POSIX
|
|
13
|
-
Classifier: Operating System :: POSIX :: Linux
|
|
14
|
-
Classifier: Programming Language :: Python
|
|
15
|
-
Classifier: Programming Language :: Python :: 3
|
|
16
|
-
Classifier: Programming Language :: Python :: 3.8
|
|
17
|
-
Classifier: Programming Language :: Python :: 3.9
|
|
18
|
-
Classifier: Programming Language :: Python :: 3.10
|
|
19
|
-
Classifier: Programming Language :: Python :: 3.11
|
|
20
|
-
Classifier: Programming Language :: Python :: 3.12
|
|
21
|
-
Classifier: Topic :: Software Development :: Libraries :: Python Modules
|
|
22
|
-
Classifier: Typing :: Typed
|
|
23
|
-
Requires-Dist: httpx (>=0.21.2)
|
|
24
|
-
Requires-Dist: pydantic (>=1.9.2)
|
|
25
|
-
Requires-Dist: pydantic-core (>=2.18.2)
|
|
26
|
-
Requires-Dist: typing_extensions (>=4.0.0)
|
|
27
|
-
Description-Content-Type: text/markdown
|
|
28
|
-
|
|
29
|
-
# Samsara Python Library
|
|
30
|
-
|
|
31
|
-
[](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fsamsarahq%2Fsamsara-python-sdk)
|
|
32
|
-
[](https://pypi.python.org/pypi/samsara-api)
|
|
33
|
-
|
|
34
|
-
The Samsara Python library provides convenient access to the Samsara API from Python.
|
|
35
|
-
|
|
36
|
-
## Documentation
|
|
37
|
-
|
|
38
|
-
API reference documentation is available [here](https://developers.samsara.com/reference/overview).
|
|
39
|
-
|
|
40
|
-
## Installation
|
|
41
|
-
|
|
42
|
-
```sh
|
|
43
|
-
pip install samsara-api
|
|
44
|
-
```
|
|
45
|
-
|
|
46
|
-
## Reference
|
|
47
|
-
|
|
48
|
-
A full reference for this library is available [here](https://github.com/samsarahq/samsara-python-sdk/blob/HEAD/./reference.md).
|
|
49
|
-
|
|
50
|
-
## Usage
|
|
51
|
-
|
|
52
|
-
Instantiate and use the client with the following:
|
|
53
|
-
|
|
54
|
-
```python
|
|
55
|
-
from samsara import Samsara
|
|
56
|
-
|
|
57
|
-
client = Samsara(
|
|
58
|
-
token="YOUR_TOKEN",
|
|
59
|
-
)
|
|
60
|
-
response = client.vehicles.stats.list()
|
|
61
|
-
for item in response:
|
|
62
|
-
yield item
|
|
63
|
-
# alternatively, you can paginate page-by-page
|
|
64
|
-
for page in response.iter_pages():
|
|
65
|
-
yield page
|
|
66
|
-
```
|
|
67
|
-
|
|
68
|
-
## Async Client
|
|
69
|
-
|
|
70
|
-
The SDK also exports an `async` client so that you can make non-blocking calls to our API.
|
|
71
|
-
|
|
72
|
-
```python
|
|
73
|
-
import asyncio
|
|
74
|
-
|
|
75
|
-
from samsara import AsyncSamsara
|
|
76
|
-
|
|
77
|
-
client = AsyncSamsara(
|
|
78
|
-
token="YOUR_TOKEN",
|
|
79
|
-
)
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
async def main() -> None:
|
|
83
|
-
response = await client.vehicles.stats.list()
|
|
84
|
-
async for item in response:
|
|
85
|
-
yield item
|
|
86
|
-
|
|
87
|
-
# alternatively, you can paginate page-by-page
|
|
88
|
-
async for page in response.iter_pages():
|
|
89
|
-
yield page
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
asyncio.run(main())
|
|
93
|
-
```
|
|
94
|
-
|
|
95
|
-
## Exception Handling
|
|
96
|
-
|
|
97
|
-
When the API returns a non-success status code (4xx or 5xx response), a subclass of the following error
|
|
98
|
-
will be thrown.
|
|
99
|
-
|
|
100
|
-
```python
|
|
101
|
-
from samsara.core.api_error import ApiError
|
|
102
|
-
|
|
103
|
-
try:
|
|
104
|
-
client.vehicles.stats.list(...)
|
|
105
|
-
except ApiError as e:
|
|
106
|
-
print(e.status_code)
|
|
107
|
-
print(e.body)
|
|
108
|
-
```
|
|
109
|
-
|
|
110
|
-
## Pagination
|
|
111
|
-
|
|
112
|
-
Paginated requests will return a `SyncPager` or `AsyncPager`, which can be used as generators for the underlying object.
|
|
113
|
-
|
|
114
|
-
```python
|
|
115
|
-
from samsara import Samsara
|
|
116
|
-
|
|
117
|
-
client = Samsara(
|
|
118
|
-
token="YOUR_TOKEN",
|
|
119
|
-
)
|
|
120
|
-
response = client.addresses.list()
|
|
121
|
-
for item in response:
|
|
122
|
-
yield item
|
|
123
|
-
# alternatively, you can paginate page-by-page
|
|
124
|
-
for page in response.iter_pages():
|
|
125
|
-
yield page
|
|
126
|
-
```
|
|
127
|
-
|
|
128
|
-
## Webhook Signature Verification
|
|
129
|
-
|
|
130
|
-
The SDK provides utility methods that allow you to verify webhook signatures and ensure
|
|
131
|
-
that all webhook events originate from Samsara. The `verify_signature` method will verify
|
|
132
|
-
the signature.
|
|
133
|
-
|
|
134
|
-
```python
|
|
135
|
-
from samsara.utils.webhooks_helper import verify_signature
|
|
136
|
-
|
|
137
|
-
is_valid = verify_signature(
|
|
138
|
-
request_body=request_body,
|
|
139
|
-
signature_header=request.headers['x-samsara-hmacsha256-signature'],
|
|
140
|
-
signature_key="YOUR_SIGNATURE_KEY",
|
|
141
|
-
notification_url="https://example.com/webhook", # The URL where event notifications are sent.
|
|
142
|
-
)
|
|
143
|
-
```
|
|
144
|
-
|
|
145
|
-
## Advanced
|
|
146
|
-
|
|
147
|
-
### Access Raw Response Data
|
|
148
|
-
|
|
149
|
-
The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
|
|
150
|
-
The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
|
|
151
|
-
|
|
152
|
-
```python
|
|
153
|
-
from samsara import Samsara
|
|
154
|
-
|
|
155
|
-
client = Samsara(
|
|
156
|
-
...,
|
|
157
|
-
)
|
|
158
|
-
response = client.vehicles.stats.with_raw_response.list(...)
|
|
159
|
-
print(response.headers) # access the response headers
|
|
160
|
-
print(response.data) # access the underlying object
|
|
161
|
-
pager = client.addresses.list(...)
|
|
162
|
-
print(pager.response.headers) # access the response headers for the first page
|
|
163
|
-
for item in pager:
|
|
164
|
-
print(item) # access the underlying object(s)
|
|
165
|
-
for page in pager.iter_pages():
|
|
166
|
-
print(page.response.headers) # access the response headers for each page
|
|
167
|
-
for item in page:
|
|
168
|
-
print(item) # access the underlying object(s)
|
|
169
|
-
```
|
|
170
|
-
|
|
171
|
-
### Retries
|
|
172
|
-
|
|
173
|
-
The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
|
|
174
|
-
as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
|
|
175
|
-
retry limit (default: 2).
|
|
176
|
-
|
|
177
|
-
A request is deemed retryable when any of the following HTTP status codes is returned:
|
|
178
|
-
|
|
179
|
-
- [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
|
|
180
|
-
- [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
|
|
181
|
-
- [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
|
|
182
|
-
|
|
183
|
-
Use the `max_retries` request option to configure this behavior.
|
|
184
|
-
|
|
185
|
-
```python
|
|
186
|
-
client.vehicles.stats.list(..., request_options={
|
|
187
|
-
"max_retries": 1
|
|
188
|
-
})
|
|
189
|
-
```
|
|
190
|
-
|
|
191
|
-
### Timeouts
|
|
192
|
-
|
|
193
|
-
The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
|
|
194
|
-
|
|
195
|
-
```python
|
|
196
|
-
|
|
197
|
-
from samsara import Samsara
|
|
198
|
-
|
|
199
|
-
client = Samsara(
|
|
200
|
-
...,
|
|
201
|
-
timeout=20.0,
|
|
202
|
-
)
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
# Override timeout for a specific method
|
|
206
|
-
client.vehicles.stats.list(..., request_options={
|
|
207
|
-
"timeout_in_seconds": 1
|
|
208
|
-
})
|
|
209
|
-
```
|
|
210
|
-
|
|
211
|
-
### Custom Client
|
|
212
|
-
|
|
213
|
-
You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
|
|
214
|
-
and transports.
|
|
215
|
-
|
|
216
|
-
```python
|
|
217
|
-
import httpx
|
|
218
|
-
from samsara import Samsara
|
|
219
|
-
|
|
220
|
-
client = Samsara(
|
|
221
|
-
...,
|
|
222
|
-
httpx_client=httpx.Client(
|
|
223
|
-
proxies="http://my.test.proxy.example.com",
|
|
224
|
-
transport=httpx.HTTPTransport(local_address="0.0.0.0"),
|
|
225
|
-
),
|
|
226
|
-
)
|
|
227
|
-
```
|
|
228
|
-
|
|
229
|
-
## Contributing
|
|
230
|
-
|
|
231
|
-
While we value open-source contributions to this SDK, this library is generated programmatically.
|
|
232
|
-
Additions made directly to this library would have to be moved over to our generation code,
|
|
233
|
-
otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
|
|
234
|
-
a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
|
|
235
|
-
an issue first to discuss with us!
|
|
236
|
-
|
|
237
|
-
On the other hand, contributions to the README are always very welcome!
|
|
238
|
-
|
|
File without changes
|
|
File without changes
|