mirror of
https://git.proxmox.com/git/proxmox-backup
synced 2025-06-14 13:25:19 +00:00
api: merge garbage-collection-status and -job-status
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>
This commit is contained in:
parent
3ae21d87c1
commit
113de4515b
@ -1212,34 +1212,6 @@ pub fn start_garbage_collection(
|
|||||||
Ok(json!(upid_str))
|
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(
|
#[api(
|
||||||
input: {
|
input: {
|
||||||
properties: {
|
properties: {
|
||||||
@ -1256,7 +1228,7 @@ pub fn garbage_collection_status(
|
|||||||
},
|
},
|
||||||
)]
|
)]
|
||||||
/// Garbage collection status.
|
/// Garbage collection status.
|
||||||
pub fn garbage_collection_job_status(
|
pub fn garbage_collection_status(
|
||||||
store: String,
|
store: String,
|
||||||
_info: &ApiMethod,
|
_info: &ApiMethod,
|
||||||
_rpcenv: &mut dyn RpcEnvironment,
|
_rpcenv: &mut dyn RpcEnvironment,
|
||||||
@ -2406,10 +2378,6 @@ const DATASTORE_INFO_SUBDIRS: SubdirMap = &[
|
|||||||
.get(&API_METHOD_GARBAGE_COLLECTION_STATUS)
|
.get(&API_METHOD_GARBAGE_COLLECTION_STATUS)
|
||||||
.post(&API_METHOD_START_GARBAGE_COLLECTION),
|
.post(&API_METHOD_START_GARBAGE_COLLECTION),
|
||||||
),
|
),
|
||||||
(
|
|
||||||
"gc-job-status",
|
|
||||||
&Router::new().get(&API_METHOD_GARBAGE_COLLECTION_JOB_STATUS),
|
|
||||||
),
|
|
||||||
(
|
(
|
||||||
"group-notes",
|
"group-notes",
|
||||||
&Router::new()
|
&Router::new()
|
||||||
|
@ -8,7 +8,7 @@ use pbs_api_types::DATASTORE_SCHEMA;
|
|||||||
|
|
||||||
use serde_json::Value;
|
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(
|
#[api(
|
||||||
input: {
|
input: {
|
||||||
@ -37,13 +37,11 @@ pub fn list_all_gc_jobs(
|
|||||||
rpcenv: &mut dyn RpcEnvironment,
|
rpcenv: &mut dyn RpcEnvironment,
|
||||||
) -> Result<Vec<GarbageCollectionJobStatus>, Error> {
|
) -> Result<Vec<GarbageCollectionJobStatus>, Error> {
|
||||||
let gc_info = match store {
|
let gc_info = match store {
|
||||||
Some(store) => {
|
Some(store) => garbage_collection_status(store, _info, rpcenv).map(|info| vec![info])?,
|
||||||
garbage_collection_job_status(store, _info, rpcenv).map(|info| vec![info])?
|
|
||||||
}
|
|
||||||
None => get_datastore_list(Value::Null, _info, rpcenv)?
|
None => get_datastore_list(Value::Null, _info, rpcenv)?
|
||||||
.into_iter()
|
.into_iter()
|
||||||
.map(|store_list_item| store_list_item.store)
|
.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<_>>(),
|
.collect::<Vec<_>>(),
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user