aboutsummaryrefslogtreecommitdiff
path: root/src/api/admin/key.rs
diff options
context:
space:
mode:
authorAlex Auvolat <alex@adnab.me>2022-05-13 14:30:30 +0200
committerAlex Auvolat <alex@adnab.me>2022-05-13 14:30:30 +0200
commitc0fb9fd0fe553e5eda39dcb1a09f059bcd631b6c (patch)
tree4d73c67a540e032190543fc319fad12c409e1e16 /src/api/admin/key.rs
parent983037d965fdcdf089b09fa90fac31501defae9e (diff)
downloadgarage-c0fb9fd0fe553e5eda39dcb1a09f059bcd631b6c.tar.gz
garage-c0fb9fd0fe553e5eda39dcb1a09f059bcd631b6c.zip
Common error type and admin error type that uses it
Diffstat (limited to 'src/api/admin/key.rs')
-rw-r--r--src/api/admin/key.rs16
1 files changed, 8 insertions, 8 deletions
diff --git a/src/api/admin/key.rs b/src/api/admin/key.rs
index 19ad5160..e5f25601 100644
--- a/src/api/admin/key.rs
+++ b/src/api/admin/key.rs
@@ -11,8 +11,8 @@ use garage_table::*;
use garage_model::garage::Garage;
use garage_model::key_table::*;
-use crate::error::*;
-use crate::helpers::*;
+use crate::admin::error::*;
+use crate::admin::parse_json_body;
pub async fn handle_list_keys(garage: &Arc<Garage>) -> Result<Response<Body>, Error> {
let res = garage
@@ -54,13 +54,13 @@ pub async fn handle_get_key_info(
.key_table
.get(&EmptyKey, &id)
.await?
- .ok_or(Error::NoSuchKey)?
+ .ok_or(Error::NoSuchAccessKey)?
} else if let Some(search) = search {
garage
.key_helper()
.get_existing_matching_key(&search)
.await
- .map_err(|_| Error::NoSuchKey)?
+ .map_err(|_| Error::NoSuchAccessKey)?
} else {
unreachable!();
};
@@ -96,9 +96,9 @@ pub async fn handle_update_key(
.key_table
.get(&EmptyKey, &id)
.await?
- .ok_or(Error::NoSuchKey)?;
+ .ok_or(Error::NoSuchAccessKey)?;
- let key_state = key.state.as_option_mut().ok_or(Error::NoSuchKey)?;
+ let key_state = key.state.as_option_mut().ok_or(Error::NoSuchAccessKey)?;
if let Some(new_name) = req.name {
key_state.name.update(new_name);
@@ -131,9 +131,9 @@ pub async fn handle_delete_key(garage: &Arc<Garage>, id: String) -> Result<Respo
.key_table
.get(&EmptyKey, &id)
.await?
- .ok_or(Error::NoSuchKey)?;
+ .ok_or(Error::NoSuchAccessKey)?;
- key.state.as_option().ok_or(Error::NoSuchKey)?;
+ key.state.as_option().ok_or(Error::NoSuchAccessKey)?;
garage.key_helper().delete_key(&mut key).await?;