use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceService method deleteGcpCloudContext.
/**
* Delete the GCP cloud context for the workspace. Verifies workspace existence and write
* permission before deleting the cloud context.
*/
@Traced
public void deleteGcpCloudContext(UUID workspaceUuid, AuthenticatedUserRequest userRequest) {
Workspace workspace = validateWorkspaceAndAction(userRequest, workspaceUuid, SamConstants.SamWorkspaceAction.WRITE);
stageService.assertMcWorkspace(workspace, "deleteGcpCloudContext");
String workspaceName = workspace.getDisplayName().orElse("");
String jobDescription = String.format("Delete GCP cloud context for workspace: name: '%s' id: '%s' ", workspaceName, workspaceUuid);
jobService.newJob().description(jobDescription).flightClass(DeleteGcpContextFlight.class).userRequest(userRequest).operationType(OperationType.DELETE).workspaceId(workspaceUuid.toString()).submitAndWait(null);
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceService method deleteAzureCloudContext.
public void deleteAzureCloudContext(UUID workspaceUuid, AuthenticatedUserRequest userRequest) {
Workspace workspace = validateWorkspaceAndAction(userRequest, workspaceUuid, SamWorkspaceAction.WRITE);
stageService.assertMcWorkspace(workspace, "deleteAzureCloudContext");
String workspaceName = workspace.getDisplayName().orElse("");
String jobDescription = String.format("Delete Azure cloud context for workspace: name: '%s' id: '%s' ", workspaceName, workspaceUuid);
jobService.newJob().description(jobDescription).flightClass(DeleteAzureContextFlight.class).userRequest(userRequest).operationType(OperationType.DELETE).workspaceId(workspaceUuid.toString()).submitAndWait(null);
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceService method removeWorkspaceRoleFromUser.
/**
* Remove a workspace role from a user. This will also remove a user from their private resources
* if they are no longer a member of the workspace (i.e. have no other roles) after role removal.
*
* @param workspaceUuid ID of the workspace user to remove user's role in
* @param role Role to remove
* @param rawUserEmail Email identifier of user whose role is being removed
* @param executingUserRequest User credentials to authenticate this removal. Must belong to a
* workspace owner, and likely do not belong to {@code userEmail}.
*/
public void removeWorkspaceRoleFromUser(UUID workspaceUuid, WsmIamRole role, String rawUserEmail, AuthenticatedUserRequest executingUserRequest) {
Workspace workspace = validateWorkspaceAndAction(executingUserRequest, workspaceUuid, SamConstants.SamWorkspaceAction.OWN);
stageService.assertMcWorkspace(workspace, "removeWorkspaceRoleFromUser");
// GCP always uses lowercase email identifiers, so we do the same here.
String targetUserEmail = rawUserEmail.toLowerCase();
// Before launching the flight, validate that the user being removed is a direct member of the
// specified role. Users may also be added to a workspace via managed groups, but WSM does not
// control membership of those groups, and so cannot remove them here.
List<String> roleMembers = samService.listUsersWithWorkspaceRole(workspaceUuid, role, executingUserRequest).stream().map(String::toLowerCase).collect(Collectors.toList());
if (!roleMembers.contains(targetUserEmail)) {
return;
}
jobService.newJob().description(String.format("Remove role %s from user %s in workspace %s", role.name(), targetUserEmail, workspaceUuid)).flightClass(RemoveUserFromWorkspaceFlight.class).userRequest(executingUserRequest).operationType(OperationType.DELETE).workspaceId(workspaceUuid.toString()).addParameter(WorkspaceFlightMapKeys.USER_TO_REMOVE, targetUserEmail).addParameter(WorkspaceFlightMapKeys.ROLE_TO_REMOVE, role).submitAndWait(null);
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceService method getWorkspaceByUserFacingId.
/**
* Retrieves an existing workspace by userFacingId
*/
@Traced
public Workspace getWorkspaceByUserFacingId(String userFacingId, AuthenticatedUserRequest userRequest) {
logger.info("getWorkspaceByUserFacingId - userRequest: {}\nuserFacingId: {}", userRequest, userFacingId);
Workspace workspace = workspaceDao.getWorkspaceByUserFacingId(userFacingId);
SamRethrow.onInterrupted(() -> samService.checkAuthz(userRequest, SamConstants.SamResource.WORKSPACE, workspace.getWorkspaceId().toString(), SamWorkspaceAction.READ), "checkAuthz");
return workspace;
}
use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.
the class WorkspaceService method deleteWorkspace.
/**
* Delete an existing workspace by ID.
*/
@Traced
public void deleteWorkspace(UUID uuid, AuthenticatedUserRequest userRequest) {
Workspace workspace = validateWorkspaceAndAction(userRequest, uuid, SamWorkspaceAction.DELETE);
String description = "Delete workspace " + uuid;
JobBuilder deleteJob = jobService.newJob().description(description).flightClass(WorkspaceDeleteFlight.class).operationType(OperationType.DELETE).workspaceId(uuid.toString()).userRequest(userRequest).addParameter(WorkspaceFlightMapKeys.WORKSPACE_STAGE, workspace.getWorkspaceStage().name());
// Skip access check, which can't succeed after the workspace is deleted
deleteJob.submitAndWait(null, false);
}
Aggregations