Compare commits

...

3 Commits

Author SHA1 Message Date
brotoskyj 5555747422 Styling - Progress Bar
Build Library / Build Library (push) Successful in 4m55s
Changed glyphs in progress bar for better printing to console
closes #51
2025-12-18 12:58:51 -05:00
brotoskyj 729b45f52a Features - Optional Policy Name in Execution Histories
Build Library / Build Library (push) Successful in 4m51s
closes #48
2025-12-18 10:14:58 -05:00
brotoskyj 66bb21ed88 Styling - Progress Bar
Build Library / Build Library (push) Successful in 5m21s
Changed progress bar indicators and added policy name to the progress bar
closes #50
2025-12-17 16:38:53 -05:00
5 changed files with 24 additions and 11 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ dependencies = [
[[package]]
name = "airlock_libs"
version = "6.1.1"
version = "7.1.0"
dependencies = [
"chrono",
"crossbeam",
+1 -1
View File
@@ -1,6 +1,6 @@
[package]
name = "airlock_libs"
version = "6.1.1"
version = "7.1.0"
edition = "2024"
[dependencies]
+1 -1
View File
@@ -4,7 +4,7 @@ build-backend = "maturin"
[project]
name = "airlock_libs"
version = "6.1.1"
version = "7.1.0"
description = "Airlock Digital API Wrapper"
readme = "README.md"
license = { text = "AGPL-3.0-only" }
+20 -7
View File
@@ -5,7 +5,7 @@ use crate::prelude::*;
pub fn pull_policy_exec_histories(
py: Python<'_>,
py_self: Py<PyAny>,
policy_names: String,
policy_names: Option<String>,
exec_types: String,
days: i64,
) -> Py<PyString> {
@@ -73,8 +73,8 @@ pub fn pull_policy_exec_histories(
.set_draw_target(ProgressDrawTarget::stderr());
progress_bar.lock().unwrap().set_style(
ProgressStyle::default_bar()
.template("Total Completion: {spinner:.green} [{elapsed_precise}] [{bar:40.green/blue}] {pos}/{len} {message}")
.unwrap(),
.template("Total - Policy Name: {msg}: {spinner:.green} [{elapsed_precise}] [{bar:40.green/blue}] {pos}/{len}")
.unwrap().progress_chars("⣿⣦⣀")
);
let client: Client = tracer.in_span("Building HTTP Client", |cx| {
let client_result: Result<Client, reqwest::Error> = build_client(headers);
@@ -179,9 +179,18 @@ pub fn pull_policy_exec_histories(
.lock()
.unwrap()
.enable_steady_tick(std::time::Duration::from_millis(100));
pb_clone
.lock()
.unwrap()
.set_message(policy_names.clone().unwrap_or("Statistics".to_string()));
let span: opentelemetry::trace::SpanRef<'_> = cx.span();
span.set_attribute(KeyValue::new("Days", days.to_string()));
span.set_attribute(KeyValue::new("Policy Name", policy_names.clone()));
span.set_attribute(KeyValue::new(
"Policy Name",
policy_names
.clone()
.unwrap_or("Statistics Monitoring".to_string()),
));
loop {
let execution_histories = tracer.in_span(checkpoint_number.to_string(), |cx| {
let results: ApiResponse = history_logging(
@@ -259,16 +268,20 @@ async fn history_logging(
base_url: &String,
exec_types: &String,
checkpoint_number: &String,
policy_names: &String,
policy_names: &Option<String>,
client: &Client,
) -> ApiResponse {
let policy_json = match policy_names {
Some(name) => format!(r#"[ "{}" ]"#, name), // JSON array with one element
None => "[]".to_string(), // Empty JSON array
};
let payload = format!(
r#"{{
"type": {},
"checkpoint": "{}",
"policy": ["{}"]
"policy": {}
}}"#,
exec_types, checkpoint_number, policy_names
exec_types, checkpoint_number, policy_json
);
let res: Result<reqwest::Response, reqwest::Error> = client
.post(format!("{}/v1/logging/exechistories", base_url))
+1 -1
View File
@@ -23,4 +23,4 @@ pyperclip==1.11.0
# Custom/Private packages
--extra-index-url https://git.racooncity.org/api/packages/brotoskyj/pypi/simple/
airlock_libs==6.1.1
airlock_libs==7.1.0