From 5fefbd94e9f8cded0d911f7cdae3d0382762607c Mon Sep 17 00:00:00 2001 From: Alex Auvolat Date: Tue, 28 Jan 2025 18:53:44 +0100 Subject: admin api: rename allow/deny api calls in api v2 --- src/api/admin/api.rs | 16 ++++++++-------- src/api/admin/bucket.rs | 20 ++++++++++---------- src/api/admin/router_v2.rs | 8 ++++---- 3 files changed, 22 insertions(+), 22 deletions(-) (limited to 'src') diff --git a/src/api/admin/api.rs b/src/api/admin/api.rs index 632711d1..c3559587 100644 --- a/src/api/admin/api.rs +++ b/src/api/admin/api.rs @@ -50,8 +50,8 @@ admin_endpoints![ DeleteBucket, // Operations on permissions for keys on buckets - BucketAllowKey, - BucketDenyKey, + AllowBucketKey, + DenyBucketKey, // Operations on bucket aliases AddGlobalBucketAlias, @@ -486,13 +486,13 @@ pub struct DeleteBucketResponse; // Operations on permissions for keys on buckets // ********************************************** -// ---- BucketAllowKey ---- +// ---- AllowBucketKey ---- #[derive(Serialize, Deserialize)] -pub struct BucketAllowKeyRequest(pub BucketKeyPermChangeRequest); +pub struct AllowBucketKeyRequest(pub BucketKeyPermChangeRequest); #[derive(Serialize, Deserialize)] -pub struct BucketAllowKeyResponse(pub GetBucketInfoResponse); +pub struct AllowBucketKeyResponse(pub GetBucketInfoResponse); #[derive(Serialize, Deserialize)] #[serde(rename_all = "camelCase")] @@ -502,13 +502,13 @@ pub struct BucketKeyPermChangeRequest { pub permissions: ApiBucketKeyPerm, } -// ---- BucketDenyKey ---- +// ---- DenyBucketKey ---- #[derive(Serialize, Deserialize)] -pub struct BucketDenyKeyRequest(pub BucketKeyPermChangeRequest); +pub struct DenyBucketKeyRequest(pub BucketKeyPermChangeRequest); #[derive(Serialize, Deserialize)] -pub struct BucketDenyKeyResponse(pub GetBucketInfoResponse); +pub struct DenyBucketKeyResponse(pub GetBucketInfoResponse); // ********************************************** // Operations on bucket aliases diff --git a/src/api/admin/bucket.rs b/src/api/admin/bucket.rs index 09952bff..885c1749 100644 --- a/src/api/admin/bucket.rs +++ b/src/api/admin/bucket.rs @@ -18,8 +18,8 @@ use garage_model::s3::object_table::*; use crate::admin::api::ApiBucketKeyPerm; use crate::admin::api::{ - ApiBucketQuotas, BucketAllowKeyRequest, BucketAllowKeyResponse, BucketDenyKeyRequest, - BucketDenyKeyResponse, BucketKeyPermChangeRequest, BucketLocalAlias, CreateBucketRequest, + ApiBucketQuotas, AllowBucketKeyRequest, AllowBucketKeyResponse, DenyBucketKeyRequest, + DenyBucketKeyResponse, BucketKeyPermChangeRequest, BucketLocalAlias, CreateBucketRequest, CreateBucketResponse, DeleteBucketRequest, DeleteBucketResponse, GetBucketInfoKey, GetBucketInfoRequest, GetBucketInfoResponse, GetBucketInfoWebsiteResponse, AddGlobalBucketAliasRequest, AddGlobalBucketAliasResponse, RemoveGlobalBucketAliasRequest, @@ -394,22 +394,22 @@ impl EndpointHandler for UpdateBucketRequest { // ---- BUCKET/KEY PERMISSIONS ---- #[async_trait] -impl EndpointHandler for BucketAllowKeyRequest { - type Response = BucketAllowKeyResponse; +impl EndpointHandler for AllowBucketKeyRequest { + type Response = AllowBucketKeyResponse; - async fn handle(self, garage: &Arc) -> Result { + async fn handle(self, garage: &Arc) -> Result { let res = handle_bucket_change_key_perm(garage, self.0, true).await?; - Ok(BucketAllowKeyResponse(res)) + Ok(AllowBucketKeyResponse(res)) } } #[async_trait] -impl EndpointHandler for BucketDenyKeyRequest { - type Response = BucketDenyKeyResponse; +impl EndpointHandler for DenyBucketKeyRequest { + type Response = DenyBucketKeyResponse; - async fn handle(self, garage: &Arc) -> Result { + async fn handle(self, garage: &Arc) -> Result { let res = handle_bucket_change_key_perm(garage, self.0, false).await?; - Ok(BucketDenyKeyResponse(res)) + Ok(DenyBucketKeyResponse(res)) } } diff --git a/src/api/admin/router_v2.rs b/src/api/admin/router_v2.rs index 6faa2ab1..45613ea4 100644 --- a/src/api/admin/router_v2.rs +++ b/src/api/admin/router_v2.rs @@ -52,8 +52,8 @@ impl AdminApiRequest { POST DeleteBucket (query::id), POST UpdateBucket (body_field, query::id), // Bucket-key permissions - POST BucketAllowKey (body), - POST BucketDenyKey (body), + POST AllowBucketKey (body), + POST DenyBucketKey (body), // Bucket aliases POST AddGlobalBucketAlias (body), POST RemoveGlobalBucketAlias (body), @@ -167,11 +167,11 @@ impl AdminApiRequest { // Bucket-key permissions Endpoint::BucketAllowKey => { let req = parse_json_body::(req).await?; - Ok(AdminApiRequest::BucketAllowKey(BucketAllowKeyRequest(req))) + Ok(AdminApiRequest::AllowBucketKey(AllowBucketKeyRequest(req))) } Endpoint::BucketDenyKey => { let req = parse_json_body::(req).await?; - Ok(AdminApiRequest::BucketDenyKey(BucketDenyKeyRequest(req))) + Ok(AdminApiRequest::DenyBucketKey(DenyBucketKeyRequest(req))) } // Bucket aliasing Endpoint::GlobalAliasBucket { id, alias } => Ok(AdminApiRequest::AddGlobalBucketAlias( -- cgit v1.2.3