Skip to main content

Crate rnaapi

Crate rnaapi 

Source
Expand description

Light weight Rust API client library for the NetActuate API Rust library for talking to the NetActuate API

This library provides the methods for establishing a connection and for retrieving data from most endpoints

It also includes an example app that just prints out some information The app can be installed with cargo install rnaapi

§Usage

§Import the library

cargo add rnaapi

§Set up your environment, note that the API_ADDRESS will be appended

to based on the endpoints

export API_KEY='<your api key>'
export API_ADDRESS='https://vapi2.netactuate.com/api/'

§Import the config that uses the environment

// Simplest example
use anyhow::Result;
use clap::Parser;
use rnaapi::NaClient;
use rnaapi::config::Settings;
use rnaapi::endpoints;
use rnaapi::{EndpointGet, EndpointGetArgs};
#[tokio::main]
async fn main() -> Result<()> {

    // with above imports
    let settings = Settings::new();
    let client = NaClient::new(settings.api_key, settings.api_url).await;
    let servers = client.get_servers().await;
    for server in servers {
        println!("fqdn: {}, mbpkgid: {}", server.fqdn, server.mbpkgid);
    }
    Ok(())
}

Modules§

config
endpoints
errors

Structs§

NaClient

Enums§

EndpointGetArgs

Traits§

EndpointGetAll
EndpointGetOne

Derive Macros§

EndpointGetAll
EndpointGetOne