admin api: rename bucket aliasing operations

This commit is contained in:
Alex 2025-01-28 18:51:15 +01:00
parent 17cbfb7fa6
commit 70bf358b60
5 changed files with 58 additions and 58 deletions

View file

@ -946,11 +946,11 @@ paths:
schema: schema:
$ref: '#/components/schemas/BucketInfo' $ref: '#/components/schemas/BucketInfo'
/GlobalAliasBucket: /AddGlobalBucketAlias:
post: post:
tags: tags:
- Bucket aliases - Bucket aliases
operationId: "GlobalAliasBucket" operationId: "AddGlobalBucketAlias"
summary: "Add a global alias" summary: "Add a global alias"
description: | description: |
Add a global alias to the target bucket Add a global alias to the target bucket
@ -982,11 +982,11 @@ paths:
schema: schema:
$ref: '#/components/schemas/BucketInfo' $ref: '#/components/schemas/BucketInfo'
/GlobalUnaliasBucket: /RemoveGlobalBucketAlias:
post: post:
tags: tags:
- Bucket aliases - Bucket aliases
operationId: "GlobalUnaliasBucket" operationId: "RemoveGlobalBucketAlias"
summary: "Delete a global alias" summary: "Delete a global alias"
description: | description: |
Delete a global alias from the target bucket Delete a global alias from the target bucket
@ -1018,11 +1018,11 @@ paths:
schema: schema:
$ref: '#/components/schemas/BucketInfo' $ref: '#/components/schemas/BucketInfo'
/LocalAliasBucket: /AddLocalBucketAlias:
post: post:
tags: tags:
- Bucket aliases - Bucket aliases
operationId: "LocalAliasBucket" operationId: "AddLocalBucketAlias"
summary: "Add a local alias" summary: "Add a local alias"
description: | description: |
Add a local alias, bound to specified account, to the target bucket Add a local alias, bound to specified account, to the target bucket
@ -1057,11 +1057,11 @@ paths:
schema: schema:
$ref: '#/components/schemas/BucketInfo' $ref: '#/components/schemas/BucketInfo'
/LocalUnaliasBucket: /RemoveGlobalBucketAlias:
post: post:
tags: tags:
- Bucket aliases - Bucket aliases
operationId: "LocalUnaliasBucket" operationId: "RemoveGlobalBucketAlias"
summary: "Delete a local alias" summary: "Delete a local alias"
description: | description: |
Delete a local alias, bound to specified account, from the target bucket Delete a local alias, bound to specified account, from the target bucket

View file

@ -750,7 +750,7 @@ Other flags will remain unchanged.
### Operations on bucket aliases ### Operations on bucket aliases
#### GlobalAliasBucket `POST /v2/GlobalAliasBucket` #### AddGlobalBucketAlias `POST /v2/AddGlobalBucketAlias`
Creates a global alias for a bucket. Creates a global alias for a bucket.
@ -763,7 +763,7 @@ Request body format:
} }
``` ```
#### GlobalUnaliasBucket `POST /v2/GlobalUnaliasBucket` #### RemoveGlobalBucketAlias `POST /v2/RemoveGlobalBucketAlias`
Removes a global alias for a bucket. Removes a global alias for a bucket.
@ -776,7 +776,7 @@ Request body format:
} }
``` ```
#### LocalAliasBucket `POST /v2/LocalAliasBucket` #### AddLocalBucketAlias `POST /v2/AddLocalBucketAlias`
Creates a local alias for a bucket in the namespace of a specific access key. Creates a local alias for a bucket in the namespace of a specific access key.
@ -790,7 +790,7 @@ Request body format:
} }
``` ```
#### LocalUnaliasBucket `POST /v2/LocalUnaliasBucket` #### RemoveLocalBucketAlias `POST /v2/RemoveLocalBucketAlias`
Removes a local alias for a bucket in the namespace of a specific access key. Removes a local alias for a bucket in the namespace of a specific access key.

