use cortex_client::apis::analyzer_api;
mod common;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let config = match common::setup_configuration() {
Ok(cfg) => cfg,
Err(e) => {
eprintln!("Configuration error: {}", e);
return Err(e.into());
}
};
println!("Fetching list of all analyzer instances...");
let find_request = Some(cortex_client::models::AnalyzerFindRequest::default());
match analyzer_api::find_analyzers(&config, find_request).await {
Ok(analyzers) => {
println!("\nSuccessfully fetched analyzer instances:");
if analyzers.is_empty() {
println!("No analyzer instances found in your Cortex organization.");
} else {
println!("--------------------------------------------------");
println!("Available Analyzer Instances:");
println!("--------------------------------------------------");
for worker_instance in &analyzers {
println!(
" Name: {}",
worker_instance.name.as_deref().unwrap_or("N/A")
);
println!(
" Instance ID (_id): {}", worker_instance._id.as_deref().unwrap_or("MISSING_ID")
);
println!(
" Definition ID: {}",
worker_instance
.worker_definition_id
.as_deref()
.unwrap_or("N/A")
);
println!(
" Type: {:?}",
worker_instance
.r#type
.unwrap_or(cortex_client::models::worker::Type::Analyzer) );
println!(" Enabled (Implicitly): If listed, it's an instance. Check Cortex UI for explicit enabled/disabled status if unsure.");
println!(" ---");
}
println!("\nTotal analyzer instances found: {}", analyzers.len());
println!("--------------------------------------------------");
println!("\nLook for your AbuseIPDB analyzer in the list above and use its 'Instance ID (_id)'");
println!(
"in your abuseipdb_example.rs file for the 'analyzer_worker_id' variable."
);
}
}
Err(e) => {
eprintln!("\nError fetching analyzer instances: {:?}", e);
eprintln!("Please check your Cortex connection and API key permissions.");
if let cortex_client::apis::Error::Serde(serde_err) = e {
eprintln!("Serde error details: {}", serde_err);
}
}
}
Ok(())
}