basic/
basic.rs

1use ip_allocator_client::Client;
2
3#[tokio::main]
4async fn main() -> Result<(), Box<dyn std::error::Error>> {
5    // Create a new client
6    let client = Client::new("http://localhost:8000");
7
8    // Borrow an item from the freelist
9    println!("šŸ”„ Borrowing an item...");
10    let borrow_result = client.handlers_ip_borrow().await?;
11    println!("āœ… Borrowed item: {:?}", borrow_result);
12
13    // Return an item to the freelist
14    println!("\nšŸ”„ Returning an item...");
15    let return_input = ip_allocator_client::types::ReturnInput {
16        item: serde_json::json!({"ip": "192.168.1.100"}),
17    };
18    let return_result = client.handlers_ip_return_item(&return_input).await?;
19    println!("āœ… Return operation initiated: {:?}", return_result);
20
21    // Check operation status
22    println!("\nšŸ”„ Checking operation status...");
23    let status = client
24        .handlers_ip_get_operation_status(&return_result.operation_id)
25        .await?;
26    println!("āœ… Operation status: {:?}", status);
27
28    Ok(())
29}