From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from firstgate.proxmox.com (firstgate.proxmox.com [212.224.123.68]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by lists.proxmox.com (Postfix) with ESMTPS id AEEC56061E for ; Wed, 12 Jan 2022 15:40:11 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id A41663D17 for ; Wed, 12 Jan 2022 15:40:11 +0100 (CET) Received: from proxmox-new.maurer-it.com (proxmox-new.maurer-it.com [94.136.29.106]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits)) (No client certificate requested) by firstgate.proxmox.com (Proxmox) with ESMTPS id D5DC43D09 for ; Wed, 12 Jan 2022 15:40:10 +0100 (CET) Received: from proxmox-new.maurer-it.com (localhost.localdomain [127.0.0.1]) by proxmox-new.maurer-it.com (Proxmox) with ESMTP id AE6FB46C85 for ; Wed, 12 Jan 2022 15:40:10 +0100 (CET) Date: Wed, 12 Jan 2022 15:40:09 +0100 From: Wolfgang Bumiller To: Dominik Csapak Cc: pbs-devel@lists.proxmox.com Message-ID: <20220112144009.fnlunj4bjtpxxf3j@olga.proxmox.com> References: <20211217081000.1061796-1-d.csapak@proxmox.com> <20211217081000.1061796-6-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211217081000.1061796-6-d.csapak@proxmox.com> X-SPAM-LEVEL: Spam detection results: 0 AWL 0.400 Adjusted score from AWL reputation of From: address BAYES_00 -1.9 Bayes spam probability is 0 to 1% 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: [pbs-devel] [PATCH proxmox-backup v3 2/6] pbs-api-types: add metrics api types X-BeenThere: pbs-devel@lists.proxmox.com X-Mailman-Version: 2.1.29 Precedence: list List-Id: Proxmox Backup Server development discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 12 Jan 2022 14:40:11 -0000 On Fri, Dec 17, 2021 at 09:09:56AM +0100, Dominik Csapak wrote: > InfluxDbUdp and InfluxDbHttp for now > > Signed-off-by: Dominik Csapak > --- > pbs-api-types/src/lib.rs | 2 + > pbs-api-types/src/metrics.rs | 147 +++++++++++++++++++++++++++++++++++ > 2 files changed, 149 insertions(+) > create mode 100644 pbs-api-types/src/metrics.rs > > diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs > index 0a0dd33d..09bd59c8 100644 > --- a/pbs-api-types/src/lib.rs > +++ b/pbs-api-types/src/lib.rs > @@ -88,6 +88,8 @@ pub use traffic_control::*; > mod zfs; > pub use zfs::*; > > +mod metrics; > +pub use metrics::*; > > #[rustfmt::skip] > #[macro_use] > diff --git a/pbs-api-types/src/metrics.rs b/pbs-api-types/src/metrics.rs > new file mode 100644 > index 00000000..786abe82 > --- /dev/null > +++ b/pbs-api-types/src/metrics.rs > @@ -0,0 +1,147 @@ > +use serde::{Deserialize, Serialize}; > + > +use crate::{DNS_NAME_OR_IP_SCHEMA, PROXMOX_SAFE_ID_FORMAT, SINGLE_LINE_COMMENT_SCHEMA}; > +use proxmox_schema::{api, Schema, StringSchema, Updater}; > + > +pub const METRIC_SERVER_ID_SCHEMA: Schema = StringSchema::new("Metrics Server ID.") > + .format(&PROXMOX_SAFE_ID_FORMAT) > + .min_length(3) > + .max_length(32) > + .schema(); > + > +pub const INFLUXDB_BUCKET_SCHEMA: Schema = StringSchema::new("InfluxDB Bucket.") > + .format(&PROXMOX_SAFE_ID_FORMAT) > + .min_length(3) > + .max_length(32) > + .default("proxmox") > + .schema(); > + > +pub const INFLUXDB_ORGANIZATION_SCHEMA: Schema = StringSchema::new("InfluxDB Organization.") > + .format(&PROXMOX_SAFE_ID_FORMAT) > + .min_length(3) > + .max_length(32) > + .default("proxmox") > + .schema(); > + > +#[api( > + properties: { > + name: { > + schema: METRIC_SERVER_ID_SCHEMA, > + }, > + enable: { > + description: "Enables or disables the metrics server", ^ same I'd prefer not to mix doc-comments and `description` entries, please stick to doc comments as they'll also show up in rustdocs. > + type: bool, > + optional: true, > + default: true, > + }, > + host: { > + schema: DNS_NAME_OR_IP_SCHEMA, > + }, > + mtu: { > + description: "The MTU", ^ same > + type: u16, > + optional: true, > + default: 1500, > + }, > + comment: { > + optional: true, > + schema: SINGLE_LINE_COMMENT_SCHEMA, > + }, > + }, > +)] > +#[derive(Serialize, Deserialize, Updater)] > +#[serde(rename_all = "kebab-case")] > +/// InfluxDB Server (UDP) > +pub struct InfluxDbUdp { > + #[updater(skip)] > + pub name: String, and please put some newlines in between these, it's a bit much otherwise with the #[serde] & doc comment stuff. > + #[serde(skip_serializing_if = "Option::is_none")] > + pub enable: Option, > + pub host: String, > + /// The port > + pub port: u16, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub mtu: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub comment: Option, > +} > + > +#[api( > + properties: { > + name: { > + schema: METRIC_SERVER_ID_SCHEMA, > + }, > + enable: { > + description: "Enables or disables the metrics server", ^ same > + type: bool, > + optional: true, > + default: true, > + }, > + host: { > + schema: DNS_NAME_OR_IP_SCHEMA, > + }, > + https: { > + description: "If true, HTTPS is used.", ^ same > + type: bool, > + optional: true, > + default: true, > + }, > + token: { > + description: "The (optional) API token", ^ same, here for instance you used both... > + type: String, > + optional: true, > + }, > + bucket: { > + schema: INFLUXDB_BUCKET_SCHEMA, > + optional: true, > + }, > + organization: { > + schema: INFLUXDB_ORGANIZATION_SCHEMA, > + optional: true, > + }, > + "max-body-size": { > + description: "The (optional) maximum body size", ^ same > + type: usize, > + optional: true, > + default: 25_000_000, > + }, > + "verify-tls": { > + description: "If true, the certificate will be validated.", ^ same > + type: bool, > + optional: true, > + default: true, > + }, > + comment: { > + optional: true, > + schema: SINGLE_LINE_COMMENT_SCHEMA, > + }, > + }, > +)] > +#[derive(Serialize, Deserialize, Updater)] > +#[serde(rename_all = "kebab-case")] > +/// InfluxDB Server (HTTP(s)) > +pub struct InfluxDbHttp { > + #[updater(skip)] > + pub name: String, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub enable: Option, > + pub host: String, > + #[serde(skip_serializing_if = "Option::is_none")] > + /// The (optional) port. (defaults: 80 for HTTP, 443 for HTTPS) > + pub port: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub https: Option, > + /// The Optional Token > + #[serde(skip_serializing_if = "Option::is_none")] > + pub token: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub bucket: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub organization: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub max_body_size: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub verify_tls: Option, > + #[serde(skip_serializing_if = "Option::is_none")] > + pub comment: Option, > +} > -- > 2.30.2