admin API refactoring (step 1) #939

Merged
lx merged 19 commits from refactor-admin into next-v2 2025-01-29 20:42:57 +00:00
Showing only changes of commit 1c03941b19 - Show all commits

View file

@ -43,15 +43,19 @@ impl EndpointHandler for GetKeyInfoRequest {
type Response = GetKeyInfoResponse; type Response = GetKeyInfoResponse;
async fn handle(self, garage: &Arc<Garage>) -> Result<GetKeyInfoResponse, Error> { async fn handle(self, garage: &Arc<Garage>) -> Result<GetKeyInfoResponse, Error> {
let key = if let Some(id) = self.id { let key = match (self.id, self.search) {
garage.key_helper().get_existing_key(&id).await? (Some(id), None) => garage.key_helper().get_existing_key(&id).await?,
} else if let Some(search) = self.search { (None, Some(search)) => {
garage garage
.key_helper() .key_helper()
.get_existing_matching_key(&search) .get_existing_matching_key(&search)
.await? .await?
} else { }
unreachable!(); _ => {
return Err(Error::bad_request(
"Either id or search must be provided (but not both)",
));
}
}; };
Ok(key_info_results(garage, key, self.show_secret_key).await?) Ok(key_info_results(garage, key, self.show_secret_key).await?)