github-actions[bot] commented on code in PR #4616:
URL: https://github.com/apache/iggy/pull/4616#discussion_r4338977747
##########
foreign/python/src/client.rs:
##########
@@ -257,6 +257,61 @@ impl IggyClient {
})
}
+ /// Capture a diagnostic snapshot of the server as a compressed ZIP
archive.
+ ///
+ /// Requires an authenticated session whose user holds the `manage_servers`
+ /// global permission.
+ ///
+ /// Args:
+ /// compression: Archive compression method. One of `"stored"`,
+ /// `"deflated"`, `"bzip2"`, `"zstd"`, `"lzma"`, `"xz"`.
+ /// snapshot_types: Data to include in the snapshot. Each entry is one
+ /// of `"filesystem_overview"`, `"process_list"`,
`"resource_usage"`,
+ /// `"test"`, `"server_logs"`, `"server_config"`, `"all"`. `"all"`
+ /// cannot be combined with any other snapshot type.
+ ///
+ /// Returns:
+ /// An awaitable that resolves to the ZIP archive `bytes`.
+ ///
+ /// Raises:
+ /// ValueError: If `compression` is empty or unknown, `snapshot_types`
+ /// is empty, or any entry in `snapshot_types` is unknown.
+ /// RuntimeError: If the client is not connected, the session is not
+ /// authenticated, the user lacks the permission, `"all"` is
+ /// combined with another snapshot type, or the request fails.
+
#[gen_stub(override_return_type(type_repr="collections.abc.Awaitable[bytes]",
imports=("collections.abc")))]
+ fn snapshot<'a>(
+ &self,
+ py: Python<'a>,
+ compression: &str,
+ snapshot_types: Vec<String>,
+ ) -> PyResult<Bound<'a, PyAny>> {
+ let compression = match compression.trim() {
+ "" => return Err(PyValueError::new_err("compression must not be
empty")),
+ value =>
SnapshotCompression::from_str(value).map_err(to_value_error)?,
+ };
+ if snapshot_types.is_empty() {
+ return Err(PyValueError::new_err("snapshot_types must not be
empty"));
+ }
+
+ let mut parsed_types = Vec::with_capacity(snapshot_types.len());
+ for snapshot_type in snapshot_types {
+ let parsed =
SystemSnapshotType::from_str(&snapshot_type).map_err(to_value_error)?;
+ if !parsed_types.contains(&parsed) {
Review Comment:
nit: The dedupe branch has no test, and without it 256 copies of `"test"`
reach `GetSnapshotRequest::encode`, which panics on the `u8` count. Add a test
that passes 256 duplicates and expects a ZIP archive.
--
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]