From dfc58d47ad47e0eb80059eec60c70e0363bfdd17 Mon Sep 17 00:00:00 2001 From: Dietmar Maurer Date: Thu, 23 Jan 2020 13:01:21 +0100 Subject: [PATCH] src/api2/admin/datastore.rs: use api macro for start_garbage_collection --- src/api2/admin/datastore.rs | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/src/api2/admin/datastore.rs b/src/api2/admin/datastore.rs index 54fa8c70..049e16ed 100644 --- a/src/api2/admin/datastore.rs +++ b/src/api2/admin/datastore.rs @@ -474,25 +474,25 @@ fn prune( Ok(json!(worker.to_string())) // return the UPID } -#[sortable] -pub const API_METHOD_START_GARBAGE_COLLECTION: ApiMethod = ApiMethod::new( - &ApiHandler::Sync(&start_garbage_collection), - &ObjectSchema::new( - "Start garbage collection.", - &sorted!([ - ("store", false, &DATASTORE_SCHEMA), - ]) - ) -); - +#[api( + input: { + properties: { + store: { + schema: DATASTORE_SCHEMA, + }, + }, + }, + returns: { + schema: UPID_SCHEMA, + }, +)] +/// Start garbage collection. fn start_garbage_collection( - param: Value, + store: String, _info: &ApiMethod, rpcenv: &mut dyn RpcEnvironment, ) -> Result { - let store = param["store"].as_str().unwrap().to_string(); - let datastore = DataStore::lookup_datastore(&store)?; println!("Starting garbage collection on store {}", store);