From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <pdm-devel-bounces@lists.proxmox.com> Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) by lore.proxmox.com (Postfix) with ESMTPS id DF6721FF18C for <inbox@lore.proxmox.com>; Mon, 12 May 2025 15:37:52 +0200 (CEST) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 98A0E6361; Mon, 12 May 2025 15:38:13 +0200 (CEST) From: Lukas Wagner <l.wagner@proxmox.com> To: pdm-devel@lists.proxmox.com Date: Mon, 12 May 2025 15:37:21 +0200 Message-Id: <20250512133725.262263-23-l.wagner@proxmox.com> X-Mailer: git-send-email 2.39.5 In-Reply-To: <20250512133725.262263-1-l.wagner@proxmox.com> References: <20250512133725.262263-1-l.wagner@proxmox.com> MIME-Version: 1.0 X-SPAM-LEVEL: Spam detection results: 0 AWL 0.018 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% DMARC_MISSING 0.1 Missing DMARC policy KAM_DMARC_STATUS 0.01 Test Rule for DKIM or SPF Failure with Strict Alignment SPF_HELO_NONE 0.001 SPF: HELO does not publish an SPF Record SPF_PASS -0.001 SPF: sender matches SPF record Subject: [pdm-devel] [PATCH proxmox-datacenter-manager v4 22/26] pdm-client: add metric collection API methods X-BeenThere: pdm-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Datacenter Manager development discussion <pdm-devel.lists.proxmox.com> List-Unsubscribe: <https://lists.proxmox.com/cgi-bin/mailman/options/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=unsubscribe> List-Archive: <http://lists.proxmox.com/pipermail/pdm-devel/> List-Post: <mailto:pdm-devel@lists.proxmox.com> List-Help: <mailto:pdm-devel-request@lists.proxmox.com?subject=help> List-Subscribe: <https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel>, <mailto:pdm-devel-request@lists.proxmox.com?subject=subscribe> Reply-To: Proxmox Datacenter Manager development discussion <pdm-devel@lists.proxmox.com> Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Errors-To: pdm-devel-bounces@lists.proxmox.com Sender: "pdm-devel" <pdm-devel-bounces@lists.proxmox.com> This adds bindings for collection settings, trigger, and status APIs. Signed-off-by: Lukas Wagner <l.wagner@proxmox.com> Reviewed-by: Maximiliano Sandoval <m.sandoval@proxmox.com> --- lib/pdm-client/src/lib.rs | 89 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 89 insertions(+) diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs index 61a8ebd9..f8de4342 100644 --- a/lib/pdm-client/src/lib.rs +++ b/lib/pdm-client/src/lib.rs @@ -317,6 +317,95 @@ impl<T: HttpApiClient> PdmClient<T> { .ok_or_else(|| Error::BadApi("api returned no webauthn entry id".to_string(), None)) } + /// Get global metric collection settings. + pub async fn get_metric_collection_settings( + &self, + ) -> Result<pdm_api_types::CollectionSettings, Error> { + let path = "/api2/extjs/config/metric-collection/default"; + Ok(self.0.get(path).await?.expect_json()?.data) + } + + /// Update global metric collection settings. + pub async fn update_metric_collection_settings( + &self, + updater: pdm_api_types::CollectionSettingsUpdater, + delete: Option<Vec<pdm_api_types::DeletableCollectionSettingsProperty>>, + ) -> Result<(), Error> { + let path = "/api2/extjs/config/metric-collection/default"; + + #[derive(Serialize)] + struct UpdateSettings<'a> { + updater: &'a pdm_api_types::CollectionSettingsUpdater, + #[serde(skip_serializing_if = "Option::is_none")] + delete: Option<Vec<pdm_api_types::DeletableCollectionSettingsProperty>>, + } + + let params = UpdateSettings { + updater: &updater, + delete, + }; + self.0.put(path, ¶ms).await?.nodata()?; + Ok(()) + } + + /// Trigger metric collection for a single remote or for all remotes, if no remote is provided. + pub async fn trigger_metric_collection( + &self, + remote: Option<&str>, + ) -> Result<(), proxmox_client::Error> { + let path = "/api2/extjs/metric-collection/trigger"; + + #[derive(Serialize)] + struct TriggerParams<'a> { + #[serde(skip_serializing_if = "Option::is_none")] + remote: Option<&'a str>, + } + + self.0 + .post(path, &TriggerParams { remote }) + .await? + .nodata()?; + + Ok(()) + } + + /// Get global metric collection status. + pub async fn get_metric_collection_status( + &self, + ) -> Result<Vec<pdm_api_types::MetricCollectionStatus>, Error> { + let path = "/api2/extjs/metric-collection/status"; + Ok(self.0.get(path).await?.expect_json()?.data) + } + + /// Get global metric collection status. + pub async fn get_metric_collection_rrddata( + &self, + mode: RrdMode, + timeframe: RrdTimeframe, + ) -> Result<pdm_api_types::rrddata::FullCollectionDatapoint, Error> { + let path = ApiPathBuilder::new("/api2/extjs/metric-collection/rrddata") + .arg("cf", mode) + .arg("timeframe", timeframe) + .build(); + Ok(self.0.get(&path).await?.expect_json()?.data) + } + + /// Get per-remote metric collection status. + pub async fn get_per_remote_metric_collection_rrddata( + &self, + remote: &str, + mode: RrdMode, + timeframe: RrdTimeframe, + ) -> Result<pdm_api_types::rrddata::RemoteCollectionDatapoint, Error> { + let path = ApiPathBuilder::new(format!( + "/api2/extjs/remotes/{remote}/metric-collection-rrddata" + )) + .arg("cf", mode) + .arg("timeframe", timeframe) + .build(); + Ok(self.0.get(&path).await?.expect_json()?.data) + } + pub async fn pve_list_nodes( &self, remote: &str, -- 2.39.5 _______________________________________________ pdm-devel mailing list pdm-devel@lists.proxmox.com https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel