[pbs-devel] [PATCH proxmox-backup 2/4] api: merge garbage-collection-status and -job-status
Fabian Grünbichler
f.gruenbichler at proxmox.com
Mon Apr 22 13:38:32 CEST 2024
the latter was newly introduced, and they both return basically the same
information now. the new extended (job) status struct is a strict superset of
the old status struct, so this is not a breaking change API wise.
Signed-off-by: Fabian Grünbichler <f.gruenbichler at proxmox.com>
---
src/api2/admin/datastore.rs | 34 +---------------------------------
src/api2/admin/gc.rs | 8 +++-----
2 files changed, 4 insertions(+), 38 deletions(-)
diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs
index da2b545a..e7a823b5 100644
--- a/src/api2/admin/datastore.rs
+++ b/src/api2/admin/datastore.rs
@@ -1212,34 +1212,6 @@ pub fn start_garbage_collection(
Ok(json!(upid_str))
}
-#[api(
- input: {
- properties: {
- store: {
- schema: DATASTORE_SCHEMA,
- },
- },
- },
- returns: {
- type: GarbageCollectionStatus,
- },
- access: {
- permission: &Permission::Privilege(&["datastore", "{store}"], PRIV_DATASTORE_AUDIT, false),
- },
-)]
-/// Garbage collection status.
-pub fn garbage_collection_status(
- store: String,
- _info: &ApiMethod,
- _rpcenv: &mut dyn RpcEnvironment,
-) -> Result<GarbageCollectionStatus, Error> {
- let datastore = DataStore::lookup_datastore(&store, Some(Operation::Read))?;
-
- let status = datastore.last_gc_status();
-
- Ok(status)
-}
-
#[api(
input: {
properties: {
@@ -1256,7 +1228,7 @@ pub fn garbage_collection_status(
},
)]
/// Garbage collection status.
-pub fn garbage_collection_job_status(
+pub fn garbage_collection_status(
store: String,
_info: &ApiMethod,
_rpcenv: &mut dyn RpcEnvironment,
@@ -2406,10 +2378,6 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
.get(&API_METHOD_GARBAGE_COLLECTION_STATUS)
.post(&API_METHOD_START_GARBAGE_COLLECTION),
),
- (
- "gc-job-status",
- &Router::new().get(&API_METHOD_GARBAGE_COLLECTION_JOB_STATUS),
- ),
(
"group-notes",
&Router::new()
diff --git a/src/api2/admin/gc.rs b/src/api2/admin/gc.rs
index 7535f369..bca06897 100644
--- a/src/api2/admin/gc.rs
+++ b/src/api2/admin/gc.rs
@@ -8,7 +8,7 @@ use pbs_api_types::DATASTORE_SCHEMA;
use serde_json::Value;
-use crate::api2::admin::datastore::{garbage_collection_job_status, get_datastore_list};
+use crate::api2::admin::datastore::{garbage_collection_status, get_datastore_list};
#[api(
input: {
@@ -37,13 +37,11 @@ pub fn list_all_gc_jobs(
rpcenv: &mut dyn RpcEnvironment,
) -> Result<Vec<GarbageCollectionJobStatus>, Error> {
let gc_info = match store {
- Some(store) => {
- garbage_collection_job_status(store, _info, rpcenv).map(|info| vec![info])?
- }
+ Some(store) => garbage_collection_status(store, _info, rpcenv).map(|info| vec![info])?,
None => get_datastore_list(Value::Null, _info, rpcenv)?
.into_iter()
.map(|store_list_item| store_list_item.store)
- .filter_map(|store| garbage_collection_job_status(store, _info, rpcenv).ok())
+ .filter_map(|store| garbage_collection_status(store, _info, rpcenv).ok())
.collect::<Vec<_>>(),
};
--
2.39.2
More information about the pbs-devel
mailing list