mirror of
https://github.com/jlengrand/engine.git
synced 2026-03-10 08:11:21 +00:00
34 lines
911 B
Rust
34 lines
911 B
Rust
use serde::{Deserialize, Serialize};
|
|
use std::borrow::Borrow;
|
|
|
|
use crate::cmd::utilities::QoveryCommand;
|
|
|
|
#[derive(Serialize, Deserialize, Debug)]
|
|
pub struct DoVpc {
|
|
id: String,
|
|
urn: String,
|
|
name: String,
|
|
ip_range: String,
|
|
region: String,
|
|
created_at: String,
|
|
default: bool,
|
|
}
|
|
|
|
pub fn get_used_cidr_on_region(token: &str) {
|
|
let mut output_from_cli = String::new();
|
|
|
|
let mut cmd = QoveryCommand::new("doctl", &vec!["vpcs", "list", "--output", "json", "-t", token], &vec![]);
|
|
let _ = cmd.exec_with_output(
|
|
|r_out| output_from_cli.push_str(&r_out),
|
|
|r_err| {
|
|
error!(
|
|
"DOCTL CLI error from cmd inserted, please check vpcs list command{}",
|
|
r_err
|
|
)
|
|
},
|
|
);
|
|
|
|
let buff = output_from_cli.borrow();
|
|
let _array: Vec<DoVpc> = serde_json::from_str(&buff).expect("JSON is not well-formatted");
|
|
}
|