volumes 0.1.0__tar.gz

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.
@@ -0,0 +1,27 @@
1
+ # Python
2
+ __pycache__/
3
+ *.py[cod]
4
+ *.egg-info/
5
+ build/
6
+ dist/
7
+
8
+ # Virtual environments
9
+ .venv/
10
+ .venv-*/
11
+ venv/
12
+
13
+ # Tooling caches
14
+ .pytest_cache/
15
+ .ruff_cache/
16
+ .mypy_cache/
17
+ .coverage
18
+ htmlcov/
19
+
20
+ # Local configuration: never commit credentials
21
+ .env
22
+ .env.*
23
+
24
+ # Editors / OS
25
+ .DS_Store
26
+ .idea/
27
+ .vscode/
volumes-0.1.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Volumes, Inc
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
volumes-0.1.0/PKG-INFO ADDED
@@ -0,0 +1,529 @@
1
+ Metadata-Version: 2.4
2
+ Name: volumes
3
+ Version: 0.1.0
4
+ Summary: Python client for the Volumes API: per-capture frame sync and scene summary metadata.
5
+ License-Expression: MIT
6
+ License-File: LICENSE
7
+ Classifier: Development Status :: 3 - Alpha
8
+ Classifier: Intended Audience :: Developers
9
+ Classifier: Operating System :: OS Independent
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Programming Language :: Python :: 3 :: Only
12
+ Classifier: Typing :: Typed
13
+ Requires-Python: >=3.9
14
+ Requires-Dist: httpx<1,>=0.23.0
15
+ Provides-Extra: dev
16
+ Requires-Dist: mypy>=1.8; extra == 'dev'
17
+ Requires-Dist: pytest>=7; extra == 'dev'
18
+ Requires-Dist: ruff>=0.17; extra == 'dev'
19
+ Description-Content-Type: text/markdown
20
+
21
+ # volumes
22
+
23
+ Python client for the Volumes API. It fetches the per-capture metadata your
24
+ API key has been granted access to:
25
+
26
+ - the **frame sync** table of a capture (CSV)
27
+ - the **scene summary** of a capture (JSON)
28
+
29
+ ```python
30
+ import volumes
31
+
32
+ client = volumes.Client() # reads VOLUMES_API_KEY and VOLUMES_BASE_URL
33
+
34
+ for capture in client.list_captures():
35
+ frame_sync = client.get_frame_sync(capture.capture_id)
36
+ summary = client.get_scene_summary(capture.capture_id)
37
+ print(capture.capture_id, len(frame_sync.rows), summary.get("schema_version"))
38
+ ```
39
+
40
+ - Python 3.9+
41
+ - One dependency: [`httpx`](https://www.python-httpx.org/)
42
+ - Fully typed (ships `py.typed`)
43
+ - Synchronous
44
+
45
+ ## Install
46
+
47
+ ```bash
48
+ pip install volumes
49
+ ```
50
+
51
+ ## Quickstart
52
+
53
+ 1. You need two things from your Volumes contact: an **API key** and the
54
+ **API endpoint** (a URL). The SDK has no built-in endpoint.
55
+ 2. Make both available to your code, preferably through the environment:
56
+
57
+ ```bash
58
+ export VOLUMES_API_KEY="<your API key>"
59
+ export VOLUMES_BASE_URL="<the API endpoint you were given>"
60
+ ```
61
+
62
+ 3. Use the client:
63
+
64
+ ```python
65
+ import volumes
66
+
67
+ with volumes.Client() as client:
68
+ captures = client.list_captures()
69
+ print(f"{len(captures)} captures available")
70
+
71
+ if captures:
72
+ capture_id = captures[0].capture_id
73
+ print(client.get_frame_sync(capture_id).rows[:3])
74
+ print(client.get_scene_summary(capture_id))
75
+ ```
76
+
77
+ Treat the API key like a password: keep it out of source control and logs.
78
+ The client sends it only in the `Authorization` header. It never appears in
79
+ `repr()` output, in what an exception says about itself (its message and
80
+ attributes, and those of the exceptions chained to it), or in the local
81
+ variables of the SDK's own stack frames (which is what error reporters and
82
+ `pytest --showlocals` print). That also holds when a misbehaving server or
83
+ proxy sends the key back in a response, in whatever letter case.
84
+
85
+ One thing is worth knowing about chained errors. When a request fails without
86
+ a response, the `httpx` error is chained to the SDK's (`error.__cause__`), and
87
+ an `httpx` error keeps the request that failed. The SDK removes the
88
+ `Authorization` header from that request before chaining the error, so
89
+ `error.__cause__.request.headers` does not hold the key. Each attempt is sent
90
+ with a request of its own, so retries are unaffected; if you pass your own
91
+ `http_client` and keep the request objects it sends, expect the ones that
92
+ failed to have lost that header. What the HTTP libraries' own stack frames
93
+ held at the moment of the failure is outside the SDK's reach.
94
+
95
+ ## Usage
96
+
97
+ ### `volumes.Client(...)`
98
+
99
+ ```python
100
+ client = volumes.Client(
101
+ api_key=None, # default: the VOLUMES_API_KEY environment variable
102
+ base_url=None, # default: the VOLUMES_BASE_URL environment variable
103
+ timeout=30.0, # seconds per request (or an httpx.Timeout); None for no timeout
104
+ max_retries=2, # retries after the first attempt, 0 to 10; 0 disables retrying
105
+ http_client=None, # an httpx.Client of your own (proxies, custom transports, tests)
106
+ )
107
+ ```
108
+
109
+ Every argument is keyword-only: write `volumes.Client(api_key=...)`, not
110
+ `volumes.Client("...")`.
111
+
112
+ Both the API key and the base URL are required. If either is missing from the
113
+ arguments and from the environment, `volumes.ConfigurationError` is raised
114
+ immediately, before any request.
115
+
116
+ The base URL must be an `https://` URL, because the API key travels in a
117
+ request header. Plain `http://` is accepted only for a loopback address, which
118
+ is what a server on your own machine has during development:
119
+
120
+ - `localhost`, in any letter case;
121
+ - an IPv4 address in `127.0.0.0/8`, written as four decimal numbers
122
+ (`127.0.0.1`);
123
+ - the IPv6 loopback address in brackets, `[::1]`. Other ways of writing that
124
+ same address, such as `[0:0:0:0:0:0:0:1]`, are accepted too.
125
+
126
+ For any other host it is a `ConfigurationError`, and so are other ways of
127
+ writing an address that may reach your own machine (`127.1`,
128
+ `[::ffff:127.0.0.1]`, a trailing dot).
129
+
130
+ The URL may include a port from 1 to 65535, written in plain decimal without
131
+ leading zeros (a colon after the host has to be followed by one), and a path
132
+ prefix (`https://gateway.example.test:8443/volumes`). It may not contain
133
+ credentials, spaces, control characters or backslashes, and no `?` or `#`, not
134
+ even one with nothing after it. A `%` has to begin a percent-escape such as
135
+ `%20`; write a literal percent sign as `%25`. The URL may be at most 2048
136
+ characters long. Whitespace before or after the whole value is ignored.
137
+
138
+ The host and the port have to be written in ASCII, and the host has to be an
139
+ IP address or a host name within the limits of the DNS: labels of 1 to 63
140
+ characters separated by single dots, at most 253 characters in all (one
141
+ trailing dot is allowed). An IPv4 address is four decimal numbers without
142
+ leading zeros. An internationalised host name is written in its punycode form
143
+ (`https://xn--caf-dma.example.test`, not the name with the accented letter),
144
+ and every label that starts with `xn--` has to be valid punycode. The reason
145
+ is that URL parsers do not agree on what to do with other characters in a
146
+ host, a full-width digit or an ideographic full stop for instance, and the
147
+ same text must not name one host under one version of the HTTP library and
148
+ another host under the next. A path prefix may contain other characters.
149
+
150
+ An unusable base URL is always a `ConfigurationError`, raised when the client
151
+ is created, and the decision does not depend on the installed `httpx` version.
152
+
153
+ `timeout` is a finite number of seconds, greater than zero and at most 86400
154
+ (one day), or an `httpx.Timeout` made of such numbers. To run without a
155
+ timeout pass `timeout=None`; `float("inf")`, NaN and larger numbers are
156
+ rejected with `ConfigurationError` when the client is created.
157
+
158
+ A client holds a connection pool. Reuse one client for many calls, and close
159
+ it when you are done, either with `client.close()` or by using it as a context
160
+ manager (`with volumes.Client() as client:`). A closed client raises
161
+ `volumes.ClientClosedError` if it is used again, including when it (or the
162
+ `http_client` you gave it) is closed while a call is waiting between retries.
163
+ If you pass your own `http_client`, it stays yours: the SDK does not close it.
164
+
165
+ ### `client.list_captures()`
166
+
167
+ Returns every capture your key can read, as a `list[volumes.Capture]`. Pages
168
+ are followed automatically until the list is complete.
169
+
170
+ ```python
171
+ captures = client.list_captures()
172
+ for capture in captures:
173
+ print(capture.capture_id) # e.g. "capture_demo_001"
174
+ ```
175
+
176
+ ### `client.iter_captures()`
177
+
178
+ The lazy variant: an iterator that requests one page at a time, only as you
179
+ consume it. Use it when you have many captures or may stop early.
180
+
181
+ ```python
182
+ for capture in client.iter_captures():
183
+ if capture.capture_id == "capture_demo_042":
184
+ break # later pages are never requested
185
+ ```
186
+
187
+ Both methods accept an optional `page_size=`: captures per request, an integer
188
+ from 1 to 1000 (the API's own range; its default is 100). It affects how many
189
+ requests are made, not what is returned.
190
+
191
+ ### `client.get_frame_sync(capture_id)`
192
+
193
+ Returns a `volumes.FrameSync`:
194
+
195
+ - `.content`: the file exactly as received, as `bytes`
196
+ - `.text`: the same, decoded as UTF-8, as a string
197
+ - `.rows`: the same data as a `list[dict[str, str]]`, parsed with
198
+ `csv.DictReader` (one dict per data row, keyed by the header row)
199
+
200
+ ```python
201
+ frame_sync = client.get_frame_sync("capture_demo_001")
202
+
203
+ print(frame_sync.content)
204
+ # b'camera_id,frame\ncam_a,0\ncam_b,2\n'
205
+
206
+ print(frame_sync.text)
207
+ # camera_id,frame
208
+ # cam_a,0
209
+ # cam_b,2
210
+
211
+ print(frame_sync.rows)
212
+ # [{'camera_id': 'cam_a', 'frame': '0'}, {'camera_id': 'cam_b', 'frame': '2'}]
213
+
214
+ columns = list(frame_sync.rows[0]) if frame_sync.rows else []
215
+ # ['camera_id', 'frame']
216
+ ```
217
+
218
+ The header is `camera_id,frame` today. The SDK neither defines nor validates
219
+ the columns: they can change over time, so read the column names from the
220
+ data. To load the table elsewhere, pass the bytes or the text along, for
221
+ example `pandas.read_csv(io.BytesIO(frame_sync.content))`; to keep the file,
222
+ write `.content` to disk unchanged.
223
+
224
+ Every key and every value in `.rows` is a string, including for rows that do
225
+ not match the header:
226
+
227
+ - a row with **fewer** cells than the header gets `""` for the missing ones;
228
+ - cells **beyond** the header are left out of `.rows` (they are still in `.text`);
229
+ - if two columns have the same name, the later one wins.
230
+
231
+ Nothing is decoded or parsed until you ask: `.text` is decoded the first time
232
+ it is read, `.rows` is parsed the first time it is read, and `.content` is
233
+ always available. If the bytes are not valid UTF-8, reading `.text` or `.rows`
234
+ raises `volumes.InvalidResponseError`; if the text is not parseable as CSV at
235
+ all, reading `.rows` does.
236
+
237
+ ### `client.get_scene_summary(capture_id)`
238
+
239
+ Returns the scene summary as a `volumes.SceneSummary`, which is a `dict`: the
240
+ parsed JSON object, unchanged. Use it like any other dictionary. In addition
241
+ it has `.content`, the JSON exactly as received, as `bytes`.
242
+
243
+ ```python
244
+ summary = client.get_scene_summary("capture_demo_001")
245
+ print(summary.get("schema_version"))
246
+ print(isinstance(summary, dict)) # True
247
+ print(summary.content) # b'{"schema_version": 3, ...}'
248
+ ```
249
+
250
+ The SDK does not define or validate the fields. The summary carries its own
251
+ `schema_version`; check it if your code depends on a particular layout. To
252
+ keep the file, write `.content` to disk unchanged; it stays as received even
253
+ if you modify the dictionary.
254
+
255
+ ## Errors
256
+
257
+ Every exception the SDK raises derives from `volumes.VolumesError`, so
258
+ `except volumes.VolumesError` catches anything that can go wrong in a call:
259
+ bad arguments, network failures, error responses, and responses that cannot be
260
+ understood.
261
+
262
+ That holds without exception for a client that uses the SDK's own HTTP client
263
+ (the default). If you pass your own `http_client`, there is one more source of
264
+ exceptions, which the SDK does not rename: anything raised by code *you* put
265
+ into that client (a custom transport, an event hook, an auth flow) that is not
266
+ one of `httpx`'s own request errors reaches you unchanged, for example a
267
+ `RuntimeError` raised by your transport. See
268
+ [Custom transport](#custom-transport).
269
+
270
+ ```
271
+ VolumesError
272
+ ├── ConfigurationError the client was created with unusable settings
273
+ ├── InvalidArgumentError a method was called with an unusable argument
274
+ ├── ClientClosedError the client was used after close()
275
+ ├── APIConnectionError no response: DNS, refused connection, reset, ...
276
+ │ └── APITimeoutError no response in time
277
+ ├── InvalidResponseError a success response that could not be understood
278
+ └── APIError the API answered with an error status
279
+ ├── BadRequestError 400
280
+ ├── AuthenticationError 401
281
+ ├── NotFoundError 404
282
+ │ ├── CaptureNotFoundError no such capture for this key
283
+ │ └── MetadataNotAvailableError capture is accessible; file not there yet
284
+ ├── RateLimitError 429 (.retry_after)
285
+ └── ServerError 5xx
286
+ ```
287
+
288
+ **Invalid arguments.** The SDK never raises a bare `ValueError` or `TypeError`
289
+ for something you passed in. A bad argument to `volumes.Client(...)` raises
290
+ `ConfigurationError`; a bad argument to a method raises `InvalidArgumentError`,
291
+ for a wrong type and a wrong value alike. Both are `VolumesError`s that *also*
292
+ subclass `ValueError`, so existing `except ValueError` handlers keep working.
293
+ Both are raised before any request is sent.
294
+
295
+ | Argument | Must be |
296
+ |---|---|
297
+ | `capture_id` | a non-empty string of at most 1024 characters |
298
+ | `page_size` | an integer from 1 to 1000 (or omitted) |
299
+
300
+ A wrong setting passed to `volumes.Client(...)` is reported the same way, as a
301
+ `ConfigurationError`: `max_retries` outside 0 to 10, an unusable `timeout`, a
302
+ `base_url` that is not `https://` (or loopback `http://`), that contains `?`
303
+ or `#`, or that is otherwise not a usable URL.
304
+
305
+ Whatever characters a `capture_id` contains, it is percent-encoded into a
306
+ single URL path segment, so it can never address a different endpoint.
307
+
308
+ **Error responses.** `APIError` and its subclasses carry what the API reported:
309
+
310
+ | Attribute | Meaning |
311
+ |---|---|
312
+ | `status_code` | HTTP status |
313
+ | `code` | Stable machine-readable code, such as `"capture_not_found"`. `None` if the response was not in the API's error format (for example an HTML page from a proxy). |
314
+ | `message` | Human-readable description |
315
+ | `request_id` | Identifier of the request. Include it when you contact support. If what the server sent as the id contains your API key (in any letter case) or anything shaped like an API key, it is replaced by `"[redacted]"`. |
316
+
317
+ ```python
318
+ import volumes
319
+
320
+ client = volumes.Client()
321
+
322
+ try:
323
+ frame_sync = client.get_frame_sync("capture_demo_001")
324
+ except volumes.CaptureNotFoundError:
325
+ # The capture does not exist, or this key has no access to it.
326
+ # The API does not say which.
327
+ ...
328
+ except volumes.MetadataNotAvailableError:
329
+ # The capture is yours, but its frame sync has not been produced yet. Try later.
330
+ ...
331
+ except volumes.AuthenticationError:
332
+ # The key is wrong, revoked, or the account is disabled.
333
+ ...
334
+ except volumes.RateLimitError as error:
335
+ print("slow down; retry after", error.retry_after, "seconds")
336
+ except volumes.APIConnectionError:
337
+ # Network problem or timeout (APITimeoutError is a subclass).
338
+ ...
339
+ except volumes.APIError as error:
340
+ print(error.status_code, error.code, error.message, error.request_id)
341
+ ```
342
+
343
+ | Status | `code` | Exception |
344
+ |---|---|---|
345
+ | 400 | `invalid_request` | `BadRequestError` |
346
+ | 401 | `invalid_api_key` | `AuthenticationError` |
347
+ | 404 | `capture_not_found` | `CaptureNotFoundError` |
348
+ | 404 | `frame_sync_not_available`, `scene_summary_not_available` | `MetadataNotAvailableError` |
349
+ | 404 | anything else | `NotFoundError` |
350
+ | 429 | any | `RateLimitError` |
351
+ | 5xx | `internal_error`, `service_unavailable`, or none | `ServerError` |
352
+ | other | any | `APIError` |
353
+
354
+ **Responses that cannot be understood** raise `InvalidResponseError`:
355
+
356
+ - a success response that is not of the type the endpoint returns:
357
+ `Content-Type: text/csv` for frame sync and `application/json` for
358
+ everything else (a `charset` or other parameter is ignored). A `200` with
359
+ another type, such as the HTML sign-in page of a proxy, is never returned as
360
+ data;
361
+ - a JSON body that is not JSON or has the wrong shape;
362
+ - frame sync bytes that are not UTF-8 (raised when `.text` or `.rows` is read)
363
+ or text that cannot be parsed as CSV (raised when `.rows` is read);
364
+ - pagination that would never end (the same cursor twice, or more than five
365
+ empty pages in a row that each promise more), or a cursor that contains your
366
+ API key: a cursor is sent back in the next request's URL, and the key never
367
+ goes into a URL.
368
+
369
+ The exception never carries the response body, not even indirectly through a
370
+ chained exception: the body may be large, and it is data, not a diagnostic.
371
+ For frame sync it is available as `.content`.
372
+
373
+ It carries `status_code` and `request_id` like the error responses above.
374
+
375
+ ## Retries
376
+
377
+ Requests that fail for transient reasons are retried automatically, up to
378
+ `max_retries` times (default 2, so at most 3 attempts; the most that can be
379
+ configured is 10):
380
+
381
+ | Retried | Never retried |
382
+ |---|---|
383
+ | connection errors | 400 |
384
+ | timeouts | 401 |
385
+ | 429 | 404 (including "not available yet") |
386
+ | any 5xx | every other 4xx |
387
+
388
+ Between attempts the client waits with exponential backoff and jitter: about
389
+ 0.5 s, 1 s, 2 s, ... capped at 8 s, each reduced randomly by up to half.
390
+
391
+ If the response has a `Retry-After` header (seconds or an HTTP date), the
392
+ client waits at least that long, plus a random extra of up to one backoff step
393
+ (0.5 s on the first retry, 1 s on the second, ...), capped at 60 s in total.
394
+ The extra is deliberate: a busy server tells every client the same number at
395
+ the same moment, and without it they would all return together.
396
+
397
+ When the retries are used up, the last error is raised. Each page fetched by
398
+ `list_captures()` / `iter_captures()` has its own retry budget.
399
+
400
+ ```python
401
+ volumes.Client(max_retries=0) # fail fast
402
+ volumes.Client(max_retries=5) # more patient
403
+ ```
404
+
405
+ ## Configuration
406
+
407
+ | Setting | Argument | Environment variable | Default |
408
+ |---|---|---|---|
409
+ | API key | `api_key` | `VOLUMES_API_KEY` | none (required) |
410
+ | API endpoint | `base_url` | `VOLUMES_BASE_URL` | none (required) |
411
+ | Request timeout | `timeout` | | `30.0` seconds (`None` = no timeout) |
412
+ | Retries | `max_retries` | | `2` |
413
+ | HTTP client | `http_client` | | a new `httpx.Client` |
414
+
415
+ An argument always wins over the environment variable.
416
+
417
+ There is no default endpoint: use the URL you were given. It has to be an
418
+ `https://` URL, because the API key travels in a request header; `http://` is
419
+ accepted only for a loopback address, for local development (see
420
+ [`volumes.Client(...)`](#volumesclient)).
421
+
422
+ The client identifies itself with `User-Agent: volumes-python/<version>` and
423
+ sends nothing else about your environment. Redirects are not followed.
424
+
425
+ ### Proxies
426
+
427
+ The HTTP client the SDK creates for itself follows the usual proxy settings of
428
+ the environment (`HTTPS_PROXY`, `ALL_PROXY`, `NO_PROXY`, ...) for an
429
+ `https://` endpoint, as `httpx` does: such a request is tunnelled through the
430
+ proxy, encrypted end to end.
431
+
432
+ For a plain `http://` endpoint, which can only be a loopback address, it
433
+ ignores them and always connects directly. A plain-http request sent through a
434
+ proxy is not tunnelled: the proxy would receive the whole request, API key
435
+ included, in clear, and a request to your own machine has no business going
436
+ to another one.
437
+
438
+ Proxy or TLS settings in the environment that cannot be used are reported in
439
+ one of two ways, and which one depends partly on the installed `httpx`:
440
+
441
+ - What `httpx` notices when a client is created makes creating a client for an
442
+ `https://` endpoint raise `ConfigurationError`. On every supported `httpx`
443
+ version that covers a proxy URL with a scheme `httpx` does not support and a
444
+ SOCKS proxy without the package for it. Newer versions notice more at that
445
+ point (some malformed proxy URLs, a certificate file that does not exist).
446
+ - Everything else shows up at the first request as `APIConnectionError`: a
447
+ proxy that cannot be reached, a proxy URL that names no usable host. (Older
448
+ `httpx` versions ignore a certificate file that does not exist.)
449
+
450
+ Either way the exception is a `VolumesError`.
451
+
452
+ This applies to the SDK's own HTTP client only. If you pass your own
453
+ `http_client`, how it routes requests is yours to decide and the SDK does not
454
+ change it: a client created with `httpx.Client()` reads the environment, so
455
+ with it a plain-http request does go to a proxy named there. Create it with
456
+ `httpx.Client(trust_env=False)` if that is not what you want.
457
+
458
+ ### Custom transport
459
+
460
+ Pass your own `httpx.Client` to control proxies, TLS settings or connection
461
+ limits. The SDK still adds its own headers, your API key and its timeout to
462
+ every request it sends, without changing your client's settings (see
463
+ [Proxies](#proxies) for what that means for a plain `http://` endpoint).
464
+
465
+ ```python
466
+ import httpx
467
+ import volumes
468
+
469
+ http_client = httpx.Client(limits=httpx.Limits(max_connections=4))
470
+ client = volumes.Client(http_client=http_client)
471
+ ```
472
+
473
+ What the SDK does with what your client raises:
474
+
475
+ | Raised inside your `http_client` | You get |
476
+ |---|---|
477
+ | `httpx.TimeoutException` | `APITimeoutError` (retried) |
478
+ | any other `httpx.TransportError` | `APIConnectionError` (retried) |
479
+ | `httpx.HTTPStatusError`, for example from a response hook that calls `raise_for_status()` | the same exception as without the hook, chosen by the status (`AuthenticationError`, `CaptureNotFoundError`, `ServerError`, ...) and retried or not by the same rules. If the hook did not read the body first, the body is gone: `code` is then `None` and a 404 is a plain `NotFoundError`. |
480
+ | any other `httpx.HTTPError` | `APIConnectionError` (not retried) |
481
+ | `httpx.InvalidURL` | `InvalidArgumentError` |
482
+ | the client being closed | `ClientClosedError` |
483
+ | anything else: an exception of your own transport, hook or auth code | that exception, unchanged |
484
+
485
+ This is also how to test code that uses the SDK without any network:
486
+
487
+ ```python
488
+ import httpx
489
+ import volumes
490
+
491
+
492
+ def handler(request: httpx.Request) -> httpx.Response:
493
+ return httpx.Response(
494
+ 200, json={"captures": [{"capture_id": "capture_demo_001"}], "next_cursor": None}
495
+ )
496
+
497
+
498
+ client = volumes.Client(
499
+ api_key="test-key",
500
+ base_url="https://api.example.test",
501
+ http_client=httpx.Client(transport=httpx.MockTransport(handler)),
502
+ )
503
+ assert client.list_captures() == [volumes.Capture("capture_demo_001")]
504
+ ```
505
+
506
+ ## Development
507
+
508
+ ```bash
509
+ uv venv --python 3.12
510
+ source .venv/bin/activate
511
+ uv pip install -e ".[dev]"
512
+
513
+ pytest
514
+ ruff check .
515
+ ruff format --check .
516
+ mypy
517
+ ```
518
+
519
+ The test suite is offline: it uses `httpx.MockTransport`, never sleeps, and
520
+ fails if anything tries to open a network connection. It is run on Python 3.9,
521
+ 3.10, 3.11 and 3.12.
522
+
523
+ The version number is written in one place, `src/volumes/_version.py`; the
524
+ package metadata takes it from there when the package is built.
525
+
526
+ Sync-only for now. Request building, response parsing and error mapping
527
+ (`_protocol.py`) and the retry policy (`_retry.py`) do no I/O, and the API key
528
+ holder (`_auth.py`) is an `httpx.Auth` that works for sync and async clients
529
+ alike, so an async client can be added on top of them later.