[pbs-devel] [RFC proxmox-backup 1/8] api-types: jobs: add sanity checks job types
Christian Ebner
c.ebner at proxmox.com
Wed Dec 13 16:38:12 CET 2023
Defines the required types for managing sanity check jobs via the API.
Signed-off-by: Christian Ebner <c.ebner at proxmox.com>
---
pbs-api-types/src/jobs.rs | 106 ++++++++++++++++++++++++++++++++++++++
1 file changed, 106 insertions(+)
diff --git a/pbs-api-types/src/jobs.rs b/pbs-api-types/src/jobs.rs
index 1f5b3cf1..4f6b2cc7 100644
--- a/pbs-api-types/src/jobs.rs
+++ b/pbs-api-types/src/jobs.rs
@@ -57,12 +57,28 @@ pub const VERIFICATION_SCHEDULE_SCHEMA: Schema =
.type_text("<calendar-event>")
.schema();
+pub const SANITY_CHECK_SCHEDULE_SCHEMA: Schema =
+ StringSchema::new("Run sanity check job at specified schedule.")
+ .format(&ApiStringFormat::VerifyFn(
+ proxmox_time::verify_calendar_event,
+ ))
+ .type_text("<calendar-event>")
+ .schema();
+
pub const REMOVE_VANISHED_BACKUPS_SCHEMA: Schema = BooleanSchema::new(
"Delete vanished backups. This remove the local copy if the remote backup was deleted.",
)
.default(false)
.schema();
+pub const DATASTORE_USAGE_FULL_THRESHOLD_DEFAULT: u8 = 90;
+pub const DATASTORE_USAGE_FULL_THRESHOLD_SCHEMA: Schema =
+ IntegerSchema::new("Datastore usage threshold level in percent for the datastore being full.")
+ .minimum(1)
+ .maximum(100)
+ .default(DATASTORE_USAGE_FULL_THRESHOLD_DEFAULT as isize)
+ .schema();
+
#[api(
properties: {
"next-run": {
@@ -753,3 +769,93 @@ pub struct PruneJobStatus {
#[serde(flatten)]
pub status: JobScheduleStatus,
}
+
+#[api(
+ properties: {
+ "datastore-usage-full-threshold": {
+ schema: DATASTORE_USAGE_FULL_THRESHOLD_SCHEMA,
+ optional: true,
+ },
+ "notify-user": {
+ optional: true,
+ type: Userid,
+ },
+ }
+)]
+#[derive(Serialize, Deserialize, Default, Updater, Clone, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// Sanity check options
+pub struct SanityCheckJobOptions {
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub datastore_usage_full_threshold: Option<u8>,
+ /// Send job email notification to this user
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub notify_user: Option<Userid>,
+}
+
+#[api(
+ properties: {
+ id: {
+ schema: JOB_ID_SCHEMA,
+ },
+ disable: {
+ type: Boolean,
+ optional: true,
+ default: false,
+ },
+ schedule: {
+ schema: SANITY_CHECK_SCHEDULE_SCHEMA,
+ },
+ comment: {
+ optional: true,
+ schema: SINGLE_LINE_COMMENT_SCHEMA,
+ },
+ options: {
+ type: SanityCheckJobOptions,
+ },
+ },
+)]
+#[derive(Deserialize, Serialize, Updater, Clone, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// Sanity check configuration.
+pub struct SanityCheckJobConfig {
+ /// Unique ID to address this job
+ #[updater(skip)]
+ pub id: String,
+
+ /// Flag to disable job
+ #[serde(default, skip_serializing_if = "is_false")]
+ #[updater(serde(skip_serializing_if = "Option::is_none"))]
+ pub disable: bool,
+
+ /// When to schedule this job in calendar event notation
+ pub schedule: String,
+
+ /// Additional comment for this job
+ #[serde(skip_serializing_if = "Option::is_none")]
+ pub comment: Option<String>,
+
+ /// Configuration options for this job
+ #[serde(flatten)]
+ pub options: SanityCheckJobOptions,
+}
+
+#[api(
+ properties: {
+ config: {
+ type: SanityCheckJobConfig,
+ },
+ status: {
+ type: JobScheduleStatus,
+ },
+ },
+)]
+#[derive(Serialize, Deserialize, Clone, PartialEq)]
+#[serde(rename_all = "kebab-case")]
+/// Status of sanity check job
+pub struct SanityCheckJobStatus {
+ #[serde(flatten)]
+ pub config: SanityCheckJobConfig,
+ #[serde(flatten)]
+ pub status: JobScheduleStatus,
+}
--
2.39.2
More information about the pbs-devel
mailing list