Skip to content

Commit

Permalink
fix linting issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Matthew Fortunka committed Feb 14, 2025
1 parent c1f6b84 commit 79248b6
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 5 deletions.
1 change: 0 additions & 1 deletion api_app/_version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
__version__ = "0.22.0"

2 changes: 2 additions & 0 deletions api_app/api/routes/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,11 @@
from core import config
from resources import strings


def _is_user_management_enabled():
return config.USER_MANAGEMENT_ENABLED


core_tags_metadata = [
{"name": "health", "description": "Verify that the TRE is up and running"},
{"name": "workspace templates", "description": "**TRE admin** registers and can access templates"},
Expand Down
6 changes: 5 additions & 1 deletion api_app/api/routes/workspace_users.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,14 @@
workspaces_users_admin_router = APIRouter(dependencies=[Depends(get_current_admin_user)])
workspaces_users_shared_router = APIRouter(dependencies=[Depends(get_current_workspace_owner_or_researcher_user_or_airlock_manager_or_tre_admin)])


@workspaces_users_shared_router.get("/workspaces/{workspace_id}/users", response_model=UsersInResponse, name=strings.API_GET_WORKSPACE_USERS)
async def get_workspace_users(workspace=Depends(get_workspace_by_id_from_path)) -> UsersInResponse:
access_service = get_access_service()
users = access_service.get_workspace_users(workspace)
return UsersInResponse(users=users)


@workspaces_users_admin_router.get("/workspaces/{workspace_id}/assignable-users", response_model=AssignableUsersInResponse, name=strings.API_GET_ASSIGNABLE_USERS)
async def get_assignable_users(workspace=Depends(get_workspace_by_id_from_path)) -> AssignableUsersInResponse:
access_service = get_access_service()
Expand All @@ -28,6 +30,7 @@ async def get_workspace_roles(workspace=Depends(get_workspace_by_id_from_path))
roles = access_service.get_workspace_roles(workspace)
return RolesInResponse(roles=roles)


@workspaces_users_admin_router.post("/workspaces/{workspace_id}/users/assign", status_code=status.HTTP_202_ACCEPTED, name=strings.API_ASSIGN_WORKSPACE_USER)
async def assign_workspace_user(response: Response, user_email: str, role_name: str, workspace=Depends(get_workspace_by_id_from_path)) -> UsersInResponse:
access_service = get_access_service()
Expand All @@ -38,12 +41,13 @@ async def assign_workspace_user(response: Response, user_email: str, role_name:
access_service.assign_workspace_user(
user,
workspace,
role,
role
)

users = access_service.get_workspace_users(workspace)
return UsersInResponse(users=users)


@workspaces_users_admin_router.delete("/workspaces/{workspace_id}/users/assign",
status_code=status.HTTP_202_ACCEPTED,
name=strings.API_REMOVE_WORKSPACE_USER_ASSIGNMENT)
Expand Down
4 changes: 1 addition & 3 deletions api_app/api/routes/workspaces.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
user_resources_workspace_router = APIRouter(dependencies=[Depends(get_current_workspace_owner_or_researcher_user_or_airlock_manager)])



def validate_user_has_valid_role_for_user_resource(user, user_resource):
if "WorkspaceOwner" in user.roles:
return
Expand Down Expand Up @@ -186,6 +185,7 @@ async def invoke_action_on_workspace(response: Response, action: str, user=Depen

return OperationInResponse(operation=operation)


# workspace operations
# This method only returns templates that the authenticated user is authorized to use
@workspaces_shared_router.get("/workspaces/{workspace_id}/workspace-service-templates", response_model=ResourceTemplateInformationInList, name=strings.API_GET_WORKSPACE_SERVICE_TEMPLATES_IN_WORKSPACE)
Expand Down Expand Up @@ -534,5 +534,3 @@ async def retrieve_user_resource_operations_by_user_resource_id_and_operation_id
async def retrieve_user_resource_history_by_user_resource_id(user_resource=Depends(get_user_resource_by_id_from_path), user=Depends(get_current_workspace_owner_or_researcher_user_or_airlock_manager), resource_history_repo=Depends(get_repository(ResourceHistoryRepository))) -> ResourceHistoryInList:
validate_user_has_valid_role_for_user_resource(user, user_resource)
return ResourceHistoryInList(resource_history=await resource_history_repo.get_resource_history_by_resource_id(resource_id=user_resource.id))


0 comments on commit 79248b6

Please sign in to comment.