3 releases

new 0.1.2 Jan 16, 2025
0.1.1 Jan 14, 2025
0.1.0 Jan 12, 2025

#518 in Web programming

Download history 274/week @ 2025-01-11

274 downloads per month

Custom license

47KB
1.5K SLoC

pan-os-rs

This project is intended to provide a wrapper around the PanOS REST API for a natively compiled and memory-safe language. Existing solutions often rely on the older XML API or are implemented in interpreted languages, which can limit performance and scalability. With this library, you can use Rust to create more efficient solutions for use with your Panorama and firewalls!

Usage

To use the library, simply use cargo add pan-os-rs or add the following to your Cargo.toml:

pan-os-rs = "0.1.0"

When using the library, all actions will be done through Session, which is the main entry point for all API calls. With its methods, you can interact with any API surface exposed by PanOS simply by specifying the object type.

use pan_os_rs::Session;

let session = Session::new("127.0.0.1", "admin", String::from("password"), true).await?;
let addresses = session.get_all::<Address>(Location::Shared, None).await?;
for address in addresses {
    println!("Name: {}\nDescription: {}\nIdentifier: {:?}\n", address.info.name, address.info.description, address.identifier);
}

Notes

While this project is focusing on the REST API, it's important to note that it will implement the bulk operations of the XML API as well for performance reasons. Current attempts at doing this have failed due to limitations in the available crates.

  • serde_xml_rs is outdated and does not appear to support #[serde(rename = "$value")] on structs/enums directly.
  • quick_xml is not implementing #[serde(flatten)] until a new feature is stablized in Rust which will take an unknown amount of time.
  • xmlserde and its helper crate xmlserde_derives would work perfectly, but does not support dyn traits or generics.

Until a valid offering presents itself - or unless a convenient method is found that is user-friendly and does not require multiple user-facing types - XML support will be on hold.

Dependencies

~9–22MB
~289K SLoC