Testing None type for policy
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
use serde_json::json;
|
||||
|
||||
use crate::modules::datatypes::*;
|
||||
use crate::prelude::*;
|
||||
|
||||
@@ -5,7 +7,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> {
|
||||
@@ -181,7 +183,10 @@ pub fn pull_policy_exec_histories(
|
||||
.enable_steady_tick(std::time::Duration::from_millis(100));
|
||||
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_default(),
|
||||
));
|
||||
loop {
|
||||
let execution_histories = tracer.in_span(checkpoint_number.to_string(), |cx| {
|
||||
let results: ApiResponse = history_logging(
|
||||
@@ -259,20 +264,17 @@ async fn history_logging(
|
||||
base_url: &String,
|
||||
exec_types: &String,
|
||||
checkpoint_number: &String,
|
||||
policy_names: &String,
|
||||
policy_names: &Option<String>,
|
||||
client: &Client,
|
||||
) -> ApiResponse {
|
||||
let payload = format!(
|
||||
r#"{{
|
||||
"type": {},
|
||||
"checkpoint": "{}",
|
||||
"policy": ["{}"]
|
||||
}}"#,
|
||||
exec_types, checkpoint_number, policy_names
|
||||
);
|
||||
let payload = json!({
|
||||
"type": exec_types,
|
||||
"checkpoint": checkpoint_number,
|
||||
"policy": policy_names.as_ref().map(|p| vec![p]),
|
||||
});
|
||||
let res: Result<reqwest::Response, reqwest::Error> = client
|
||||
.post(format!("{}/v1/logging/exechistories", base_url))
|
||||
.body(payload)
|
||||
.json(&payload)
|
||||
.send()
|
||||
.await;
|
||||
match res {
|
||||
|
||||
Reference in New Issue
Block a user