From 6dc073fa0fae1ce9f04c4b3621d34014cbfd9a9f Mon Sep 17 00:00:00 2001 From: Wolfgang Bumiller Date: Thu, 26 Aug 2021 13:17:55 +0200 Subject: [PATCH] move some API return types to pbs-api-types they'll be required by the api client Signed-off-by: Wolfgang Bumiller --- pbs-api-types/src/lib.rs | 76 +++++++++++++++++++++++++++++++++++++++- 1 file changed, 75 insertions(+), 1 deletion(-) diff --git a/pbs-api-types/src/lib.rs b/pbs-api-types/src/lib.rs index 576099eb..1c9063bf 100644 --- a/pbs-api-types/src/lib.rs +++ b/pbs-api-types/src/lib.rs @@ -3,7 +3,10 @@ use serde::{Deserialize, Serialize}; use proxmox::api::api; -use proxmox::api::schema::{ApiStringFormat, EnumEntry, IntegerSchema, Schema, StringSchema}; +use proxmox::api::schema::{ + ApiStringFormat, ApiType, ArraySchema, EnumEntry, IntegerSchema, ReturnType, Schema, + StringSchema, +}; use proxmox::const_regex; use proxmox::{IPRE, IPRE_BRACKET, IPV4OCTET, IPV4RE, IPV6H16, IPV6LS32, IPV6RE}; @@ -564,3 +567,74 @@ impl std::convert::TryFrom> for RsaPubK }) } } + +#[api( + properties: { + upid: { schema: UPID::API_SCHEMA }, + }, +)] +#[derive(Serialize, Deserialize)] +/// Task properties. +pub struct TaskListItem { + pub upid: String, + /// The node name where the task is running on. + pub node: String, + /// The Unix PID + pub pid: i64, + /// The task start time (Epoch) + pub pstart: u64, + /// The task start time (Epoch) + pub starttime: i64, + /// Worker type (arbitrary ASCII string) + pub worker_type: String, + /// Worker ID (arbitrary ASCII string) + pub worker_id: Option, + /// The authenticated entity who started the task + pub user: Authid, + /// The task end time (Epoch) + #[serde(skip_serializing_if="Option::is_none")] + pub endtime: Option, + /// Task end status + #[serde(skip_serializing_if="Option::is_none")] + pub status: Option, +} + +pub const ADMIN_DATASTORE_LIST_SNAPSHOTS_RETURN_TYPE: ReturnType = ReturnType { + optional: false, + schema: &ArraySchema::new( + "Returns the list of snapshots.", + &SnapshotListItem::API_SCHEMA, + ).schema(), +}; + +pub const ADMIN_DATASTORE_LIST_SNAPSHOT_FILES_RETURN_TYPE: ReturnType = ReturnType { + optional: false, + schema: &ArraySchema::new( + "Returns the list of archive files inside a backup snapshots.", + &BackupContent::API_SCHEMA, + ).schema(), +}; + +pub const ADMIN_DATASTORE_LIST_GROUPS_RETURN_TYPE: ReturnType = ReturnType { + optional: false, + schema: &ArraySchema::new( + "Returns the list of backup groups.", + &GroupListItem::API_SCHEMA, + ).schema(), +}; + +pub const ADMIN_DATASTORE_PRUNE_RETURN_TYPE: ReturnType = ReturnType { + optional: false, + schema: &ArraySchema::new( + "Returns the list of snapshots and a flag indicating if there are kept or removed.", + &PruneListItem::API_SCHEMA, + ).schema(), +}; + +pub const NODE_TASKS_LIST_TASKS_RETURN_TYPE: ReturnType = ReturnType { + optional: false, + schema: &ArraySchema::new( + "A list of tasks.", + &TaskListItem::API_SCHEMA, + ).schema(), +};