samsara-api 0.0.2__py3-none-any.whl → 0.0.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -20,10 +20,10 @@ class BaseClientWrapper:
20
20
 
21
21
  def get_headers(self) -> typing.Dict[str, str]:
22
22
  headers: typing.Dict[str, str] = {
23
- "User-Agent": "samsara-api/0.0.2",
23
+ "User-Agent": "samsara-api/0.0.3",
24
24
  "X-Fern-Language": "Python",
25
25
  "X-Fern-SDK-Name": "samsara-api",
26
- "X-Fern-SDK-Version": "0.0.2",
26
+ "X-Fern-SDK-Version": "0.0.3",
27
27
  }
28
28
  headers["Authorization"] = f"Bearer {self._get_token()}"
29
29
  return headers
@@ -19,7 +19,7 @@ class WorkOrderItemObjectRequestBody(UniversalBaseModel):
19
19
 
20
20
  type: WorkOrderItemObjectRequestBodyType = pydantic.Field()
21
21
  """
22
- The type of item. Valid values: `DVIR`, `FAULT`, `FORM`, `ISSUE`, `ITEM_TYPE_UNSPECIFIED`, `SCHEDULED_MAINTENANCE`
22
+ The type of item. Valid values: `DVIR`, `FAULT`, `FORM`, `ISSUE`, `ITEM_TYPE_UNSPECIFIED`, `MAINTENANCE_PREDICTION_EVENT`, `SCHEDULED_MAINTENANCE`
23
23
  """
24
24
 
25
25
  if IS_PYDANTIC_V2:
@@ -3,5 +3,14 @@
3
3
  import typing
4
4
 
5
5
  WorkOrderItemObjectRequestBodyType = typing.Union[
6
- typing.Literal["DVIR", "FAULT", "FORM", "ISSUE", "ITEM_TYPE_UNSPECIFIED", "SCHEDULED_MAINTENANCE"], typing.Any
6
+ typing.Literal[
7
+ "DVIR",
8
+ "FAULT",
9
+ "FORM",
10
+ "ISSUE",
11
+ "ITEM_TYPE_UNSPECIFIED",
12
+ "MAINTENANCE_PREDICTION_EVENT",
13
+ "SCHEDULED_MAINTENANCE",
14
+ ],
15
+ typing.Any,
7
16
  ]
@@ -19,7 +19,7 @@ class WorkOrderItemObjectResponseBody(UniversalBaseModel):
19
19
 
20
20
  type: WorkOrderItemObjectResponseBodyType = pydantic.Field()
21
21
  """
22
- The type of item. Valid values: `DVIR`, `FAULT`, `FORM`, `ISSUE`, `ITEM_TYPE_UNSPECIFIED`, `SCHEDULED_MAINTENANCE`
22
+ The type of item. Valid values: `DVIR`, `FAULT`, `FORM`, `ISSUE`, `ITEM_TYPE_UNSPECIFIED`, `MAINTENANCE_PREDICTION_EVENT`, `SCHEDULED_MAINTENANCE`
23
23
  """
24
24
 
25
25
  if IS_PYDANTIC_V2:
@@ -3,5 +3,14 @@
3
3
  import typing
4
4
 
5
5
  WorkOrderItemObjectResponseBodyType = typing.Union[
6
- typing.Literal["DVIR", "FAULT", "FORM", "ISSUE", "ITEM_TYPE_UNSPECIFIED", "SCHEDULED_MAINTENANCE"], typing.Any
6
+ typing.Literal[
7
+ "DVIR",
8
+ "FAULT",
9
+ "FORM",
10
+ "ISSUE",
11
+ "ITEM_TYPE_UNSPECIFIED",
12
+ "MAINTENANCE_PREDICTION_EVENT",
13
+ "SCHEDULED_MAINTENANCE",
14
+ ],
15
+ typing.Any,
7
16
  ]
