From 0fe75be43bd1231ba4da0e1e0c144f7af500f4e6 Mon Sep 17 00:00:00 2001 From: prplV Date: Thu, 13 Feb 2025 12:31:52 +0300 Subject: [PATCH] final conf structs and +creds struct to contain refs on existing values --- crates/integr-structs/src/api.rs | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/crates/integr-structs/src/api.rs b/crates/integr-structs/src/api.rs index 4563655..f26850b 100644 --- a/crates/integr-structs/src/api.rs +++ b/crates/integr-structs/src/api.rs @@ -183,6 +183,42 @@ pub mod v3 { config : Vec, } + impl Default for Config { + fn default() -> Self { + Self { + config : Vec::new() + } + } + } + + impl Config { + pub async fn is_default(&self) -> bool { + self.config.is_empty() + } + } + + pub struct Credentials<'a> { + ip : &'a str, + login : &'a str, + password : &'a str, + api_key : &'a str, + period : &'a str, + timeout : &'a str, + } + + impl<'a> Credentials<'a> { + pub fn from_config_endpoint(endpoint: &'a ConfigEndpoint) -> Credentials<'a> { + Self { + ip : &endpoint.ip, + login : &endpoint.login, + password : &endpoint.password, + api_key : &endpoint.api_key, + period : &endpoint.period, + timeout : &endpoint.timeout, + } + } + } + // to prometheus and nmns #[derive(Serialize, Deserialize)] pub struct MetricOutput {