v2 changes init
parent
efb00dcf5e
commit
59ab93a46e
|
|
@ -1,13 +1,31 @@
|
||||||
{
|
{
|
||||||
"endpoints" : [
|
"id" : 1 ,
|
||||||
{
|
"template" :
|
||||||
"url" : "http://127.0.0.1:8081/ping",
|
[{
|
||||||
"method" : "GET"
|
"id" :"mock_api_1",
|
||||||
},
|
"name" : "Mock / ",
|
||||||
{
|
"url" : "http://127.0.0.1:8081/",
|
||||||
"url" : "http://127.0.0.1:8081/",
|
"method" : "GET",
|
||||||
"method" : "GET"
|
"measure" :
|
||||||
}
|
[
|
||||||
],
|
"operation", "response", "empty_field"
|
||||||
"delay" : 5
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"id" :"mock_api_2",
|
||||||
|
"name" : "Mock /ping ",
|
||||||
|
"url" : "http://127.0.0.1:8081/ping",
|
||||||
|
"method" : "GET",
|
||||||
|
"measure" :
|
||||||
|
[
|
||||||
|
"operation", "response", "empty_field"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"ip_address" : "127.0.0.1:8081",
|
||||||
|
"login" : "",
|
||||||
|
"pass" : "" ,
|
||||||
|
"api_key" : "908c709827bd40n98r7209837x98273",
|
||||||
|
"period" : 10,
|
||||||
|
"timeout" : 2
|
||||||
}
|
}
|
||||||
|
|
@ -1,7 +1,7 @@
|
||||||
// mod to communicate with api-grub config file
|
// mod to communicate with api-grub config file
|
||||||
// 1) check changes in unix-socket
|
// 1) check changes in unix-socket
|
||||||
// 2) save changes in local config file
|
// 2) save changes in local config file
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::{ApiConfig, ApiConfigV2};
|
||||||
use anyhow::{Error, Ok, Result};
|
use anyhow::{Error, Ok, Result};
|
||||||
use log::{info, warn, error};
|
use log::{info, warn, error};
|
||||||
use std::{fs, path::Path};
|
use std::{fs, path::Path};
|
||||||
|
|
@ -15,7 +15,7 @@ const CONFIG_PATH: &str = "config_api.json";
|
||||||
const SOCKET_PATH: &str = "api-grub.sock";
|
const SOCKET_PATH: &str = "api-grub.sock";
|
||||||
|
|
||||||
// todo! rewrite to use current_exe
|
// todo! rewrite to use current_exe
|
||||||
pub async fn pull_local_config() -> Result<ApiConfig> {
|
pub async fn pull_local_config() -> Result<ApiConfigV2> {
|
||||||
// let conf_path = std::env::current_exe()?;
|
// let conf_path = std::env::current_exe()?;
|
||||||
let path = Path::new(CONFIG_PATH);
|
let path = Path::new(CONFIG_PATH);
|
||||||
// return match conf_path.parent() {
|
// return match conf_path.parent() {
|
||||||
|
|
@ -28,7 +28,7 @@ pub async fn pull_local_config() -> Result<ApiConfig> {
|
||||||
// None => Err(Error::msg("No local conf was found"))
|
// None => Err(Error::msg("No local conf was found"))
|
||||||
// }
|
// }
|
||||||
if path.exists() && path.is_file() {
|
if path.exists() && path.is_file() {
|
||||||
let config: ApiConfig = from_str(
|
let config: ApiConfigV2 = from_str(
|
||||||
&fs::read_to_string(CONFIG_PATH)?
|
&fs::read_to_string(CONFIG_PATH)?
|
||||||
)?;
|
)?;
|
||||||
Ok(config)
|
Ok(config)
|
||||||
|
|
@ -39,7 +39,7 @@ pub async fn pull_local_config() -> Result<ApiConfig> {
|
||||||
|
|
||||||
// for config pulling
|
// for config pulling
|
||||||
// ++++ reader to channel
|
// ++++ reader to channel
|
||||||
pub async fn init_config_grub_mechanism(tx: &Sender<ApiConfig>) -> Result<()> {
|
pub async fn init_config_grub_mechanism(tx: &Sender<ApiConfigV2>) -> Result<()> {
|
||||||
info!("Initializing Unix-Socket listening for pulling new configs...");
|
info!("Initializing Unix-Socket listening for pulling new configs...");
|
||||||
let server = init_unix_listener().await?;
|
let server = init_unix_listener().await?;
|
||||||
//
|
//
|
||||||
|
|
@ -51,7 +51,7 @@ pub async fn init_config_grub_mechanism(tx: &Sender<ApiConfig>) -> Result<()> {
|
||||||
if let Err(er) = stream.read_to_string(&mut buffer).await {
|
if let Err(er) = stream.read_to_string(&mut buffer).await {
|
||||||
warn!("Cannot read config from stream due to {}", er);
|
warn!("Cannot read config from stream due to {}", er);
|
||||||
} else {
|
} else {
|
||||||
let config: Result<ApiConfig, serde_json::Error> = from_str(&buffer);
|
let config: Result<ApiConfigV2, serde_json::Error> = from_str(&buffer);
|
||||||
if let stdOk(conf) = config {
|
if let stdOk(conf) = config {
|
||||||
info!("New config was pulled from Unix-Stream. Saving it locally and sharing with API-grub module...");
|
info!("New config was pulled from Unix-Stream. Saving it locally and sharing with API-grub module...");
|
||||||
if let Err(er) = save_new_config(&buffer).await {
|
if let Err(er) = save_new_config(&buffer).await {
|
||||||
|
|
@ -97,13 +97,13 @@ mod config_unittests {
|
||||||
#[test]
|
#[test]
|
||||||
async fn check_save_new_config() {
|
async fn check_save_new_config() {
|
||||||
use std::fs;
|
use std::fs;
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::ApiConfigV2;
|
||||||
use serde_json::to_string;
|
use serde_json::to_string;
|
||||||
|
|
||||||
let test_config_path = "test_config_api.json";
|
let test_config_path = "test_config_api.json";
|
||||||
|
|
||||||
// config gen
|
// config gen
|
||||||
let config = to_string::<ApiConfig>(&ApiConfig::default());
|
let config = to_string::<ApiConfigV2>(&ApiConfigV2::default());
|
||||||
assert!(config.is_ok());
|
assert!(config.is_ok());
|
||||||
let config = config.unwrap();
|
let config = config.unwrap();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -3,7 +3,7 @@ mod net;
|
||||||
mod logger;
|
mod logger;
|
||||||
|
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::ApiConfigV2;
|
||||||
use logger::setup_logger;
|
use logger::setup_logger;
|
||||||
use log::{info, warn};
|
use log::{info, warn};
|
||||||
use config::{pull_local_config, init_config_grub_mechanism};
|
use config::{pull_local_config, init_config_grub_mechanism};
|
||||||
|
|
@ -19,7 +19,7 @@ async fn main() -> Result<()>{
|
||||||
setup_logger().await?;
|
setup_logger().await?;
|
||||||
let config = get_config().await;
|
let config = get_config().await;
|
||||||
// config update channel
|
// config update channel
|
||||||
let (tx, mut rx) = mpsc::channel::<ApiConfig>(1);
|
let (tx, mut rx) = mpsc::channel::<ApiConfigV2>(1);
|
||||||
// futures
|
// futures
|
||||||
// todo : rewrite with spawn
|
// todo : rewrite with spawn
|
||||||
let config_fut = init_config_grub_mechanism(&tx);
|
let config_fut = init_config_grub_mechanism(&tx);
|
||||||
|
|
@ -30,7 +30,7 @@ async fn main() -> Result<()>{
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn get_config() -> ApiConfig {
|
async fn get_config() -> ApiConfigV2 {
|
||||||
return match pull_local_config().await {
|
return match pull_local_config().await {
|
||||||
Ok(conf) => {
|
Ok(conf) => {
|
||||||
info!("Local config was loaded");
|
info!("Local config was loaded");
|
||||||
|
|
@ -38,7 +38,7 @@ async fn get_config() -> ApiConfig {
|
||||||
},
|
},
|
||||||
Err(er) => {
|
Err(er) => {
|
||||||
warn!("Cannot get local config due to {}", er);
|
warn!("Cannot get local config due to {}", er);
|
||||||
ApiConfig::default()
|
ApiConfigV2::default()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
// module to handle unix-socket connection + pulling info from api
|
// module to handle unix-socket connection + pulling info from api
|
||||||
use anyhow::{Error, Result};
|
use anyhow::{Error, Result};
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::{ApiConfig, ApiConfigV2, Template};
|
||||||
use log::{error, info};
|
use log::{error, info};
|
||||||
use tokio::sync::mpsc::Receiver;
|
use tokio::sync::mpsc::Receiver;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
|
|
@ -15,33 +15,37 @@ impl RestMethod {
|
||||||
"patch" => Method::PATCH,
|
"patch" => Method::PATCH,
|
||||||
"put" => Method::PUT,
|
"put" => Method::PUT,
|
||||||
"delete" => Method::DELETE,
|
"delete" => Method::DELETE,
|
||||||
|
"head" => Method::HEAD,
|
||||||
|
"trace" => Method::TRACE,
|
||||||
|
"options" => Method::OPTIONS,
|
||||||
|
"connect" => Method::CONNECT,
|
||||||
"get" | _ => Method::GET
|
"get" | _ => Method::GET
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
struct ApiPoll<'a> {
|
struct ApiPoll<'a> {
|
||||||
config : &'a mut ApiConfig,
|
config : &'a mut ApiConfigV2,
|
||||||
client : Client,
|
client : Client,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl<'a> ApiPoll<'a> {
|
impl<'a> ApiPoll<'a> {
|
||||||
pub async fn new(poll_cfg : &'a mut ApiConfig) -> Self {
|
pub async fn new(poll_cfg : &'a mut ApiConfigV2) -> Self {
|
||||||
Self {
|
Self {
|
||||||
config : poll_cfg,
|
config : poll_cfg,
|
||||||
client : Client::new(),
|
client : Client::new(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// can be weak and with bug test needed
|
// can be weak and with bug test needed
|
||||||
pub async fn change_config(&mut self, conf: ApiConfig) {
|
pub async fn change_config(&mut self, conf: ApiConfigV2) {
|
||||||
*self.config = conf;
|
*self.config = conf;
|
||||||
}
|
}
|
||||||
pub async fn is_default(&self) -> bool {
|
pub async fn is_default(&self) -> bool {
|
||||||
self.config.endpoints.len() == 0
|
self.config.template.len() == 0
|
||||||
}
|
}
|
||||||
pub async fn process_polling(&self) -> Result<Vec<String>> {
|
pub async fn process_polling(&self) -> Result<Vec<String>> {
|
||||||
let mut buffer: Vec<String> = vec![];
|
let mut buffer: Vec<String> = vec![];
|
||||||
// TODO: rewrite nextly to async
|
// TODO: rewrite nextly to async
|
||||||
for point in &self.config.endpoints {
|
for point in &self.config.template {
|
||||||
// let a = self.client.get(&point.url).send().await.unwrap();
|
// let a = self.client.get(&point.url).send().await.unwrap();
|
||||||
// a.text().await.unwrap();
|
// a.text().await.unwrap();
|
||||||
match self.client.request(RestMethod::from_str(&point.method).await, &point.url).send().await {
|
match self.client.request(RestMethod::from_str(&point.method).await, &point.url).send().await {
|
||||||
|
|
@ -51,14 +55,13 @@ impl<'a> ApiPoll<'a> {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if let Ok(text) = resp.text().await {
|
if let Ok(text) = resp.text().await {
|
||||||
info!("{}: {} - Successfull grubbing info", &point.method.to_uppercase(), &point.url);
|
|
||||||
buffer.push(text);
|
buffer.push(text);
|
||||||
} else {
|
} else {
|
||||||
error!("{}: {} - Error with extracting text field from Response", &point.method.to_uppercase(), &point.url);
|
error!("{}: {} - Error with extracting text field from Response", &point.method.to_uppercase(), &point.url);
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
Err(er) => {
|
Err(er) => {
|
||||||
error!("{}: {} - Query crushed due to {}", &point.method.to_uppercase(), &point.url, er);
|
error!("{}: {} endpoint is unreachable", &point.method.to_uppercase(), &point.url);
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -68,12 +71,12 @@ impl<'a> ApiPoll<'a> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
pub async fn get_delay(&self) -> u32 {
|
pub async fn get_delay(&self) -> u32 {
|
||||||
self.config.delay
|
self.config.timeout
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// for api info pulling
|
// for api info pulling
|
||||||
pub async fn init_api_grub_mechanism(config: ApiConfig, rx: &mut Receiver<ApiConfig>) -> Result<()> {
|
pub async fn init_api_grub_mechanism(config: ApiConfigV2, rx: &mut Receiver<ApiConfigV2>) -> Result<()> {
|
||||||
info!("Initializing API-info grubbing mechanism...");
|
info!("Initializing API-info grubbing mechanism...");
|
||||||
let mut config = config;
|
let mut config = config;
|
||||||
let mut poller = ApiPoll::new(&mut config).await;
|
let mut poller = ApiPoll::new(&mut config).await;
|
||||||
|
|
@ -111,16 +114,16 @@ mod net_unittests {
|
||||||
}
|
}
|
||||||
#[test]
|
#[test]
|
||||||
async fn check_api_poll_change_config() {
|
async fn check_api_poll_change_config() {
|
||||||
let mut conf1 = ApiConfig::default();
|
let mut conf1 = ApiConfigV2::default();
|
||||||
let conf2 = ApiConfig { endpoints : vec![], delay : 10, };
|
let conf2 = ApiConfigV2::pattern();
|
||||||
let mut poll = ApiPoll::new(&mut conf1).await;
|
let mut poll = ApiPoll::new(&mut conf1).await;
|
||||||
poll.change_config(conf2).await;
|
poll.change_config(conf2).await;
|
||||||
assert_eq!(poll.config.delay, 10)
|
assert_eq!(poll.config.timeout, 1)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test]
|
#[test]
|
||||||
async fn check_api_poll_is_default() {
|
async fn check_api_poll_is_default() {
|
||||||
let mut conf1 = ApiConfig::default();
|
let mut conf1 = ApiConfigV2::default();
|
||||||
let poll = ApiPoll::new(&mut conf1).await;
|
let poll = ApiPoll::new(&mut conf1).await;
|
||||||
assert!(poll.is_default().await)
|
assert!(poll.is_default().await)
|
||||||
}
|
}
|
||||||
|
|
@ -130,15 +133,8 @@ mod net_unittests {
|
||||||
use log::{set_max_level, LevelFilter};
|
use log::{set_max_level, LevelFilter};
|
||||||
|
|
||||||
set_max_level(LevelFilter::Off);
|
set_max_level(LevelFilter::Off);
|
||||||
let mut conf1 = ApiConfig {
|
let mut conf1 = ApiConfigV2::pattern();
|
||||||
endpoints : vec![
|
let conf2 = ApiConfigV2::default();
|
||||||
ApiEndpoint {
|
|
||||||
url : String::from("https://dummy-json.mock.beeceptor.com/countries"),
|
|
||||||
method: String::from("get"),
|
|
||||||
}],
|
|
||||||
delay : 10,
|
|
||||||
};
|
|
||||||
let conf2 = ApiConfig::default();
|
|
||||||
|
|
||||||
let mut poll = ApiPoll::new(&mut conf1).await;
|
let mut poll = ApiPoll::new(&mut conf1).await;
|
||||||
assert!(poll.process_polling().await.is_ok());
|
assert!(poll.process_polling().await.is_ok());
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@
|
||||||
// using Unix-Socket Client
|
// using Unix-Socket Client
|
||||||
|
|
||||||
use anyhow::{Error, Result};
|
use anyhow::{Error, Result};
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::ApiConfigV2;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
use tokio::net::UnixStream;
|
use tokio::net::UnixStream;
|
||||||
use std::env;
|
use std::env;
|
||||||
|
|
@ -18,7 +18,7 @@ enum UnixSocketConsumer {
|
||||||
// to create us-client
|
// to create us-client
|
||||||
struct UnixSocketClient;
|
struct UnixSocketClient;
|
||||||
// to catch new configs from integr submod
|
// to catch new configs from integr submod
|
||||||
type ConfigGateway = Receiver<ApiConfig>;
|
type ConfigGateway = Receiver<ApiConfigV2>;
|
||||||
|
|
||||||
pub async fn init_delivery_mech(rx: ConfigGateway) -> Result<()> {
|
pub async fn init_delivery_mech(rx: ConfigGateway) -> Result<()> {
|
||||||
let mut rx = rx;
|
let mut rx = rx;
|
||||||
|
|
|
||||||
|
|
@ -1,18 +1,18 @@
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
|
|
||||||
use tokio::sync::mpsc::Sender;
|
use tokio::sync::mpsc::Sender;
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::ApiConfigV2;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
use tokio::time::{sleep, Duration};
|
use tokio::time::{sleep, Duration};
|
||||||
// mock
|
// mock
|
||||||
|
|
||||||
type Worker = Arc<Sender<ApiConfig>>;
|
type Worker = Arc<Sender<ApiConfigV2>>;
|
||||||
|
|
||||||
#[allow(dead_code, unused_variables)]
|
#[allow(dead_code, unused_variables)]
|
||||||
pub async fn init_integration_mech(tx: Worker) -> Result<()> {
|
pub async fn init_integration_mech(tx: Worker) -> Result<()> {
|
||||||
loop {
|
loop {
|
||||||
sleep(Duration::from_secs(5)).await;
|
sleep(Duration::from_secs(5)).await;
|
||||||
let conf = ApiConfig::default();
|
let conf = ApiConfigV2::default();
|
||||||
tx.send(conf).await?;
|
tx.send(conf).await?;
|
||||||
}
|
}
|
||||||
// Ok(())
|
// Ok(())
|
||||||
|
|
|
||||||
|
|
@ -2,7 +2,7 @@ mod delivery;
|
||||||
mod integration;
|
mod integration;
|
||||||
mod logger;
|
mod logger;
|
||||||
|
|
||||||
use integr_structs::api::ApiConfig;
|
use integr_structs::api::ApiConfigV2;
|
||||||
use logger::setup_logger;
|
use logger::setup_logger;
|
||||||
use dotenv::dotenv;
|
use dotenv::dotenv;
|
||||||
use anyhow::Result;
|
use anyhow::Result;
|
||||||
|
|
@ -23,7 +23,7 @@ async fn main() -> Result<()> {
|
||||||
info!("Pulling env vars from .env file if exists ...");
|
info!("Pulling env vars from .env file if exists ...");
|
||||||
dotenv().ok();
|
dotenv().ok();
|
||||||
|
|
||||||
let (tx, rx) = mpsc::channel::<ApiConfig>(1);
|
let (tx, rx) = mpsc::channel::<ApiConfigV2>(1);
|
||||||
let tx = Arc::new(tx);
|
let tx = Arc::new(tx);
|
||||||
let integr_jh = tokio::spawn(
|
let integr_jh = tokio::spawn(
|
||||||
async move {
|
async move {
|
||||||
|
|
|
||||||
|
|
@ -29,24 +29,87 @@ impl Default for ApiConfig {
|
||||||
// v2
|
// v2
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct ApiConfigV2 {
|
pub struct ApiConfigV2 {
|
||||||
id : u64,
|
pub id : u64,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
template : Vec<Template>,
|
pub template : Vec<Template>,
|
||||||
ip_address : String,
|
pub ip_address : String,
|
||||||
login : Option<String>,
|
pub login : Option<String>,
|
||||||
pass : Option<String>,
|
pub pass : Option<String>,
|
||||||
api_key : Option<String>,
|
pub api_key : Option<String>,
|
||||||
period : u32, // if "0" -> inf
|
pub period : u32, // if "0" -> inf
|
||||||
timeout : u32, // if "0" -> no-delay
|
pub timeout : u32, // if "0" -> no-delay
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl Default for ApiConfigV2 {
|
||||||
|
fn default() -> Self {
|
||||||
|
ApiConfigV2 {
|
||||||
|
id : 0,
|
||||||
|
template : Vec::new(),
|
||||||
|
ip_address : String::from("no_ip"),
|
||||||
|
login : None,
|
||||||
|
pass : None,
|
||||||
|
api_key : None,
|
||||||
|
period : 0,
|
||||||
|
timeout : 0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
impl ApiConfigV2 {
|
||||||
|
pub fn template() -> Self {
|
||||||
|
ApiConfigV2 {
|
||||||
|
id : 1111,
|
||||||
|
template : Vec::new(),
|
||||||
|
ip_address : String::from("ip"),
|
||||||
|
login : None,
|
||||||
|
pass : None,
|
||||||
|
api_key : None,
|
||||||
|
period : 1111,
|
||||||
|
timeout : 1111,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
pub fn pattern() -> Self {
|
||||||
|
ApiConfigV2 {
|
||||||
|
id : 1111,
|
||||||
|
template : vec![
|
||||||
|
Template {
|
||||||
|
id : String::from("no id"),
|
||||||
|
name : String::from("open api"),
|
||||||
|
url : String::from("https://dummy-json.mock.beeceptor.com/countries"),
|
||||||
|
method : String::from("GET"),
|
||||||
|
measure : Vec::new(),
|
||||||
|
}
|
||||||
|
],
|
||||||
|
ip_address : String::from("ip"),
|
||||||
|
login : None,
|
||||||
|
pass : None,
|
||||||
|
api_key : None,
|
||||||
|
period : 1,
|
||||||
|
timeout : 1,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
pub struct Template {
|
pub struct Template {
|
||||||
id : String,
|
pub id : String,
|
||||||
name : String,
|
pub name : String,
|
||||||
url : String,
|
pub url : String,
|
||||||
|
pub method : String,
|
||||||
#[serde(default)]
|
#[serde(default)]
|
||||||
measure : Vec<String>,
|
pub measure : Vec<String>,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for Template {
|
||||||
|
fn default() -> Self {
|
||||||
|
Template {
|
||||||
|
id : String::from("no-id"),
|
||||||
|
name : String::from("no-name"),
|
||||||
|
url : String::from("no-url"),
|
||||||
|
method : String::from("no-method"),
|
||||||
|
measure : Vec::new(),
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Serialize, Deserialize, Debug)]
|
#[derive(Serialize, Deserialize, Debug)]
|
||||||
|
|
|
||||||
|
|
@ -2,20 +2,30 @@
|
||||||
"id" : 1 ,
|
"id" : 1 ,
|
||||||
"template" :
|
"template" :
|
||||||
[{
|
[{
|
||||||
"id" :"conference",
|
"id" :"mock_api_1",
|
||||||
"name" : "Conference",
|
"name" : "Mock / ",
|
||||||
"url" : "https://$ip_address/api/v1/conferences",
|
"url" : "http://127.0.0.1:8081/",
|
||||||
|
"method" : "GET",
|
||||||
"measure" :
|
"measure" :
|
||||||
[
|
[
|
||||||
"total", "number", "description",
|
"operation", "response", "empty_field"
|
||||||
"shutdown", "startTime", "stopTime",
|
|
||||||
"participants_total", "participants_online"
|
|
||||||
]
|
]
|
||||||
}],
|
},
|
||||||
|
{
|
||||||
|
"id" :"mock_api_2",
|
||||||
|
"name" : "Mock /ping ",
|
||||||
|
"url" : "http://127.0.0.1:8081/ping",
|
||||||
|
"method" : "GET",
|
||||||
|
"measure" :
|
||||||
|
[
|
||||||
|
"operation", "response", "empty_field"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
"ip_address" : "127.0.0.1:8081",
|
"ip_address" : "127.0.0.1:8081",
|
||||||
"login" : "",
|
"login" : "",
|
||||||
"pass" : "" ,
|
"pass" : "" ,
|
||||||
"api_key" : "908c709827bd40n98r7209837x98273",
|
"api_key" : "908c709827bd40n98r7209837x98273",
|
||||||
"period" : "10",
|
"period" : 10,
|
||||||
"timeout" : "2"
|
"timeout" : 2
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue