(
server: &str,
limit: u32,
offset: u32,
ids_only: bool,
names_only: bool,
label_selector: Option<&str>,
output: &str,
tls: &TlsOptions,
)
| 3338 | /// List sandboxes. |
| 3339 | #[allow(clippy::too_many_arguments)] |
| 3340 | pub async fn sandbox_list( |
| 3341 | server: &str, |
| 3342 | limit: u32, |
| 3343 | offset: u32, |
| 3344 | ids_only: bool, |
| 3345 | names_only: bool, |
| 3346 | label_selector: Option<&str>, |
| 3347 | output: &str, |
| 3348 | tls: &TlsOptions, |
| 3349 | ) -> Result<()> { |
| 3350 | let mut client = grpc_client(server, tls).await?; |
| 3351 | |
| 3352 | let response = client |
| 3353 | .list_sandboxes(ListSandboxesRequest { |
| 3354 | limit, |
| 3355 | offset, |
| 3356 | label_selector: label_selector.unwrap_or("").to_string(), |
| 3357 | }) |
| 3358 | .await |
| 3359 | .into_diagnostic()?; |
| 3360 | |
| 3361 | let sandboxes = response.into_inner().sandboxes; |
| 3362 | |
| 3363 | if crate::output::print_output_collection(output, &sandboxes, sandbox_to_json)? { |
| 3364 | return Ok(()); |
| 3365 | } |
| 3366 | |
| 3367 | if sandboxes.is_empty() { |
| 3368 | if !ids_only && !names_only { |
| 3369 | println!("No sandboxes found."); |
| 3370 | } |
| 3371 | return Ok(()); |
| 3372 | } |
| 3373 | |
| 3374 | if ids_only { |
| 3375 | for sandbox in sandboxes { |
| 3376 | println!("{}", sandbox.object_id()); |
| 3377 | } |
| 3378 | return Ok(()); |
| 3379 | } |
| 3380 | |
| 3381 | if names_only { |
| 3382 | for sandbox in sandboxes { |
| 3383 | println!("{}", sandbox.object_name()); |
| 3384 | } |
| 3385 | return Ok(()); |
| 3386 | } |
| 3387 | |
| 3388 | // Calculate column widths |
| 3389 | let name_width = sandboxes |
| 3390 | .iter() |
| 3391 | .map(|s| s.object_name().len()) |
| 3392 | .max() |
| 3393 | .unwrap_or(4) |
| 3394 | .max(4); |
| 3395 | let created_width = 19; // "YYYY-MM-DD HH:MM:SS" |
| 3396 | |
| 3397 | // Print header |
no test coverage detected