]> git.proxmox.com Git - proxmox-backup.git/commitdiff
api: merge garbage-collection-status and -job-status
authorFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 22 Apr 2024 09:43:51 +0000 (11:43 +0200)
committerFabian Grünbichler <f.gruenbichler@proxmox.com>
Mon, 22 Apr 2024 11:58:08 +0000 (13:58 +0200)
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@proxmox.com>
src/api2/admin/datastore.rs
src/api2/admin/gc.rs

index da2b545aa4d178301aa7b9c4a261bba2bae0a00b..e7a823b521ef65fadb3fdcbfa8e5bf0e1097be22 100644 (file)
@@ -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()
index 7535f36923ae6c99c8800a4aa98fced80e2a15b4..bca06897b3af1f0039258f328b63cbccd27b623b 100644 (file)
@@ -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<_>>(),
     };