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 7FB7184878 for ; Tue, 14 Dec 2021 13:24:16 +0100 (CET) Received: from firstgate.proxmox.com (localhost [127.0.0.1]) by firstgate.proxmox.com (Proxmox) with ESMTP id 753EA242DC for ; Tue, 14 Dec 2021 13:24:16 +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 359F7242BE for ; Tue, 14 Dec 2021 13:24:15 +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 0E9CE44F19 for ; Tue, 14 Dec 2021 13:24:15 +0100 (CET) From: Dominik Csapak To: pbs-devel@lists.proxmox.com Date: Tue, 14 Dec 2021 13:24:08 +0100 Message-Id: <20211214122412.4077902-6-d.csapak@proxmox.com> X-Mailer: git-send-email 2.30.2 In-Reply-To: <20211214122412.4077902-1-d.csapak@proxmox.com> References: <20211214122412.4077902-1-d.csapak@proxmox.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-SPAM-LEVEL: Spam detection results: 0 AWL 0.176 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 URIBL_BLOCKED 0.001 ADMINISTRATOR NOTICE: The query to URIBL was blocked. See http://wiki.apache.org/spamassassin/DnsBlocklists#dnsbl-block for more information. [lib.rs, metrics.rs] Subject: [pbs-devel] [PATCH proxmox-backup 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: Tue, 14 Dec 2021 12:24:16 -0000 InfluxDbUdp and InfluxDbHttp for now Signed-off-by: Dominik Csapak --- pbs-api-types/src/lib.rs | 2 + pbs-api-types/src/metrics.rs | 134 +++++++++++++++++++++++++++++++++++ 2 files changed, 136 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..c7e08885 --- /dev/null +++ b/pbs-api-types/src/metrics.rs @@ -0,0 +1,134 @@ +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, + }, + host: { + schema: DNS_NAME_OR_IP_SCHEMA, + }, + port: { + description: "The port", + type: u16, + }, + mtu: { + description: "The MTU", + 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, + pub host: String, + 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, + }, + host: { + schema: DNS_NAME_OR_IP_SCHEMA, + }, + https: { + description: "If true, HTTPS is used.", + type: bool, + optional: true, + default: true, + }, + token: { + description: "The (optional) API token", + 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", + type: usize, + optional: true, + default: 25_000_000, + }, + "verify-tls": { + description: "If true, the certificate will be validated.", + 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, + 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