Some checks failed
Integration Tests / integration-test (push) Failing after 6s
- Fix AssetUploadStatus serialization to use snake_case (created/duplicate/rejected) - Fix AssetOrder serialization to use lowercase (asc/desc) - Add file_created_at/file_modified_at to UploadAssetBuilder - Fix AddAssetsBuilder response type to Vec<Value> instead of AlbumResponse - Fix ServerAbout model - version is String not ServerVersion struct - Update upload_photos.rs to handle duplicate responses correctly - Update server_info.rs to display new ServerAbout fields - Update AGENTS.md with new example list
51 lines
1.7 KiB
Rust
51 lines
1.7 KiB
Rust
//! Example: Server information
|
|
//!
|
|
//! This example demonstrates how to check server health and capabilities
|
|
|
|
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");
|
|
|
|
let client = Client::from_url(&url)?.with_api_key(api_key);
|
|
|
|
// Health check (ping)
|
|
println!("Checking server health...");
|
|
match client.server().ping().await {
|
|
Ok(response) => println!("Server is healthy! Response: {}", response),
|
|
Err(e) => println!("Health check failed: {}", e),
|
|
}
|
|
|
|
// Get version
|
|
println!("\nServer Version:");
|
|
let version = client.server().version().await?;
|
|
println!(" Version: {}", version);
|
|
|
|
// Get features
|
|
println!("\nServer Features:");
|
|
let features = client.server().features().await?;
|
|
println!(" OAuth enabled: {}", features.oauth);
|
|
println!(" OAuth auto launch: {}", features.oauth_auto_launch);
|
|
println!(" Password login: {}", features.password_login);
|
|
println!(" Config file: {}", features.config_file);
|
|
|
|
// Get about info
|
|
println!("\nServer About:");
|
|
let about = client.server().about().await?;
|
|
println!(" Version: {}", about.version);
|
|
println!(" Version URL: {}", about.version_url);
|
|
println!(" Licensed: {}", about.licensed);
|
|
if let Some(ref build) = about.build {
|
|
println!(" Build: {}", build);
|
|
}
|
|
if let Some(ref repository) = about.repository {
|
|
println!(" Repository: {}", repository);
|
|
}
|
|
|
|
Ok(())
|
|
}
|