| Crates.io | victorops |
| lib.rs | victorops |
| version | 0.1.3 |
| created_at | 2025-05-26 16:50:53.266346+00 |
| updated_at | 2025-06-14 16:06:51.574184+00 |
| description | Async Rust client for VictorOps |
| homepage | |
| repository | https://github.com/endoze/victorops |
| max_upload_size | |
| id | 1690052 |
| size | 187,358 |
A Rust client library for the VictorOps (Splunk On-Call) REST API.
Add this to your Cargo.toml:
[dependencies]
victorops = "0.1.0"
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let api_id = "your-api-id".to_string();
let api_key = "your-api-key".to_string();
let client = victorops::Client::new(
api_id,
api_key,
"https://api.victorops.com".to_string(),
)?;
let (incidents, _details) = client.get_incidents().await?;
println!("Found {} incidents", incidents.incidents.len());
Ok(())
}
Run the team schedule example:
export VICTOROPS_API_ID="your-api-id"
export VICTOROPS_API_KEY="your-api-key"
cargo run --example team_schedule team-slug
Run the incidents example:
export VICTOROPS_API_ID="your-api-id"
export VICTOROPS_API_KEY="your-api-key"
cargo run --example incidents
get_incident(id) - Get a specific incidentget_incidents() - Get all incidentscreate_user(user) - Create a new userget_user(username) - Get user by usernameget_user_by_email(email) - Get user by email addressget_all_users() - Get all users (v1)get_all_users_v2() - Get all users (v2)update_user(user) - Update user informationdelete_user(username, replacement) - Delete user with replacementcreate_team(team) - Create a new teamget_team(team_id) - Get team by IDget_all_teams() - Get all teamsget_team_members(team_id) - Get team membersget_team_admins(team_id) - Get team administratorsupdate_team(team) - Update team informationdelete_team(team_id) - Delete teamadd_team_member(team_id, username) - Add member to teamremove_team_member(team_id, username, replacement) - Remove member from teamis_team_member(team_id, username) - Check if user is team memberget_api_team_schedule() - Get team on-call scheduleget_user_on_call_schedule() - Get user on-call scheduletake_on_call_for_team() - Take on-call for teamtake_on_call_for_policy() - Take on-call for escalation policycreate_escalation_policy(policy) - Create escalation policyget_escalation_policy(id) - Get escalation policy by IDget_all_escalation_policies() - Get all escalation policiesdelete_escalation_policy(id) - Delete escalation policycreate_routing_key(key) - Create routing keyget_routing_key(name) - Get routing key by nameget_all_routing_keys() - Get all routing keyscreate_contact(username, contact) - Create contact methodget_contact(username, ext_id, type) - Get contact methodget_all_contacts(username) - Get all contact methods for userget_contact_by_id(username, id, type) - Get contact method by IDdelete_contact(username, ext_id, type) - Delete contact method#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = victorops::Client::new(
"api-id".to_string(),
"api-key".to_string(),
"https://api.victorops.com".to_string(),
)?;
Ok(())
}
use std::time::Duration;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = victorops::Client::with_timeout(
"api-id".to_string(),
"api-key".to_string(),
"https://api.victorops.com".to_string(),
Duration::from_secs(60),
)?;
Ok(())
}
All API methods return a tuple containing the response data and request details:
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = victorops::Client::new(
"api-id".to_string(),
"api-key".to_string(),
"https://api.victorops.com".to_string(),
)?;
let (user, details) = client.get_user("username").await?;
println!("Status: {}", details.status_code);
println!("Response: {}", details.response_body);
println!("Request: {}", details.request_body);
Ok(())
}
The library provides comprehensive error handling through the Error enum:
use victorops::Error;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = victorops::Client::new(
"api-id".to_string(),
"api-key".to_string(),
"https://api.victorops.com".to_string(),
)?;
match client.get_user("nonexistent").await {
Ok((user, _)) => println!("User found: {:?}", user),
Err(Error::Api { status: 404, .. }) => println!("User not found"),
Err(Error::Http(e)) => println!("HTTP error: {}", e),
Err(e) => println!("Other error: {}", e),
}
Ok(())
}
Http - HTTP request failuresJson - JSON serialization/deserialization errorsUrlParse - URL parsing errorsInvalidHeaderValue - Invalid HTTP header valuesApi - API-specific errors with status codesAuthentication - Authentication failuresNotFound - Resource not foundInvalidInput - Invalid input parametersThe library includes comprehensive type definitions for all VictorOps entities:
User - User account informationTeam - Team details and membershipIncident - Incident data and transitionsEscalationPolicy - Escalation policy configurationContact - Contact method informationRoutingKey - Routing key configurationAll types support Serde serialization/deserialization and include optional fields as appropriate for the VictorOps API.
This project is licensed under the MIT License.