Overview
The ListAgentsOptions struct provides filtering and pagination options when fetching AI agents.
Definition
pub struct ListAgentsOptions {
pub page: Option<u32>,
pub per_page: Option<u32>,
pub is_active: Option<bool>,
pub search: Option<String>,
}
Fields
The page number to retrieve (1-indexed). Defaults to 1 if not specified.
Number of agents to return per page. Defaults to 20 if not specified.
Filter agents by active status. When true, only returns active agents. When false, only returns inactive agents.
Search query to filter agents by name, description, or other attributes.
Usage Example
use wacht::api::agents::{fetch_agents, ListAgentsOptions};
// Fetch all agents with default pagination
let all_agents = fetch_agents(None).await?;
// Fetch only active agents
let active_options = ListAgentsOptions {
is_active: Some(true),
..Default::default()
};
let active_agents = fetch_agents(Some(active_options)).await?;
// Search for specific agents with pagination
let search_options = ListAgentsOptions {
page: Some(2),
per_page: Some(50),
search: Some("customer support".to_string()),
is_active: Some(true),
};
let support_agents = fetch_agents(Some(search_options)).await?;
// Iterate through all pages
let mut page = 1;
loop {
let options = ListAgentsOptions {
page: Some(page),
per_page: Some(100),
..Default::default()
};
let response = fetch_agents(Some(options)).await?;
// Process agents
for agent in &response.data {
println!("Agent: {}", agent.name);
}
if !response.has_more {
break;
}
page += 1;
}
See Also