Compare commits
2 Commits
f08b37cb7d
...
71b1d3411d
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
71b1d3411d | ||
|
|
e9e67358c4 |
12
Cargo.lock
generated
12
Cargo.lock
generated
@ -152,6 +152,7 @@ dependencies = [
|
|||||||
"simplelog",
|
"simplelog",
|
||||||
"thiserror",
|
"thiserror",
|
||||||
"tokio",
|
"tokio",
|
||||||
|
"uuid",
|
||||||
]
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
@ -1884,6 +1885,17 @@ version = "1.0.4"
|
|||||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
checksum = "b6c140620e7ffbb22c2dee59cafe6084a59b5ffc27a8859a5f0d494b5d52b6be"
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "uuid"
|
||||||
|
version = "1.21.0"
|
||||||
|
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||||
|
checksum = "b672338555252d43fd2240c714dc444b8c6fb0a5c5335e65a07bba7742735ddb"
|
||||||
|
dependencies = [
|
||||||
|
"js-sys",
|
||||||
|
"serde_core",
|
||||||
|
"wasm-bindgen",
|
||||||
|
]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "uuid-simd"
|
name = "uuid-simd"
|
||||||
version = "0.8.0"
|
version = "0.8.0"
|
||||||
|
|||||||
@ -19,6 +19,7 @@ serde_json = "1.0.145"
|
|||||||
simplelog = "0.12.2"
|
simplelog = "0.12.2"
|
||||||
thiserror = "2.0.17"
|
thiserror = "2.0.17"
|
||||||
tokio = { version = "1.48.0", features = ["full"] }
|
tokio = { version = "1.48.0", features = ["full"] }
|
||||||
|
uuid = { version = "1.21.0", features = ["serde"] }
|
||||||
|
|
||||||
[features]
|
[features]
|
||||||
schemars = ["dep:schemars"]
|
schemars = ["dep:schemars"]
|
||||||
|
|||||||
@ -1,20 +1,72 @@
|
|||||||
|
use std::fmt::Display;
|
||||||
|
|
||||||
|
use chrono::{DateTime, Utc};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
use uuid::Uuid;
|
||||||
|
|
||||||
use crate::{ApiClient, Client, Result};
|
use crate::{ApiClient, Client, Result};
|
||||||
|
use crate::api::{DomainCollection, DomainExtension, DomainObject, domain_client, domain_read};
|
||||||
|
|
||||||
|
domain_client!(ActivationStatus, activation_api);
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
pub struct ChangeActivation;
|
pub struct ActivationStatus {
|
||||||
|
sites: Vec<String>,
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
is_running: bool,
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
force_foreign_changes: bool,
|
||||||
pub struct PendingChange;
|
time_started: DateTime<Utc>,
|
||||||
|
changes: Vec<PendingChange>,
|
||||||
impl From<&Client> for ApiClient<ChangeActivation> {
|
#[serde(default)]
|
||||||
fn from(value: &Client) -> Self {
|
status_per_site: Vec<SiteStatus>
|
||||||
Self::new(value)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl DomainExtension for ActivationStatus {
|
||||||
|
const DOMAIN_TYPE: super::DomainType = super::DomainType::ActivationRun;
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
|
pub struct PendingChange {
|
||||||
|
id: Uuid,
|
||||||
|
user_id: Option<String>,
|
||||||
|
action_name: String,
|
||||||
|
text: String,
|
||||||
|
time: DateTime<Utc>,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
|
pub struct SiteStatus {
|
||||||
|
site: String,
|
||||||
|
phase: ChangePhase,
|
||||||
|
state: ChangeState,
|
||||||
|
status_text: String,
|
||||||
|
status_details: String,
|
||||||
|
start_time: DateTime<Utc>,
|
||||||
|
end_time: DateTime<Utc>
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum ChangePhase {
|
||||||
|
Initialized,
|
||||||
|
Queued,
|
||||||
|
Started,
|
||||||
|
Sync,
|
||||||
|
Activate,
|
||||||
|
Finishing,
|
||||||
|
Done
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
|
#[serde(rename_all = "snake_case")]
|
||||||
|
pub enum ChangeState {
|
||||||
|
Success,
|
||||||
|
Error,
|
||||||
|
Warning
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
@ -25,20 +77,119 @@ pub struct ActivateChangeRequest {
|
|||||||
force_foreign_changes: bool
|
force_foreign_changes: bool
|
||||||
}
|
}
|
||||||
|
|
||||||
impl ApiClient<ChangeActivation> {
|
#[derive(Debug, Default, Clone, Serialize, Deserialize)]
|
||||||
pub async fn activate(&self) -> Result<()> {
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
todo!()
|
pub struct ActivationOptions {
|
||||||
|
redirect: bool,
|
||||||
|
sites: Vec<String>,
|
||||||
|
force_foreign_changes: bool
|
||||||
}
|
}
|
||||||
pub async fn await_activation(&self, activation_id: &str) -> Result<()> {
|
|
||||||
todo!()
|
impl ActivationOptions {
|
||||||
|
pub fn set_redirect(&mut self, redirect: bool) {
|
||||||
|
self.redirect = redirect
|
||||||
}
|
}
|
||||||
pub async fn read_current_activations(&self) -> Result<Vec<ChangeActivation>> {
|
pub fn with_redirect(mut self, redirect: bool) -> Self {
|
||||||
todo!()
|
self.set_redirect(redirect);
|
||||||
|
self
|
||||||
}
|
}
|
||||||
pub async fn bulk_read_pending_changes(&self) -> Result<Vec<PendingChange>> {
|
pub fn set_force_foreign_changes(&mut self, force: bool) {
|
||||||
todo!()
|
self.force_foreign_changes = force;
|
||||||
}
|
}
|
||||||
pub async fn read_activation_status(&self, activation_id: &str) -> Result<ChangeActivation> {
|
pub fn with_force_foreign_changes(mut self, force: bool) -> Self {
|
||||||
todo!()
|
self.set_force_foreign_changes(force);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
|
||||||
|
pub fn set_sites(&mut self, sites: Vec<String>) {
|
||||||
|
self.sites = sites;
|
||||||
|
}
|
||||||
|
pub fn with_sites(mut self, sites: Vec<String>) -> Self {
|
||||||
|
self.set_sites(sites);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
pub fn set_site(&mut self, site: String) {
|
||||||
|
self.sites.push(site);
|
||||||
|
}
|
||||||
|
pub fn with_site(mut self, site: String) -> Self {
|
||||||
|
self.set_site(site);
|
||||||
|
self
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
domain_read!(ActivationStatus);
|
||||||
|
|
||||||
|
impl ApiClient<ActivationStatus> {
|
||||||
|
pub async fn activate_pending_changes(
|
||||||
|
&self,
|
||||||
|
options: &ActivationOptions
|
||||||
|
) -> Result<String> {
|
||||||
|
let etag = {
|
||||||
|
let url = format!("{}/pending_changes", self.collection_root());
|
||||||
|
self.inner.get_etag(&url).await
|
||||||
|
}?;
|
||||||
|
let url = format!(
|
||||||
|
"{}/domain-types/{}/actions/activate-changes/invoke",
|
||||||
|
self.inner.url, ActivationStatus::DOMAIN_TYPE
|
||||||
|
);
|
||||||
|
|
||||||
|
let request = self.inner.http
|
||||||
|
.post(url)
|
||||||
|
.json(&options)
|
||||||
|
.header(reqwest::header::IF_MATCH, etag)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let response: DomainObject<ActivationStatus> =
|
||||||
|
self.inner.query_api(request).await?;
|
||||||
|
Ok(response.id)
|
||||||
|
}
|
||||||
|
pub async fn await_completion(&self, activation_id: impl Display) -> Result<()> {
|
||||||
|
let url = format!(
|
||||||
|
"{}/objects/{}/{}/actions/wait-for-completion/invoke",
|
||||||
|
self.inner.url, ActivationStatus::DOMAIN_TYPE, activation_id
|
||||||
|
);
|
||||||
|
|
||||||
|
let request = self.inner.http
|
||||||
|
.get(url)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
self.inner.invoke_api(request).await
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn collection_root(&self) -> String {
|
||||||
|
format!(
|
||||||
|
"{}/domain-types/{}/collections",
|
||||||
|
self.inner.url, ActivationStatus::DOMAIN_TYPE
|
||||||
|
)
|
||||||
|
}
|
||||||
|
pub async fn read_running_activations(&self) -> Result<Vec<ActivationStatus>> {
|
||||||
|
let url = format!("{}/running", self.collection_root());
|
||||||
|
|
||||||
|
let request = self.inner.http
|
||||||
|
.get(url)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
let collection: DomainCollection<_> = self.inner.query_api(request).await?;
|
||||||
|
Ok(collection.into())
|
||||||
|
}
|
||||||
|
pub async fn read_pending_changes(&self) -> Result<Vec<PendingChange>> {
|
||||||
|
let url = format!("{}/pending_changes", self.collection_root());
|
||||||
|
|
||||||
|
let request = self.inner.http
|
||||||
|
.get(url)
|
||||||
|
.build()
|
||||||
|
.unwrap();
|
||||||
|
|
||||||
|
#[derive(Deserialize)]
|
||||||
|
struct ChangeCollection {
|
||||||
|
value: Vec<PendingChange>
|
||||||
|
}
|
||||||
|
|
||||||
|
let collection: ChangeCollection = self.inner.query_api(request).await?;
|
||||||
|
Ok(collection.value)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -5,24 +5,10 @@ use serde::{Deserialize, Serialize};
|
|||||||
use schemars::JsonSchema;
|
use schemars::JsonSchema;
|
||||||
|
|
||||||
use crate::api::{
|
use crate::api::{
|
||||||
DomainObject, DomainType
|
DomainCollection, DomainObject, DomainType, domain_client
|
||||||
};
|
};
|
||||||
use crate::{ApiClient, Client, Result};
|
use crate::{ApiClient, Client, Result};
|
||||||
|
|
||||||
impl Client {
|
|
||||||
pub fn host_group_api(&self) -> ApiClient<HostGroup> {
|
|
||||||
self.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn service_group_api(&self) -> ApiClient<ServiceGroup> {
|
|
||||||
self.into()
|
|
||||||
}
|
|
||||||
|
|
||||||
pub fn contact_group_api(&self) -> ApiClient<ContactGroup> {
|
|
||||||
self.into()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
pub struct Group {
|
pub struct Group {
|
||||||
@ -44,10 +30,11 @@ impl From<DomainObject<serde_json::Value>> for Group {
|
|||||||
|
|
||||||
|
|
||||||
macro_rules! domain_group {
|
macro_rules! domain_group {
|
||||||
($id:ident, $typ:expr) => {
|
($id:ident, $typ:expr, $func:ident) => {
|
||||||
#[derive(Debug, Clone, Serialize, Deserialize)]
|
#[derive(Debug, Clone, Serialize, Deserialize)]
|
||||||
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
#[cfg_attr(feature = "schemars", derive(JsonSchema))]
|
||||||
pub struct $id(Group);
|
pub struct $id(Group);
|
||||||
|
domain_client!($id, $func);
|
||||||
|
|
||||||
impl Deref for $id {
|
impl Deref for $id {
|
||||||
type Target = Group;
|
type Target = Group;
|
||||||
@ -69,12 +56,6 @@ macro_rules! domain_group {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl From<&Client> for ApiClient<$id> {
|
|
||||||
fn from(value: &Client) -> Self {
|
|
||||||
Self::new(value)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
impl ApiClient<$id> {
|
impl ApiClient<$id> {
|
||||||
pub async fn create(&self, group: &$id) -> Result<()> {
|
pub async fn create(&self, group: &$id) -> Result<()> {
|
||||||
self.inner.create($typ, group, &()).await
|
self.inner.create($typ, group, &()).await
|
||||||
@ -100,12 +81,13 @@ macro_rules! domain_group {
|
|||||||
self.inner.bulk_create($typ, entries, &()).await
|
self.inner.bulk_create($typ, entries, &()).await
|
||||||
}
|
}
|
||||||
pub async fn bulk_read(&self) -> Result<Vec<$id>> {
|
pub async fn bulk_read(&self) -> Result<Vec<$id>> {
|
||||||
let entries: Vec<DomainObject<serde_json::Value>> =
|
let collection: DomainCollection<serde_json::Value> =
|
||||||
self.inner.bulk_read($typ, &()).await?;
|
self.inner.bulk_read($typ, &()).await?;
|
||||||
let objects = entries.into_iter()
|
let groups = collection.value
|
||||||
|
.into_iter()
|
||||||
.map($id::from)
|
.map($id::from)
|
||||||
.collect();
|
.collect();
|
||||||
Ok(objects)
|
Ok(groups)
|
||||||
}
|
}
|
||||||
pub async fn bulk_update(&self, entries: &[Group]) -> Result<()> {
|
pub async fn bulk_update(&self, entries: &[Group]) -> Result<()> {
|
||||||
#[derive(Serialize)]
|
#[derive(Serialize)]
|
||||||
@ -140,6 +122,6 @@ macro_rules! domain_group {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
domain_group!(HostGroup, DomainType::HostGroupConfig);
|
domain_group!(HostGroup, DomainType::HostGroupConfig, host_group_api);
|
||||||
domain_group!(ServiceGroup, DomainType::ServiceGroupConfig);
|
domain_group!(ServiceGroup, DomainType::ServiceGroupConfig, service_group_api);
|
||||||
domain_group!(ContactGroup, DomainType::ContactGroupConfig);
|
domain_group!(ContactGroup, DomainType::ContactGroupConfig, contact_group_api);
|
||||||
|
|||||||
@ -21,7 +21,8 @@ pub enum DomainType {
|
|||||||
ContactGroupConfig,
|
ContactGroupConfig,
|
||||||
HostGroupConfig,
|
HostGroupConfig,
|
||||||
ServiceGroupConfig,
|
ServiceGroupConfig,
|
||||||
HostTagGroup
|
HostTagGroup,
|
||||||
|
ActivationRun,
|
||||||
}
|
}
|
||||||
|
|
||||||
impl fmt::Display for DomainType {
|
impl fmt::Display for DomainType {
|
||||||
@ -34,6 +35,7 @@ impl fmt::Display for DomainType {
|
|||||||
DomainType::HostGroupConfig => write!(f, "host_group_config"),
|
DomainType::HostGroupConfig => write!(f, "host_group_config"),
|
||||||
DomainType::ServiceGroupConfig => write!(f, "service_group_config"),
|
DomainType::ServiceGroupConfig => write!(f, "service_group_config"),
|
||||||
DomainType::HostTagGroup => write!(f, "host_tag_group"),
|
DomainType::HostTagGroup => write!(f, "host_tag_group"),
|
||||||
|
DomainType::ActivationRun => write!(f, "activation_run")
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -89,6 +91,15 @@ pub(crate) struct DomainCollection<E> {
|
|||||||
// pub extensions: Option<E>,
|
// pub extensions: Option<E>,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
impl <E> From<DomainCollection<E>> for Vec<E> {
|
||||||
|
fn from(value: DomainCollection<E>) -> Self {
|
||||||
|
value.value
|
||||||
|
.into_iter()
|
||||||
|
.map(|obj| obj.extensions)
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
pub trait DomainExtension: DeserializeOwned + Serialize {
|
pub trait DomainExtension: DeserializeOwned + Serialize {
|
||||||
const DOMAIN_TYPE: DomainType;
|
const DOMAIN_TYPE: DomainType;
|
||||||
}
|
}
|
||||||
@ -155,7 +166,7 @@ impl InnerClient {
|
|||||||
pub(crate) async fn bulk_read_domain_objects<E, Q>(
|
pub(crate) async fn bulk_read_domain_objects<E, Q>(
|
||||||
&self,
|
&self,
|
||||||
query: &Q,
|
query: &Q,
|
||||||
) -> Result<Vec<DomainObject<E>>>
|
) -> Result<DomainCollection<E>>
|
||||||
where
|
where
|
||||||
E: DomainExtension,
|
E: DomainExtension,
|
||||||
Q: Serialize
|
Q: Serialize
|
||||||
@ -293,22 +304,16 @@ macro_rules! domain_bulk_read {
|
|||||||
($id:ident) => {
|
($id:ident) => {
|
||||||
impl ApiClient<$id> {
|
impl ApiClient<$id> {
|
||||||
pub async fn bulk_read(&self) -> Result<Vec<$id>> {
|
pub async fn bulk_read(&self) -> Result<Vec<$id>> {
|
||||||
let objs = self.inner.bulk_read_domain_objects::<$id, _>(&()).await?;
|
let collection = self.inner.bulk_read_domain_objects::<$id, _>(&()).await?;
|
||||||
let objs = objs.into_iter()
|
Ok(collection.into())
|
||||||
.map(|obj| obj.extensions)
|
|
||||||
.collect();
|
|
||||||
Ok(objs)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
($id:ident, $qry:ident) => {
|
($id:ident, $qry:ident) => {
|
||||||
impl ApiClient<$id> {
|
impl ApiClient<$id> {
|
||||||
pub async fn bulk_read(&self, query: &$qry) -> Result<Vec<$id>> {
|
pub async fn bulk_read(&self, query: &$qry) -> Result<Vec<$id>> {
|
||||||
let objs = self.inner.bulk_read_domain_objects::<$id, _>(&query).await?;
|
let collection = self.inner.bulk_read_domain_objects::<$id, _>(&query).await?;
|
||||||
let objs = objs.into_iter()
|
Ok(collection.into())
|
||||||
.map(|obj| obj.extensions)
|
|
||||||
.collect();
|
|
||||||
Ok(objs)
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|||||||
@ -11,7 +11,7 @@ use serde::de::DeserializeOwned;
|
|||||||
use tokio::sync::Semaphore;
|
use tokio::sync::Semaphore;
|
||||||
|
|
||||||
use crate::api::{
|
use crate::api::{
|
||||||
DomainCollection, DomainObject, DomainType,
|
DomainCollection, DomainType,
|
||||||
};
|
};
|
||||||
use crate::{Error, Result};
|
use crate::{Error, Result};
|
||||||
|
|
||||||
@ -400,7 +400,7 @@ impl InnerClient {
|
|||||||
&self,
|
&self,
|
||||||
domain_type: DomainType,
|
domain_type: DomainType,
|
||||||
query: &Q
|
query: &Q
|
||||||
) -> Result<Vec<DomainObject<O>>>
|
) -> Result<DomainCollection<O>>
|
||||||
where
|
where
|
||||||
O: DeserializeOwned,
|
O: DeserializeOwned,
|
||||||
Q: Serialize
|
Q: Serialize
|
||||||
@ -412,8 +412,7 @@ impl InnerClient {
|
|||||||
.build()
|
.build()
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let response: DomainCollection<O> = self.query_api(request).await?;
|
self.query_api(request).await
|
||||||
Ok(response.value)
|
|
||||||
|
|
||||||
}
|
}
|
||||||
pub(crate) async fn bulk_update<O>(
|
pub(crate) async fn bulk_update<O>(
|
||||||
|
|||||||
40
src/main.rs
40
src/main.rs
@ -33,6 +33,7 @@ async fn main() -> Result<()> {
|
|||||||
test_host_groups(client.clone()).await?;
|
test_host_groups(client.clone()).await?;
|
||||||
test_service_groups(client.clone()).await?;
|
test_service_groups(client.clone()).await?;
|
||||||
test_contact_groups(client.clone()).await?;
|
test_contact_groups(client.clone()).await?;
|
||||||
|
test_activations(client.clone()).await?;
|
||||||
|
|
||||||
info!("tests done; all pass");
|
info!("tests done; all pass");
|
||||||
Ok(())
|
Ok(())
|
||||||
@ -324,6 +325,45 @@ async fn test_service_groups(client: Client) -> Result<()> {
|
|||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn test_activations(client: Client) -> Result<()> {
|
||||||
|
use checkmk_api::api::activations::*;
|
||||||
|
info!("testing activations");
|
||||||
|
|
||||||
|
let api = client.activation_api();
|
||||||
|
|
||||||
|
let pending = api
|
||||||
|
.read_pending_changes()
|
||||||
|
.await
|
||||||
|
.inspect_err(|e| error!("failed to read pending changes: {e}"))?;
|
||||||
|
info!("pending changes: {pending:#?}");
|
||||||
|
|
||||||
|
let running = api
|
||||||
|
.read_running_activations()
|
||||||
|
.await
|
||||||
|
.inspect_err(|e| error!("failed to read running activations: {e}"))?;
|
||||||
|
info!("running activations: {running:#?}");
|
||||||
|
|
||||||
|
let options = ActivationOptions::default()
|
||||||
|
.with_redirect(false)
|
||||||
|
.with_force_foreign_changes(false)
|
||||||
|
.with_site(SITENAME.to_string());
|
||||||
|
|
||||||
|
info!("activating pending changes");
|
||||||
|
let activation_id = api
|
||||||
|
.activate_pending_changes(&options)
|
||||||
|
.await
|
||||||
|
.inspect_err(|e| error!("failed to activate pending changes: {e}"))?;
|
||||||
|
info!("activation started with id: {activation_id}");
|
||||||
|
|
||||||
|
info!("waiting for activation {activation_id} to complete");
|
||||||
|
api.await_completion(&activation_id)
|
||||||
|
.await
|
||||||
|
.inspect_err(|e| error!("failed to await activation completion: {e}"))?;
|
||||||
|
info!("activation {activation_id} completed");
|
||||||
|
|
||||||
|
Ok(())
|
||||||
|
}
|
||||||
|
|
||||||
async fn test_contact_groups(client: Client) -> Result<()> {
|
async fn test_contact_groups(client: Client) -> Result<()> {
|
||||||
use checkmk_api::api::groups::*;
|
use checkmk_api::api::groups::*;
|
||||||
const TESTGROUP: &str = "test-contact-group";
|
const TESTGROUP: &str = "test-contact-group";
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user