Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/cli integration #55

Draft
wants to merge 20 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .DS_Store
Binary file not shown.
7 changes: 7 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ snmp-data-parser = { path = "./crates/snmp-data-parser" }
rasn-snmp = { path = "./crates/rasn/standards/snmp" }
rasn-smi = { path = "./crates/rasn/standards/smi" }
rasn = { path = "./crates/rasn" }
clap = { version = "3.2.7", features = ["derive"] }

actix = "0.13"
actix-web = { version = "4.1", default_features = false, features = [
Expand Down Expand Up @@ -93,6 +94,8 @@ futures-util = { version = "0.3", default-features = false, features = [
cached = "0.35.0"
num_cpus = "1"
macro_rules_attribute = "0.1"
serde_yaml = "0.8"
async-trait = "0.1"

[dev-dependencies]
snmp-sim = { path = ".", features = ["integration-tests"] }
Expand Down Expand Up @@ -137,3 +140,7 @@ members = [

[patch.crates-io]
paperclip = { git = "https://github.com/sonalake/paperclip", branch = "master" }

[build-dependencies]
clap = "3.2"
clap_mangen = "0.1"
19 changes: 19 additions & 0 deletions build.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,24 @@
//use std::ffi::OsString;

// generated by `sqlx migrate build-script`
fn main() {
//-> std::io::Result<()> {
// trigger recompilation when a new migration is added
println!("cargo:rerun-if-changed=migrations");
// println!("cargo:rerun-if-env-changed=MAN_DIR");

// let package_name: &str = env!("CARGO_PKG_NAME");
// let man_dir = std::path::PathBuf::from(std::env::var_os("MAN_DIR").map_or(OsString::from("./man"), |v| v));

// let cmd = clap::Command::new(package_name)
// .arg(clap::arg!(-n --name <NAME>))
// .arg(clap::arg!(-c --count <NUM>));

// let man = clap_mangen::Man::new(cmd);
// let mut buffer: Vec<u8> = Default::default();
// man.render(&mut buffer)?;

// std::fs::write(man_dir.join(format!("{}.1", package_name)), buffer)?;

// Ok(())
}
87 changes: 66 additions & 21 deletions clients/rust/rust-client-snmp-sim-lib/src/apis/agents_api.rs
Original file line number Diff line number Diff line change
@@ -1,19 +1,17 @@
/*
*
*
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document:
*
* The version of the OpenAPI document:
*
* Generated by: https://openapi-generator.tech
*/


use reqwest;

use super::{configuration, Error};
use crate::apis::ResponseContent;
use super::{Error, configuration};


/// struct for typed errors of method [`agents_get`]
#[derive(Debug, Clone, Serialize, Deserialize)]
Expand Down Expand Up @@ -70,8 +68,11 @@ pub enum AgentsPostError {
UnknownValue(serde_json::Value),
}


pub async fn agents_get(configuration: &configuration::Configuration, page: Option<i64>, page_size: Option<i64>) -> Result<Vec<crate::models::ResponseAgent>, Error<AgentsGetError>> {
pub async fn agents_get(
configuration: &configuration::Configuration,
page: Option<i64>,
page_size: Option<i64>,
) -> Result<Vec<crate::models::ResponseAgent>, Error<AgentsGetError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;
Expand Down Expand Up @@ -99,17 +100,28 @@ pub async fn agents_get(configuration: &configuration::Configuration, page: Opti
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AgentsGetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn agents_id_delete(configuration: &configuration::Configuration, id: &str) -> Result<crate::models::ResponseAgent, Error<AgentsIdDeleteError>> {
pub async fn agents_id_delete(
configuration: &configuration::Configuration,
id: &str,
) -> Result<crate::models::ResponseAgent, Error<AgentsIdDeleteError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/agents/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
let local_var_uri_str = format!(
"{}/agents/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::DELETE, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
Expand All @@ -126,17 +138,28 @@ pub async fn agents_id_delete(configuration: &configuration::Configuration, id:
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AgentsIdDeleteError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn agents_id_get(configuration: &configuration::Configuration, id: &str) -> Result<crate::models::ResponseAgent, Error<AgentsIdGetError>> {
pub async fn agents_id_get(
configuration: &configuration::Configuration,
id: &str,
) -> Result<crate::models::ResponseAgent, Error<AgentsIdGetError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/agents/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
let local_var_uri_str = format!(
"{}/agents/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::GET, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
Expand All @@ -153,17 +176,29 @@ pub async fn agents_id_get(configuration: &configuration::Configuration, id: &st
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AgentsIdGetError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn agents_id_put(configuration: &configuration::Configuration, id: &str, body: crate::models::RequestAgent) -> Result<crate::models::ResponseAgent, Error<AgentsIdPutError>> {
pub async fn agents_id_put(
configuration: &configuration::Configuration,
id: &str,
body: crate::models::RequestAgent,
) -> Result<crate::models::ResponseAgent, Error<AgentsIdPutError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;

let local_var_uri_str = format!("{}/agents/{id}", local_var_configuration.base_path, id=crate::apis::urlencode(id));
let local_var_uri_str = format!(
"{}/agents/{id}",
local_var_configuration.base_path,
id = crate::apis::urlencode(id)
);
let mut local_var_req_builder = local_var_client.request(reqwest::Method::PUT, local_var_uri_str.as_str());

if let Some(ref local_var_user_agent) = local_var_configuration.user_agent {
Expand All @@ -181,12 +216,19 @@ pub async fn agents_id_put(configuration: &configuration::Configuration, id: &st
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AgentsIdPutError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

pub async fn agents_post(configuration: &configuration::Configuration, body: crate::models::RequestAgent) -> Result<crate::models::ResponseAgent, Error<AgentsPostError>> {
pub async fn agents_post(
configuration: &configuration::Configuration,
body: crate::models::RequestAgent,
) -> Result<crate::models::ResponseAgent, Error<AgentsPostError>> {
let local_var_configuration = configuration;

let local_var_client = &local_var_configuration.client;
Expand All @@ -209,8 +251,11 @@ pub async fn agents_post(configuration: &configuration::Configuration, body: cra
serde_json::from_str(&local_var_content).map_err(Error::from)
} else {
let local_var_entity: Option<AgentsPostError> = serde_json::from_str(&local_var_content).ok();
let local_var_error = ResponseContent { status: local_var_status, content: local_var_content, entity: local_var_entity };
let local_var_error = ResponseContent {
status: local_var_status,
content: local_var_content,
entity: local_var_entity,
};
Err(Error::ResponseError(local_var_error))
}
}

Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
/*
*
*
*
* No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
*
* The version of the OpenAPI document:
*
* The version of the OpenAPI document:
*
* Generated by: https://openapi-generator.tech
*/


use reqwest;


#[derive(Debug, Clone)]
pub struct Configuration {
pub base_path: String,
Expand All @@ -32,7 +30,6 @@ pub struct ApiKey {
pub key: String,
}


impl Configuration {
pub fn new() -> Configuration {
Configuration::default()
Expand All @@ -49,7 +46,6 @@ impl Default for Configuration {
oauth_access_token: None,
bearer_access_token: None,
api_key: None,

}
}
}
Loading