MCPcopy Create free account
hub / github.com/BigBoot/AutoKuma / edit_monitor

Method edit_monitor

kuma-client/src/client.rs:850–883  ·  view source on GitHub ↗
(self: &Arc<Self>, monitor: &mut Monitor, verify: bool)

Source from the content-addressed store, hash-verified

848 }
849
850 pub async fn edit_monitor(self: &Arc<Self>, monitor: &mut Monitor, verify: bool) -> Result<()> {
851 if verify {
852 self.verify_monitor(monitor).await?;
853 }
854
855 let tags = mem::take(monitor.common_mut().tags_mut());
856
857 #[cfg(feature = "private-api")]
858 let create_paused = mem::take(monitor.common_mut().create_paused_mut());
859
860 let mut monitor_json = serde_json::to_value(&monitor).unwrap();
861
862 // Workaround for https://github.com/BigBoot/AutoKuma/issues/72 until fixed in UptimeKuma
863 if let Some(monitor_json) = monitor_json.as_object_mut() {
864 if !monitor_json.contains_key("url") {
865 monitor_json.insert("url".to_owned(), json!("https://"));
866 }
867 }
868
869 let id: i32 = self
870 .call("editMonitor", vec![monitor_json], "/monitorID", true)
871 .await?;
872
873 self.update_monitor_tags(id, &tags).await?;
874
875 *monitor.common_mut().tags_mut() = tags;
876
877 #[cfg(feature = "private-api")]
878 {
879 *monitor.common_mut().create_paused_mut() = create_paused;
880 }
881
882 Ok(())
883 }
884
885 pub async fn pause_monitor(self: &Arc<Self>, monitor_id: i32) -> Result<()> {
886 let _: bool = self

Callers 3

add_monitorMethod · 0.80
update_entityMethod · 0.80
handleFunction · 0.80

Calls 4

verify_monitorMethod · 0.80
update_monitor_tagsMethod · 0.80
common_mutMethod · 0.45
callMethod · 0.45

Tested by

no test coverage detected