aboutsummaryrefslogtreecommitdiff
path: root/src/api/admin/api.rs
diff options
context:
space:
mode:
authorAlex Auvolat <lx@deuxfleurs.fr>2025-01-30 19:08:48 +0100
committerAlex Auvolat <lx@deuxfleurs.fr>2025-02-03 18:54:51 +0100
commit89ff9f5576f91dc127ba3cc1fae96543e27b9468 (patch)
treedd6f849031b7ba78a6ca06005918e93bcf3de320 /src/api/admin/api.rs
parentbdaf55ab3f866234bd5a7d585758265a88d2906a (diff)
downloadgarage-89ff9f5576f91dc127ba3cc1fae96543e27b9468.tar.gz
garage-89ff9f5576f91dc127ba3cc1fae96543e27b9468.zip
admin api: base infrastructure for local endpoints
admin api: rename EndpointHandler into RequestHandler to avoid confusion with RPC wip: infrastructure for local api calls admin api: fix things admin api: first local endpoint to work with new scheme admin api: implement SetWorkerVariable
Diffstat (limited to 'src/api/admin/api.rs')
-rw-r--r--src/api/admin/api.rs41
1 files changed, 40 insertions, 1 deletions
diff --git a/src/api/admin/api.rs b/src/api/admin/api.rs
index 44fc9fca..89ddb286 100644
--- a/src/api/admin/api.rs
+++ b/src/api/admin/api.rs
@@ -1,3 +1,4 @@
+use std::collections::HashMap;
use std::convert::TryFrom;
use std::net::SocketAddr;
use std::sync::Arc;
@@ -6,13 +7,17 @@ use async_trait::async_trait;
use paste::paste;
use serde::{Deserialize, Serialize};
+use garage_rpc::*;
+
use garage_model::garage::Garage;
+use garage_api_common::common_error::CommonErrorDerivative;
use garage_api_common::helpers::is_default;
+use crate::api_server::{AdminRpc, AdminRpcResponse};
use crate::error::Error;
use crate::macros::*;
-use crate::EndpointHandler;
+use crate::{Admin, RequestHandler};
// This generates the following:
//
@@ -71,8 +76,14 @@ admin_endpoints![
// Operations on bucket aliases
AddBucketAlias,
RemoveBucketAlias,
+
+ // Worker operations
+ GetWorkerVariable,
+ SetWorkerVariable,
];
+local_admin_endpoints![GetWorkerVariable, SetWorkerVariable,];
+
// **********************************************
// Special endpoints
//
@@ -580,3 +591,31 @@ pub struct RemoveBucketAliasRequest {
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct RemoveBucketAliasResponse(pub GetBucketInfoResponse);
+
+// **********************************************
+// Worker operations
+// **********************************************
+
+// ---- GetWorkerVariable ----
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct LocalGetWorkerVariableRequest {
+ pub variable: Option<String>,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct LocalGetWorkerVariableResponse(pub HashMap<String, String>);
+
+// ---- SetWorkerVariable ----
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct LocalSetWorkerVariableRequest {
+ pub variable: String,
+ pub value: String,
+}
+
+#[derive(Debug, Clone, Serialize, Deserialize)]
+pub struct LocalSetWorkerVariableResponse {
+ pub variable: String,
+ pub value: String,
+}