Generate typed API models for HAProxy, Caddy, Firewall, VLAN, LAGG,
WireGuard (client/server/general), and regenerate Dnsmasq. All core
modules validated against a live OPNsense 26.1.2 instance.
Codegen improvements:
- Add --module-name and --api-key CLI flags for controlling output
filenames and API response envelope keys
- Fix enum variant names starting with digits (prefix with V)
- Use value="" XML attribute for wire values instead of element names
- Handle unknown *Field types as opn_string (select widget safe)
- Forgiving enum deserialization (warn instead of error on unknown)
- Handle empty arrays in opn_string deserializer
Add per-module examples (list_haproxy, list_caddy, list_vlan, etc.)
and utility examples (raw_get, check_package, install_and_wait).
Extract shared client setup into examples/common/mod.rs.
Fix post_typed sending empty JSON body ({}) instead of no body,
which was causing 400 errors on firmware endpoints.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
22 lines
484 B
Rust
22 lines
484 B
Rust
//! Example: fetch and display OPNsense Caddy settings.
|
|
//!
|
|
//! ```text
|
|
//! cargo run --example list_caddy
|
|
//! ```
|
|
|
|
mod common;
|
|
|
|
use opnsense_api::generated::caddy::PischemCaddyResponse;
|
|
|
|
#[tokio::main]
|
|
async fn main() {
|
|
let client = common::client_from_env();
|
|
|
|
let response: PischemCaddyResponse = client
|
|
.get_typed("caddy", "General", "get")
|
|
.await
|
|
.expect("API call failed");
|
|
|
|
println!("{}", serde_json::to_string_pretty(&response).unwrap());
|
|
}
|