@@ -0,0 +1,221 @@
1
+ Metadata-Version: 2.1
2
+ Name: samsara-api
3
+ Version: 0.0.3
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,<3.0.0)
26
+ Requires-Dist: typing_extensions (>=4.0.0)
27
+ Description-Content-Type: text/markdown
28
+
29
+ # Samsara Python Library
30
+
31
+ [![fern shield](https://img.shields.io/badge/%F0%9F%8C%BF-Built%20with%20Fern-brightgreen)](https://buildwithfern.com?utm_source=github&utm_medium=github&utm_campaign=readme&utm_source=https%3A%2F%2Fgithub.com%2Fsamsarahq%2Fsamsara-python-sdk)
32
+ [![pypi](https://img.shields.io/pypi/v/samsara-api)](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
+ ## Advanced
129
+
130
+ ### Access Raw Response Data
131
+
132
+ The SDK provides access to raw response data, including headers, through the `.with_raw_response` property.
133
+ The `.with_raw_response` property returns a "raw" client that can be used to access the `.headers` and `.data` attributes.
134
+
135
+ ```python
136
+ from samsara import Samsara
137
+
138
+ client = Samsara(
139
+ ...,
140
+ )
141
+ response = client.vehicles.stats.with_raw_response.list(...)
142
+ print(response.headers) # access the response headers
143
+ print(response.data) # access the underlying object
144
+ pager = client.addresses.list(...)
145
+ print(pager.response.headers) # access the response headers for the first page
146
+ for item in pager:
147
+ print(item) # access the underlying object(s)
148
+ for page in pager.iter_pages():
149
+ print(page.response.headers) # access the response headers for each page
150
+ for item in page:
151
+ print(item) # access the underlying object(s)
152
+ ```
153
+
154
+ ### Retries
155
+
156
+ The SDK is instrumented with automatic retries with exponential backoff. A request will be retried as long
157
+ as the request is deemed retryable and the number of retry attempts has not grown larger than the configured
158
+ retry limit (default: 2).
159
+
160
+ A request is deemed retryable when any of the following HTTP status codes is returned:
161
+
162
+ - [408](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/408) (Timeout)
163
+ - [429](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/429) (Too Many Requests)
164
+ - [5XX](https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/500) (Internal Server Errors)
165
+
166
+ Use the `max_retries` request option to configure this behavior.
167
+
168
+ ```python
169
+ client.vehicles.stats.list(..., request_options={
170
+ "max_retries": 1
171
+ })
172
+ ```
173
+
174
+ ### Timeouts
175
+
176
+ The SDK defaults to a 60 second timeout. You can configure this with a timeout option at the client or request level.
177
+
178
+ ```python
179
+
180
+ from samsara import Samsara
181
+
182
+ client = Samsara(
183
+ ...,
184
+ timeout=20.0,
185
+ )
186
+
187
+
188
+ # Override timeout for a specific method
189
+ client.vehicles.stats.list(..., request_options={
190
+ "timeout_in_seconds": 1
191
+ })
192
+ ```
193
+
194
+ ### Custom Client
195
+
196
+ You can override the `httpx` client to customize it for your use-case. Some common use-cases include support for proxies
197
+ and transports.
198
+
199
+ ```python
200
+ import httpx
201
+ from samsara import Samsara
202
+
203
+ client = Samsara(
204
+ ...,
205
+ httpx_client=httpx.Client(
206
+ proxies="http://my.test.proxy.example.com",
207
+ transport=httpx.HTTPTransport(local_address="0.0.0.0"),
208
+ ),
209
+ )
210
+ ```
211
+
212
+ ## Contributing
213
+
214
+ While we value open-source contributions to this SDK, this library is generated programmatically.
215
+ Additions made directly to this library would have to be moved over to our generation code,
216
+ otherwise they would be overwritten upon the next generated release. Feel free to open a PR as
217
+ a proof of concept, but know that we will not be able to merge it as-is. We suggest opening
218
+ an issue first to discuss with us!
219
+
220
+ On the other hand, contributions to the README are always very welcome!
221
+
@@ -80,7 +80,7 @@ samsara/contacts/client.py,sha256=-DvPNxYQZboAYekVkG22JH8GLN5Pb441W0pD7amZue8,19
80
80
  samsara/contacts/raw_client.py,sha256=nMFcdeS_I53QS01zxF2yeY6-t6cbQ7ZeZeqUxKcH7yI,27530
81
81
  samsara/core/__init__.py,sha256=4POYbbRlgR7TwGFY5nmHpaa7nFgXOX_pYHcN1Ezh2p8,1643
82
82
  samsara/core/api_error.py,sha256=44vPoTyWN59gonCIZMdzw7M1uspygiLnr3GNFOoVL2Q,614
83
- samsara/core/client_wrapper.py,sha256=tylN7Z47lS0PcCy8T0aZZcteEYdsU7dLfM9oTf7mQ9k,2236
83
+ samsara/core/client_wrapper.py,sha256=3F4i9kyUag6uWDXyh6x6xWxjNJw-KY8ezQYsS8jLlaU,2236
84
84
  samsara/core/datetime_utils.py,sha256=nBys2IsYrhPdszxGKCNRPSOCwa-5DWOHG95FB8G9PKo,1047
85
85
  samsara/core/file.py,sha256=d4NNbX8XvXP32z8KpK2Xovv33nFfruIrpz0QWxlgpZk,2663
86
86
  samsara/core/force_multipart.py,sha256=awxh5MtcRYe74ehY8U76jzv6fYM_w_D3Rur7KQQzSDk,429
@@ -2514,10 +2514,10 @@ samsara/types/work_order_attachment_object_response_body.py,sha256=Ce66d8VXVdpVL
2514
2514
  samsara/types/work_order_attachment_object_response_body_processing_status.py,sha256=w82JZVehbfKHNKnX6yGJ4ZioPLQeU-Yl5g5-LDdVe80,220
2515
2515
  samsara/types/work_order_discount_object_request_body.py,sha256=ypiPPoF0rkmdpYsBjq0rF-Q9e7w4uYEGnyXK9fspt5s,1074
2516
2516
  samsara/types/work_order_discount_object_response_body.py,sha256=Z2Xy7CmOcUAduOpIKSVR2l_WqqJIys1zxH_-e8M2-NA,1078
2517
- samsara/types/work_order_item_object_request_body.py,sha256=Y3cTjYnwDnb8URFotb3uKlsIchOOZJ96uTbvcNgtQ-A,933
2518
- samsara/types/work_order_item_object_request_body_type.py,sha256=VscZ6y43wrrUM6babjcrpryDyhTW7Fm0jN770scYuFw,248
2519
- samsara/types/work_order_item_object_response_body.py,sha256=bGvcAkoyQJhCgBLWhx4WAL77CcxT6MPTbrY1fDmq30s,937
2520
- samsara/types/work_order_item_object_response_body_type.py,sha256=hiB3lQvaJJrAiRCy73GRJN_hCFBg8u4j4nKQ45KqR5M,249
2517
+ samsara/types/work_order_item_object_request_body.py,sha256=IR7-f72UooE1Sz5NZtihDMmdZFwsrlj0nhKonrWfx_o,965
2518
+ samsara/types/work_order_item_object_request_body_type.py,sha256=vguZe7JH6HLX_7I0qaCErNPllbGiPw1COKxVnoBtYEg,348
2519
+ samsara/types/work_order_item_object_response_body.py,sha256=1amSCQKCs6IrqLv9UsSJmaQT4LprDgNVGA688RyqVxg,969
2520
+ samsara/types/work_order_item_object_response_body_type.py,sha256=aHS_rnbm5qvc3IghV3sGvE6qOV6057U6X8OLJ3YjOhM,349
2521
2521
  samsara/types/work_order_money_object_request_body.py,sha256=Urpvg5aIH9fx6VStIclHqVhUVp8brDi8_YgD2fb1JUE,816
2522
2522
  samsara/types/work_order_money_object_response_body.py,sha256=7u8dbgEpMRr7s4Yxe2RCEx7l676q7DR-rOkMoNsjkC4,817
2523
2523
  samsara/types/work_order_object_response_body.py,sha256=NXgUY522IAzRXhINXnDSc7L8PYh0Q1qRBAWyntbEEvI,5341
@@ -2654,7 +2654,7 @@ samsara/webhooks/types/__init__.py,sha256=gZew8TwQaEiQWvSAewo9htvyM3UqVSZc1UJ2Aa
2654
2654
  samsara/webhooks/types/webhooks_patch_webhook_request_body_version.py,sha256=WaQrAnZGbaz7eQ6fpnX77L5nb8dLwuUkEQdvx5mCGAw,224
2655
2655
  samsara/webhooks/types/webhooks_post_webhooks_request_body_event_types_item.py,sha256=-whKIc9UjBEIXZUxwkDULLSxR0Dg_-6KxRUjcfyvTuQ,927
2656
2656
  samsara/webhooks/types/webhooks_post_webhooks_request_body_version.py,sha256=1HR1l6_Qc_jS_mf_UkguxgMiiIeAiwaX7jjOTQfG1bw,224
2657
- samsara_api-0.0.2.dist-info/LICENSE,sha256=uX-nl5hOEHp4uvQPCcpde-doNbQhV5uRQNwkB474IoQ,1064
2658
- samsara_api-0.0.2.dist-info/METADATA,sha256=mvat8gIq2ExK6kWTz_VALsf6nmMxPreEb0ovLOIGmdM,1067
2659
- samsara_api-0.0.2.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
2660
- samsara_api-0.0.2.dist-info/RECORD,,
2657
+ samsara_api-0.0.3.dist-info/LICENSE,sha256=uX-nl5hOEHp4uvQPCcpde-doNbQhV5uRQNwkB474IoQ,1064
2658
+ samsara_api-0.0.3.dist-info/METADATA,sha256=Q5d72JwKP-TFYAtidklu9hp0ut6jYbJDCQHbm_oH260,6255
2659
+ samsara_api-0.0.3.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
2660
+ samsara_api-0.0.3.dist-info/RECORD,,
@@ -1,29 +0,0 @@
1
- Metadata-Version: 2.1
2
- Name: samsara-api
3
- Version: 0.0.2
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,<3.0.0)
26
- Requires-Dist: typing_extensions (>=4.0.0)
27
- Description-Content-Type: text/markdown
28
-
29
-