View file

@ -54,10 +54,10 @@ admin_endpoints![
BucketDenyKey, BucketDenyKey,
// Operations on bucket aliases // Operations on bucket aliases
GlobalAliasBucket, AddGlobalBucketAlias,
GlobalUnaliasBucket, RemoveGlobalBucketAlias,
LocalAliasBucket, AddLocalBucketAlias,
LocalUnaliasBucket, RemoveLocalBucketAlias,
]; ];
// ********************************************** // **********************************************
@ -514,48 +514,48 @@ pub struct BucketDenyKeyResponse(pub GetBucketInfoResponse);
// Operations on bucket aliases // Operations on bucket aliases
// ********************************************** // **********************************************
// ---- GlobalAliasBucket ---- // ---- AddGlobalBucketAlias ----
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct GlobalAliasBucketRequest { pub struct AddGlobalBucketAliasRequest {
pub bucket_id: String, pub bucket_id: String,
pub alias: String, pub alias: String,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct GlobalAliasBucketResponse(pub GetBucketInfoResponse); pub struct AddGlobalBucketAliasResponse(pub GetBucketInfoResponse);
// ---- GlobalUnaliasBucket ---- // ---- RemoveGlobalBucketAlias ----
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct GlobalUnaliasBucketRequest { pub struct RemoveGlobalBucketAliasRequest {
pub bucket_id: String, pub bucket_id: String,
pub alias: String, pub alias: String,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct GlobalUnaliasBucketResponse(pub GetBucketInfoResponse); pub struct RemoveGlobalBucketAliasResponse(pub GetBucketInfoResponse);
// ---- LocalAliasBucket ---- // ---- AddLocalBucketAlias ----
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct LocalAliasBucketRequest { pub struct AddLocalBucketAliasRequest {
pub bucket_id: String, pub bucket_id: String,
pub access_key_id: String, pub access_key_id: String,
pub alias: String, pub alias: String,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct LocalAliasBucketResponse(pub GetBucketInfoResponse); pub struct AddLocalBucketAliasResponse(pub GetBucketInfoResponse);
// ---- LocalUnaliasBucket ---- // ---- RemoveLocalBucketAlias ----
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct LocalUnaliasBucketRequest { pub struct RemoveLocalBucketAliasRequest {
pub bucket_id: String, pub bucket_id: String,
pub access_key_id: String, pub access_key_id: String,
pub alias: String, pub alias: String,
} }
#[derive(Serialize, Deserialize)] #[derive(Serialize, Deserialize)]
pub struct LocalUnaliasBucketResponse(pub GetBucketInfoResponse); pub struct RemoveLocalBucketAliasResponse(pub GetBucketInfoResponse);

View file

@ -22,10 +22,10 @@ use crate::admin::api::{
BucketDenyKeyResponse, BucketKeyPermChangeRequest, BucketLocalAlias, CreateBucketRequest, BucketDenyKeyResponse, BucketKeyPermChangeRequest, BucketLocalAlias, CreateBucketRequest,
CreateBucketResponse, DeleteBucketRequest, DeleteBucketResponse, GetBucketInfoKey, CreateBucketResponse, DeleteBucketRequest, DeleteBucketResponse, GetBucketInfoKey,
GetBucketInfoRequest, GetBucketInfoResponse, GetBucketInfoWebsiteResponse, GetBucketInfoRequest, GetBucketInfoResponse, GetBucketInfoWebsiteResponse,
GlobalAliasBucketRequest, GlobalAliasBucketResponse, GlobalUnaliasBucketRequest, AddGlobalBucketAliasRequest, AddGlobalBucketAliasResponse, RemoveGlobalBucketAliasRequest,
GlobalUnaliasBucketResponse, ListBucketsRequest, ListBucketsResponse, ListBucketsResponseItem, RemoveGlobalBucketAliasResponse, ListBucketsRequest, ListBucketsResponse, ListBucketsResponseItem,
LocalAliasBucketRequest, LocalAliasBucketResponse, LocalUnaliasBucketRequest, AddLocalBucketAliasRequest, AddLocalBucketAliasResponse, RemoveLocalBucketAliasRequest,
LocalUnaliasBucketResponse, UpdateBucketRequest, UpdateBucketResponse, RemoveLocalBucketAliasResponse, UpdateBucketRequest, UpdateBucketResponse,
}; };
use crate::admin::error::*; use crate::admin::error::*;
use crate::admin::EndpointHandler; use crate::admin::EndpointHandler;
@ -453,10 +453,10 @@ pub async fn handle_bucket_change_key_perm(
// ---- BUCKET ALIASES ---- // ---- BUCKET ALIASES ----
#[async_trait] #[async_trait]
impl EndpointHandler for GlobalAliasBucketRequest { impl EndpointHandler for AddGlobalBucketAliasRequest {
type Response = GlobalAliasBucketResponse; type Response = AddGlobalBucketAliasResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GlobalAliasBucketResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<AddGlobalBucketAliasResponse, Error> {
let bucket_id = parse_bucket_id(&self.bucket_id)?; let bucket_id = parse_bucket_id(&self.bucket_id)?;
let helper = garage.locked_helper().await; let helper = garage.locked_helper().await;
@ -465,17 +465,17 @@ impl EndpointHandler for GlobalAliasBucketRequest {
.set_global_bucket_alias(bucket_id, &self.alias) .set_global_bucket_alias(bucket_id, &self.alias)
.await?; .await?;
Ok(GlobalAliasBucketResponse( Ok(AddGlobalBucketAliasResponse(
bucket_info_results(garage, bucket_id).await?, bucket_info_results(garage, bucket_id).await?,
)) ))
} }
} }
#[async_trait] #[async_trait]
impl EndpointHandler for GlobalUnaliasBucketRequest { impl EndpointHandler for RemoveGlobalBucketAliasRequest {
type Response = GlobalUnaliasBucketResponse; type Response = RemoveGlobalBucketAliasResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GlobalUnaliasBucketResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<RemoveGlobalBucketAliasResponse, Error> {
let bucket_id = parse_bucket_id(&self.bucket_id)?; let bucket_id = parse_bucket_id(&self.bucket_id)?;
let helper = garage.locked_helper().await; let helper = garage.locked_helper().await;
@ -484,17 +484,17 @@ impl EndpointHandler for GlobalUnaliasBucketRequest {
.unset_global_bucket_alias(bucket_id, &self.alias) .unset_global_bucket_alias(bucket_id, &self.alias)
.await?; .await?;
Ok(GlobalUnaliasBucketResponse( Ok(RemoveGlobalBucketAliasResponse(
bucket_info_results(garage, bucket_id).await?, bucket_info_results(garage, bucket_id).await?,
)) ))
} }
} }
#[async_trait] #[async_trait]
impl EndpointHandler for LocalAliasBucketRequest { impl EndpointHandler for AddLocalBucketAliasRequest {
type Response = LocalAliasBucketResponse; type Response = AddLocalBucketAliasResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<LocalAliasBucketResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<AddLocalBucketAliasResponse, Error> {
let bucket_id = parse_bucket_id(&self.bucket_id)?; let bucket_id = parse_bucket_id(&self.bucket_id)?;
let helper = garage.locked_helper().await; let helper = garage.locked_helper().await;
@ -503,17 +503,17 @@ impl EndpointHandler for LocalAliasBucketRequest {
.set_local_bucket_alias(bucket_id, &self.access_key_id, &self.alias) .set_local_bucket_alias(bucket_id, &self.access_key_id, &self.alias)
.await?; .await?;
Ok(LocalAliasBucketResponse( Ok(AddLocalBucketAliasResponse(
bucket_info_results(garage, bucket_id).await?, bucket_info_results(garage, bucket_id).await?,
)) ))
} }
} }
#[async_trait] #[async_trait]
impl EndpointHandler for LocalUnaliasBucketRequest { impl EndpointHandler for RemoveLocalBucketAliasRequest {
type Response = LocalUnaliasBucketResponse; type Response = RemoveLocalBucketAliasResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<LocalUnaliasBucketResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<RemoveLocalBucketAliasResponse, Error> {
let bucket_id = parse_bucket_id(&self.bucket_id)?; let bucket_id = parse_bucket_id(&self.bucket_id)?;
let helper = garage.locked_helper().await; let helper = garage.locked_helper().await;
@ -522,7 +522,7 @@ impl EndpointHandler for LocalUnaliasBucketRequest {
.unset_local_bucket_alias(bucket_id, &self.access_key_id, &self.alias) .unset_local_bucket_alias(bucket_id, &self.access_key_id, &self.alias)
.await?; .await?;
Ok(LocalUnaliasBucketResponse( Ok(RemoveLocalBucketAliasResponse(
bucket_info_results(garage, bucket_id).await?, bucket_info_results(garage, bucket_id).await?,
)) ))
} }

View file

@ -55,10 +55,10 @@ impl AdminApiRequest {
POST BucketAllowKey (body), POST BucketAllowKey (body),
POST BucketDenyKey (body), POST BucketDenyKey (body),
// Bucket aliases // Bucket aliases
POST GlobalAliasBucket (body), POST AddGlobalBucketAlias (body),
POST GlobalUnaliasBucket (body), POST RemoveGlobalBucketAlias (body),
POST LocalAliasBucket (body), POST AddLocalBucketAlias (body),
POST LocalUnaliasBucket (body), POST RemoveLocalBucketAlias (body),
]); ]);
if let Some(message) = query.nonempty_message() { if let Some(message) = query.nonempty_message() {
@ -174,14 +174,14 @@ impl AdminApiRequest {
Ok(AdminApiRequest::BucketDenyKey(BucketDenyKeyRequest(req))) Ok(AdminApiRequest::BucketDenyKey(BucketDenyKeyRequest(req)))
} }
// Bucket aliasing // Bucket aliasing
Endpoint::GlobalAliasBucket { id, alias } => Ok(AdminApiRequest::GlobalAliasBucket( Endpoint::GlobalAliasBucket { id, alias } => Ok(AdminApiRequest::AddGlobalBucketAlias(
GlobalAliasBucketRequest { AddGlobalBucketAliasRequest {
bucket_id: id, bucket_id: id,
alias, alias,
}, },
)), )),
Endpoint::GlobalUnaliasBucket { id, alias } => Ok( Endpoint::GlobalUnaliasBucket { id, alias } => Ok(
AdminApiRequest::GlobalUnaliasBucket(GlobalUnaliasBucketRequest { AdminApiRequest::RemoveGlobalBucketAlias(RemoveGlobalBucketAliasRequest {
bucket_id: id, bucket_id: id,
alias, alias,
}), }),
@ -190,7 +190,7 @@ impl AdminApiRequest {
id, id,
access_key_id, access_key_id,
alias, alias,
} => Ok(AdminApiRequest::LocalAliasBucket(LocalAliasBucketRequest { } => Ok(AdminApiRequest::AddLocalBucketAlias(AddLocalBucketAliasRequest {
access_key_id, access_key_id,
bucket_id: id, bucket_id: id,
alias, alias,
@ -199,8 +199,8 @@ impl AdminApiRequest {
id, id,
access_key_id, access_key_id,
alias, alias,
} => Ok(AdminApiRequest::LocalUnaliasBucket( } => Ok(AdminApiRequest::RemoveLocalBucketAlias(
LocalUnaliasBucketRequest { RemoveLocalBucketAliasRequest {
access_key_id, access_key_id,
bucket_id: id, bucket_id: id,
alias, alias,