This commit is contained in:
kieran 2024-09-23 11:26:19 +01:00
parent 8e3436b473
commit 77f8120a1f
No known key found for this signature in database
GPG Key ID: DE71CEB3925BE941
5 changed files with 1726 additions and 0 deletions

2
.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
/target
.idea/

1678
Cargo.lock generated Normal file

File diff suppressed because it is too large Load Diff

16
Cargo.toml Normal file
View File

@ -0,0 +1,16 @@
[package]
name = "lnvps"
version = "0.1.0"
edition = "2021"
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
[dependencies]
http = "1.1.0"
proxmox-client = { git = "https://github.com/proxmox/proxmox-rs", version = "0.3.1", features = ["hyper-client"] }
proxmox-login = { git = "https://github.com/proxmox/proxmox-rs", version = "0.1.1" }
tokio = { version = "1.37.0", features = ["rt", "rt-multi-thread", "macros"] }
anyhow = "1.0.83"
log = "0.4.21"
config = "0.14.0"
pretty_env_logger = "0.5.0"

View File

@ -0,0 +1,3 @@
server = "10.97.0.234"
token_id = "root@pam!test-dev"
secret = "e2d8d39f-63ce-48f0-a025-b428d29a26e3"

27
src/main.rs Normal file
View File

@ -0,0 +1,27 @@
use std::default;
use log::info;
use proxmox_client::{AuthenticationKind, HttpApiClient, TlsOptions, Token};
#[tokio::main]
async fn main() -> Result<(), anyhow::Error> {
pretty_env_logger::init();
let addr = "https://10.97.0.234:8006/";
let url = addr.parse().unwrap();
let client = proxmox_client::Client::with_options(
url,
TlsOptions::Insecure,
Default::default())?;
client.set_authentication(AuthenticationKind::Token(Token {
userid: "root@pam!test-dev".to_string(),
prefix: "PVEAPIToken".to_string(),
value: "e2d8d39f-63ce-48f0-a025-b428d29a26e3".to_string(),
}));
let rsp = client.get("/api2/json/version").await?;
let string = String::from_utf8(rsp.body)?;
info!("Version: {}", string);
Ok(())
}