justinmclean opened a new issue, #4611:
URL: https://github.com/apache/iggy/issues/4611

   The Python SDK has no way to take a server snapshot. The Rust client and the 
C++ SDK both have one.
   
   ### Where
   
   - `foreign/python/src/client.rs`: a new `snapshot` method on the client.
   - `foreign/python/apache_iggy.pyi`: the regenerated stub.
   - `foreign/python/tests/test_snapshot.py`: a new test file.
   
   ### Context
   
   The Rust trait is `SystemClient::snapshot(compression: SnapshotCompression, 
snapshot_types: Vec<SystemSnapshotType>) -> Result<Snapshot, IggyError>` in 
`core/common/src/traits/system_client.rs`. `Snapshot` wraps a `Vec<u8>` 
(`core/common/src/types/snapshot/mod.rs`), so the Python method can return 
`bytes` with no new result class.
   
   Both enums implement `FromStr` in that file, so the arguments can be plain 
strings, the way `describe_options` takes a scope string:
   
   - compression: `stored`, `deflated`, `bzip2`, `zstd`, `lzma`, `xz`
   - snapshot types: `filesystem_overview`, `process_list`, `resource_usage`, 
`test`, `server_logs`, `server_config`, `all`
   
   The C++ SDK already does this in `snapshot` in `foreign/cpp/src/client.rs`, 
including rejecting an empty type list and an empty or unknown compression. Use 
it as the worked example.
   
   ### Done looks like
   
   - `data = await client.snapshot("deflated", ["all"])` returns non-empty 
`bytes` against a real server.
   - An unknown compression or snapshot type, or an empty type list, raises 
`ValueError` before any request is sent.
   - The method has a docstring in the style of its neighbours, and the `.pyi` 
stub is regenerated.
   - `uv run --no-sync pytest tests/test_snapshot.py -v` passes.
   
   ### Steps
   
   - [ ] Read `snapshot` in `foreign/cpp/src/client.rs` for the argument checks 
and the `FromStr` calls.
   - [ ] Add `snapshot(compression: &str, snapshot_types: Vec<String>)` to 
`foreign/python/src/client.rs`, using `future_into_py` and `to_runtime_error` 
as `get_stats` does, and map bad input to `PyValueError`.
   - [ ] Return the snapshot as `bytes`.
   - [ ] Regenerate the stub with `cargo run --bin stub_gen` (see the Python 
README) and commit the `apache_iggy.pyi` change.
   - [ ] Add `test_snapshot.py` modelled on `test_stats.py`: a happy path, an 
invalid compression, an empty type list, and `"all"` combined with another type 
(the C++ test `SnapshotAllCombinedWithOtherTypeThrows` shows the expected 
behaviour).
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to