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