admin api: convert most bucket operations

This commit is contained in:
Alex Auvolat
2025-01-30 13:36:25 +01:00
parent 819f4f0050
commit f37d5d2b08
10 changed files with 581 additions and 640 deletions
+10 -4
View File
@@ -73,16 +73,22 @@ impl EndpointHandler for GetBucketInfoRequest {
type Response = GetBucketInfoResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GetBucketInfoResponse, Error> {
let bucket_id = match (self.id, self.global_alias) {
(Some(id), None) => parse_bucket_id(&id)?,
(None, Some(ga)) => garage
let bucket_id = match (self.id, self.global_alias, self.search) {
(Some(id), None, None) => parse_bucket_id(&id)?,
(None, Some(ga), None) => garage
.bucket_helper()
.resolve_global_bucket_name(&ga)
.await?
.ok_or_else(|| HelperError::NoSuchBucket(ga.to_string()))?,
(None, None, Some(search)) => {
garage
.bucket_helper()
.admin_get_existing_matching_bucket(&search)
.await?
}
_ => {
return Err(Error::bad_request(
"Either id or globalAlias must be provided (but not both)",
"Either id, globalAlias or search must be provided (but not several of them)",
));
}
};