Add integration testing infrastructure with Podman Compose

- Add docker/podman-compose.yml for Immich server (no ML)
- Add test-data/sample-photos/ with 3 public domain images
- Add scripts/start-immich.sh for container startup + admin/API key creation
- Add scripts/seed-data.sh for uploading test photos and creating albums
- Add scripts/stop-immich.sh for cleanup with volume destruction
- Add scripts/run-example.sh wrapper (fixed env var export)
- Update examples to use IMMICH_URL and IMMICH_API_KEY env vars
- Add .github/workflows/integration-test.yml for CI
- Update assets.list() to use /search/metadata endpoint
- Update AGENTS.md with example running instructions
- Add 5 new examples: search_metadata, album_management, timeline_browsing,
  delete_assets, server_info
This commit is contained in:
Joakim Hulthe
2026-04-14 19:56:41 +00:00
parent c55d2b9080
commit 2e7db3b35a
22 changed files with 1327 additions and 22 deletions

67
examples/delete_assets.rs Normal file
View File

@@ -0,0 +1,67 @@
//! Example: Delete assets
//!
//! This example demonstrates how to delete assets from Immich.
//!
//! WARNING: This will actually delete photos. Use with caution!
//!
//! This example uses environment variables for configuration:
//! - IMMICH_URL: The Immich server URL (defaults to http://localhost:2283)
//! - IMMICH_API_KEY: Your API key (required)
//!
//! IMPORTANT: Run this against a test instance only. This operation permanently
//! removes assets from the server.
use immich_sdk::Client;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Configure the client from environment variables
let url = std::env::var("IMMICH_URL").unwrap_or_else(|_| "http://localhost:2283".to_string());
let api_key =
std::env::var("IMMICH_API_KEY").expect("IMMICH_API_KEY environment variable not set");
// Create a client
let client = Client::from_url(&url)?.with_api_key(api_key);
// List existing assets
let assets = client.assets().list().execute().await?;
println!("Found {} assets", assets.len());
if assets.is_empty() {
println!("No assets to delete. Run upload_photos first.");
return Ok(());
}
// Get the first asset details
let first_id = assets[0].id;
println!("Getting details for asset: {}", first_id);
let asset = client.assets().get(first_id).execute().await?;
println!("Asset: {} ({})", asset.original_file_name, asset.id);
// Delete a single asset
println!("\nDeleting single asset...");
client.assets().delete().id(first_id).execute().await?;
println!("Asset deleted successfully");
// Batch delete (if there are more assets)
if assets.len() > 1 {
println!("\nBatch deleting remaining assets...");
let ids_to_delete: Vec<_> = assets.iter().skip(1).take(2).map(|a| a.id).collect();
client
.assets()
.delete()
.ids(ids_to_delete)
.execute()
.await?;
println!("Batch delete completed");
}
// Verify deletion
let remaining = client.assets().list().execute().await?;
println!("\nRemaining assets: {}", remaining.len());
Ok(())
}