diff options
author | Alex Auvolat <lx@deuxfleurs.fr> | 2025-01-28 15:12:03 +0100 |
---|---|---|
committer | Alex Auvolat <lx@deuxfleurs.fr> | 2025-01-29 19:26:16 +0100 |
commit | c99bfe69ea19497895d32669fd15c689b86035d8 (patch) | |
tree | fd70d3d92c45de20f28c078b902c083cee91a037 /src/api/admin/api.rs | |
parent | 831f2b0207f128d67f061e6f7084337b1cbfefa4 (diff) | |
download | garage-c99bfe69ea19497895d32669fd15c689b86035d8.tar.gz garage-c99bfe69ea19497895d32669fd15c689b86035d8.zip |
admin api: new router_v2 with unified path syntax
Diffstat (limited to 'src/api/admin/api.rs')
-rw-r--r-- | src/api/admin/api.rs | 31 |
1 files changed, 20 insertions, 11 deletions
diff --git a/src/api/admin/api.rs b/src/api/admin/api.rs index a5dbdfbe..b0ab058a 100644 --- a/src/api/admin/api.rs +++ b/src/api/admin/api.rs @@ -11,6 +11,12 @@ use crate::admin::EndpointHandler; use crate::helpers::is_default; pub enum AdminApiRequest { + // Special endpoints of the Admin API + Options(OptionsRequest), + CheckDomain(CheckDomainRequest), + Health(HealthRequest), + Metrics(MetricsRequest), + // Cluster operations GetClusterStatus(GetClusterStatusRequest), GetClusterHealth(GetClusterHealthRequest), @@ -90,6 +96,7 @@ impl EndpointHandler for AdminApiRequest { async fn handle(self, garage: &Arc<Garage>) -> Result<AdminApiResponse, Error> { Ok(match self { + Self::Options | Self::CheckDomain | Self::Health | Self::Metrics => unreachable!(), // Cluster operations Self::GetClusterStatus(req) => { AdminApiResponse::GetClusterStatus(req.handle(garage).await?) @@ -152,19 +159,19 @@ impl EndpointHandler for AdminApiRequest { } // ********************************************** -// Metrics-related endpoints +// Special endpoints // ********************************************** -// TODO: do we want this here ?? - -// ---- Metrics ---- +pub struct OptionsRequest; -pub struct MetricsRequest; - -// ---- Health ---- +pub struct CheckDomainRequest { + pub domain: String, +} pub struct HealthRequest; +pub struct MetricsRequest; + // ********************************************** // Cluster operations // ********************************************** @@ -404,7 +411,7 @@ pub struct ImportKeyResponse(pub GetKeyInfoResponse); pub struct UpdateKeyRequest { pub id: String, - pub params: UpdateKeyRequestParams, + pub body: UpdateKeyRequestBody, } #[derive(Serialize)] @@ -412,7 +419,7 @@ pub struct UpdateKeyResponse(pub GetKeyInfoResponse); #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -pub struct UpdateKeyRequestParams { +pub struct UpdateKeyRequestBody { // TODO: id (get parameter) goes here pub name: Option<String>, pub allow: Option<KeyPerm>, @@ -527,7 +534,7 @@ pub struct CreateBucketLocalAlias { pub struct UpdateBucketRequest { pub id: String, - pub params: UpdateBucketRequestParams, + pub body: UpdateBucketRequestBody, } #[derive(Serialize)] @@ -535,7 +542,7 @@ pub struct UpdateBucketResponse(pub GetBucketInfoResponse); #[derive(Deserialize)] #[serde(rename_all = "camelCase")] -pub struct UpdateBucketRequestParams { +pub struct UpdateBucketRequestBody { pub website_access: Option<UpdateBucketWebsiteAccess>, pub quotas: Option<ApiBucketQuotas>, } @@ -563,6 +570,7 @@ pub struct DeleteBucketResponse; // ---- BucketAllowKey ---- +#[derive(Deserialize)] pub struct BucketAllowKeyRequest(pub BucketKeyPermChangeRequest); #[derive(Serialize)] @@ -578,6 +586,7 @@ pub struct BucketKeyPermChangeRequest { // ---- BucketDenyKey ---- +#[derive(Deserialize)] pub struct BucketDenyKeyRequest(pub BucketKeyPermChangeRequest); #[derive(Serialize)] |