use serde::Deserialize;
use crate::api::client::ApiClient;
use crate::error::OlError;
#[derive(Debug, Clone, Deserialize)]
pub struct CatalogAgent {
pub platform: String,
#[serde(default)]
pub display_name: Option<String>,
}
#[derive(Debug, Clone, Deserialize)]
pub struct CatalogHook {
pub agent: String,
pub event_type: String,
}
#[derive(Debug, Clone, Deserialize)]
pub struct CatalogErrorCode {
pub code: String,
pub category: String,
#[serde(default)]
pub description: Option<String>,
}
#[derive(Debug, Deserialize)]
struct ListResponse<T> {
#[serde(default = "Vec::new")]
items: Vec<T>,
}
pub async fn list_agents(client: &ApiClient) -> Result<Vec<CatalogAgent>, OlError> {
let resp: ListResponse<CatalogAgent> = client.get("/api/v1/catalog/agents").await?;
Ok(resp.items)
}
pub async fn list_hooks(client: &ApiClient) -> Result<Vec<CatalogHook>, OlError> {
let resp: ListResponse<CatalogHook> = client.get("/api/v1/catalog/hooks").await?;
Ok(resp.items)
}
pub async fn list_error_codes(client: &ApiClient) -> Result<Vec<CatalogErrorCode>, OlError> {
let resp: ListResponse<CatalogErrorCode> = client.get("/api/v1/catalog/error-codes").await?;
Ok(resp.items)
}