Skip to content

Commit

Permalink
fix: permissions API Parameters (#516)
Browse files Browse the repository at this point in the history
  • Loading branch information
c-thiel authored Nov 19, 2024
1 parent 0d9d06f commit 5133752
Show file tree
Hide file tree
Showing 8 changed files with 405 additions and 201 deletions.
41 changes: 23 additions & 18 deletions crates/iceberg-catalog/src/api/management/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ pub mod v1 {
rename_default_project,
rename_project_by_id,
rename_warehouse,
search_role,
search_user,
update_role,
update_storage_credential,
Expand Down Expand Up @@ -364,19 +365,17 @@ pub mod v1 {
path = "/management/v1/user/{id}",
params(("id" = Uuid,)),
responses(
(status = 200, description = "User deleted successfully"),
(status = 204, description = "User deleted successfully"),
)
)]
async fn delete_user<C: Catalog, A: Authorizer, S: SecretStore>(
Path(id): Path<UserId>,
AxumState(api_context): AxumState<ApiContext<State<A, C, S>>>,
Extension(metadata): Extension<RequestMetadata>,
) -> Response {
(
StatusCode::OK,
Json(ApiServer::<C, A, S>::delete_user(api_context, metadata, id).await),
)
.into_response()
) -> Result<(StatusCode, ())> {
ApiServer::<C, A, S>::delete_user(api_context, metadata, id)
.await
.map(|()| (StatusCode::NO_CONTENT, ()))
}

/// Create a new role
Expand Down Expand Up @@ -445,7 +444,7 @@ pub mod v1 {
path = "/management/v1/role/{id}",
params(("id" = Uuid,)),
responses(
(status = 200, description = "Role deleted successfully"),
(status = 204, description = "Role deleted successfully"),
)
)]
async fn delete_role<C: Catalog, A: Authorizer, S: SecretStore>(
Expand All @@ -455,7 +454,7 @@ pub mod v1 {
) -> Result<(StatusCode, ())> {
ApiServer::<C, A, S>::delete_role(api_context, metadata, id)
.await
.map(|()| (StatusCode::OK, ()))
.map(|()| (StatusCode::NO_CONTENT, ()))
}

/// Get a role
Expand Down Expand Up @@ -595,14 +594,16 @@ pub mod v1 {
tag = "project",
path = "/management/v1/default-project",
responses(
(status = 200, description = "Project deleted successfully")
(status = 204, description = "Project deleted successfully")
)
)]
async fn delete_default_project<C: Catalog, A: Authorizer, S: SecretStore>(
AxumState(api_context): AxumState<ApiContext<State<A, C, S>>>,
Extension(metadata): Extension<RequestMetadata>,
) -> Result<()> {
ApiServer::<C, A, S>::delete_project(None, api_context, metadata).await
) -> Result<(StatusCode, ())> {
ApiServer::<C, A, S>::delete_project(None, api_context, metadata)
.await
.map(|()| (StatusCode::NO_CONTENT, ()))
}

/// Delete the default project
Expand All @@ -612,15 +613,17 @@ pub mod v1 {
path = "/management/v1/project/{project_id}",
params(("project_id" = Uuid,)),
responses(
(status = 200, description = "Project deleted successfully")
(status = 204, description = "Project deleted successfully")
)
)]
async fn delete_project_by_id<C: Catalog, A: Authorizer, S: SecretStore>(
Path(project_id): Path<ProjectIdent>,
AxumState(api_context): AxumState<ApiContext<State<A, C, S>>>,
Extension(metadata): Extension<RequestMetadata>,
) -> Result<()> {
ApiServer::<C, A, S>::delete_project(Some(project_id), api_context, metadata).await
) -> Result<(StatusCode, ())> {
ApiServer::<C, A, S>::delete_project(Some(project_id), api_context, metadata)
.await
.map(|()| (StatusCode::NO_CONTENT, ()))
}

/// Rename the default project
Expand Down Expand Up @@ -703,15 +706,17 @@ pub mod v1 {
tag = "warehouse",
path = "/management/v1/warehouse/{warehouse_id}",
responses(
(status = 200, description = "Warehouse deleted successfully")
(status = 204, description = "Warehouse deleted successfully")
)
)]
async fn delete_warehouse<C: Catalog, A: Authorizer + Clone, S: SecretStore>(
Path(warehouse_id): Path<uuid::Uuid>,
AxumState(api_context): AxumState<ApiContext<State<A, C, S>>>,
Extension(metadata): Extension<RequestMetadata>,
) -> Result<()> {
ApiServer::<C, A, S>::delete_warehouse(warehouse_id.into(), api_context, metadata).await
) -> Result<(StatusCode, ())> {
ApiServer::<C, A, S>::delete_warehouse(warehouse_id.into(), api_context, metadata)
.await
.map(|()| (StatusCode::NO_CONTENT, ()))
}

/// Rename a warehouse
Expand Down
Loading

0 comments on commit 5133752

Please sign in to comment.