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 [IPv6:2a01:7e0:0:424::9]) by lore.proxmox.com (Postfix) with ESMTPS id CD8901FF16F for <inbox@lore.proxmox.com>; Thu, 13 Feb 2025 13:10:39 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id C86642976; Thu, 13 Feb 2025 13:10:36 +0100 (CET) Date: Thu, 13 Feb 2025 13:10:34 +0100 From: Wolfgang Bumiller <w.bumiller@proxmox.com> To: Lukas Wagner <l.wagner@proxmox.com> Message-ID: <cdlqcqdehmqrrsxfwuj4emgokmdo37d3vhsthibln4ka5xnpy2@tbtjs3omqqvr> References: <20250211120541.163621-1-l.wagner@proxmox.com> <20250211120541.163621-25-l.wagner@proxmox.com> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20250211120541.163621-25-l.wagner@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.083 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: Re: [pdm-devel] [PATCH proxmox-datacenter-manager 24/25] 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> Cc: 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> On Tue, Feb 11, 2025 at 01:05:40PM +0100, Lukas Wagner wrote: > This adds bindings for collection settings, trigger, and status APIs. > > Signed-off-by: Lukas Wagner <l.wagner@proxmox.com> > --- > lib/pdm-client/src/lib.rs | 87 +++++++++++++++++++++++++++++++++++++++ > 1 file changed, 87 insertions(+) > > diff --git a/lib/pdm-client/src/lib.rs b/lib/pdm-client/src/lib.rs > index a41b82c..ae41e9a 100644 > --- a/lib/pdm-client/src/lib.rs > +++ b/lib/pdm-client/src/lib.rs > @@ -320,6 +320,93 @@ 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 all, 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? > + .expect_json::<()>()?; Look like this should be `.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 mut path = "/api2/extjs/metric-collection/rrddata".to_string(); > + let mut sep = '?'; > + add_query_arg(&mut path, &mut sep, "cf", &Some(mode)); > + add_query_arg(&mut path, &mut sep, "timeframe", &Some(timeframe)); > + 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 mut path = format!("/api2/extjs/remotes/{remote}/metric-collection-rrddata"); > + let mut sep = '?'; > + add_query_arg(&mut path, &mut sep, "cf", &Some(mode)); > + add_query_arg(&mut path, &mut sep, "timeframe", &Some(timeframe)); > + 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