Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# Unreleased

## AeroCloud

### Features

- Add `v7 list-reusable-models` command.

# 1.1.0 - 2026-01-28

## AeroCloud
Expand Down
3 changes: 3 additions & 0 deletions src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,9 @@ pub enum AeroCloudV7Command {
yaw_angle: Option<YawAngle>,
},

#[command(about = "List reusable models")]
ListReusableModels,

#[command(about = "Create a new model")]
CreateModel {
#[arg(
Expand Down
3 changes: 3 additions & 0 deletions src/commands/aerocloud/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ pub async fn run(
)
.await
}
AeroCloudV7Command::ListReusableModels => {
self::v7::list_reusable_models::run(args, &client).await
}
AeroCloudV7Command::CreateModel { params } => {
self::v7::create_model::run(
args,
Expand Down
63 changes: 63 additions & 0 deletions src/commands/aerocloud/v7/list_reusable_models.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
use crate::{
aerocloud::{
Client,
types::{ListPageModelsV7, ModelV7, PaginationOffset},
},
args::Args,
utils::new_dynamic_table,
};
use chrono::Local;
use color_eyre::eyre;

pub async fn run(args: &Args, client: &Client) -> eyre::Result<()> {
let mut all_items = vec![];
let mut offset = PaginationOffset(0u64);

loop {
let ListPageModelsV7 { items, nav } = client
.models_v7_list_reusable(None, Some(&offset))
.await?
.into_inner();

all_items.extend(items);

if let Some(next_offset) = nav.next_offset {
offset = PaginationOffset(next_offset);
} else {
break;
}
}

if args.json {
println!("{}", &serde_json::to_string(&all_items)?);
} else {
print_human(&all_items);
}

Ok(())
}

fn print_human(models: &[ModelV7]) {
if models.is_empty() {
println!("<empty>");
return;
}

let mut table = new_dynamic_table();
table.set_header(vec!["Id", "Name", "Files", "Parts", "Created at"]);

for model in models {
table.add_row(vec![
format!("{}", model.id),
format!("{}", model.name),
format!("{}", model.files.len()),
format!(
"{}",
model.files.iter().map(|f| f.parts.len()).sum::<usize>()
),
format!("{}", model.created_at.with_timezone(&Local)),
]);
}

println!("{table}");
}
1 change: 1 addition & 0 deletions src/commands/aerocloud/v7/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,5 +5,6 @@ pub mod create_simulation;
pub mod delete_projects;
pub mod delete_simulations;
pub mod list_projects;
pub mod list_reusable_models;
pub mod list_simulations;
pub mod wait_for_simulations;