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 313681FF16F
	for <inbox@lore.proxmox.com>; Thu, 13 Feb 2025 13:15:12 +0100 (CET)
Received: from firstgate.proxmox.com (localhost [127.0.0.1])
	by firstgate.proxmox.com (Proxmox) with ESMTP id 4BA0C2FA8;
	Thu, 13 Feb 2025 13:15:09 +0100 (CET)
Message-ID: <fb09d57d-38cf-4c49-b088-6b8cbca69735@proxmox.com>
Date: Thu, 13 Feb 2025 13:15:06 +0100
MIME-Version: 1.0
User-Agent: Mozilla Thunderbird
To: Wolfgang Bumiller <w.bumiller@proxmox.com>
References: <20250211120541.163621-1-l.wagner@proxmox.com>
 <20250211120541.163621-20-l.wagner@proxmox.com>
 <hwmvp5z6tdc24aahd5yhcdjklfkruobvvnj5gr5yzd5zz4iuz3@qappomeenggf>
Content-Language: de-AT, en-US
From: Lukas Wagner <l.wagner@proxmox.com>
In-Reply-To: <hwmvp5z6tdc24aahd5yhcdjklfkruobvvnj5gr5yzd5zz4iuz3@qappomeenggf>
X-SPAM-LEVEL: Spam detection results:  0
 AWL -0.140 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
 POISEN_SPAM_PILL          0.1 Meta: its spam
 POISEN_SPAM_PILL_1        0.1 random spam to be learned in bayes
 POISEN_SPAM_PILL_3        0.1 random spam to be learned in bayes
 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 19/25] api: add
 endpoint for updating metric collection settings
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  2025-02-13 13:09, Wolfgang Bumiller wrote:
> On Tue, Feb 11, 2025 at 01:05:35PM +0100, Lukas Wagner wrote:
>> This one lives under /config/metric-collection.
>> At the moment, we do not offer full CRUD, but only offer a hard-coded
>> collection settings instance at /config/metric-collection/default, which
>> can be retrieved via GET and updated via PUT.
>>
>> Later, we might update this to full CRUD, e.g. to have different
>> settings for different 'poll-groups' consisting of a sub-set of remotes.
>>
>> Signed-off-by: Lukas Wagner <l.wagner@proxmox.com>
>> ---
>>  server/src/api/config/metric_collection.rs | 166 +++++++++++++++++++++
>>  server/src/api/config/mod.rs               |   2 +
>>  2 files changed, 168 insertions(+)
>>  create mode 100644 server/src/api/config/metric_collection.rs
>>
>> diff --git a/server/src/api/config/metric_collection.rs b/server/src/api/config/metric_collection.rs
>> new file mode 100644
>> index 0000000..1146101
>> --- /dev/null
>> +++ b/server/src/api/config/metric_collection.rs
>> @@ -0,0 +1,166 @@
>> +use anyhow::{bail, Error};
>> +
>> +use proxmox_config_digest::ConfigDigest;
>> +use proxmox_router::{list_subdirs_api_method, Router, RpcEnvironment, SubdirMap};
>> +use proxmox_schema::api;
>> +use proxmox_sortable_macro::sortable;
>> +
>> +use pdm_api_types::{
>> +    CollectionSettings, CollectionSettingsUpdater, DeletableCollectionSettingsProperty,
>> +};
>> +use pdm_config::metric_collection::COLLECTION_SETTINGS_TYPE;
>> +
>> +#[sortable]
>> +const SUBDIRS: SubdirMap = &sorted!([("default", &DEFAULT_ROUTER),]);
>> +
>> +pub const ROUTER: Router = Router::new()
>> +    .get(&list_subdirs_api_method!(SUBDIRS))
>> +    .subdirs(SUBDIRS);
>> +
>> +const DEFAULT_ROUTER: Router = Router::new()
>> +    .get(&API_METHOD_GET_SETTINGS)
>> +    .put(&API_METHOD_UPDATE_SETTINGS);
>> +
>> +#[api(
>> +    protected: false,
>> +)]
>> +/// Get metric collection settings.
>> +pub fn get_settings(rpcenv: &mut dyn RpcEnvironment) -> Result<CollectionSettings, Error> {
>> +    let (config, digest) = pdm_config::metric_collection::config()?;
>> +    rpcenv["digest"] = digest.to_hex().into();
>> +
>> +    if config.sections.contains_key("default") {
>> +        let a = config.lookup(COLLECTION_SETTINGS_TYPE, "default")?;
>> +        Ok(a)
> 
> tiny nit: Clippy would warn here, and 'a' is a weird name anyway ;-)
> (drop the let binding)
>

Already fixed locally for v2, thanks.

Yeah, sometimes 'a' is my 'ugh, not sure yet what to name this yet' or
'ugh, what type is this again, let me see the inline type hints from my LSP' name,
sometimes I forgot to fix that afterwards ;)


-- 
- Lukas



_______________________________________________
pdm-devel mailing list
pdm-devel@lists.proxmox.com
https://lists.proxmox.com/cgi-bin/mailman/listinfo/pdm-devel