Search in sources :

Example 21 with Workspace

use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.

the class JobServiceTest method runFlight.

// Submit a flight; wait for it to finish; return the flight id
// Use the jobId defaulting in the JobBuilder
private String runFlight(String description) {
    // workspace must exist in the Dao for authorization check to pass
    UUID workspaceId = UUID.randomUUID();
    Workspace workspace = Workspace.builder().workspaceId(workspaceId).workspaceStage(WorkspaceStage.MC_WORKSPACE).description("Workspace for runFlight: " + description).build();
    workspaceDao.createWorkspace(workspace);
    String jobId = jobService.newJob().description(description).flightClass(JobServiceTestFlight.class).userRequest(testUser).workspaceId(workspaceId.toString()).submit();
    jobService.waitForJob(jobId);
    return jobId;
}
Also used : UUID(java.util.UUID) Workspace(bio.terra.workspace.service.workspace.model.Workspace)

Example 22 with Workspace

use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.

the class ResourceDaoTest method createGcpWorkspace.

/**
 * Creates a workspaces with a GCP cloud context and stores it in the database. Returns the
 * workspace id.
 *
 * <p>The {@link ResourceDao#createControlledResource(ControlledResource)} checks that a relevant
 * cloud context exists before storing the resource.
 */
private UUID createGcpWorkspace() {
    Workspace workspace = Workspace.builder().workspaceId(UUID.randomUUID()).workspaceStage(WorkspaceStage.MC_WORKSPACE).build();
    workspaceDao.createWorkspace(workspace);
    WorkspaceFixtures.createGcpCloudContextInDatabase(workspaceDao, workspace.getWorkspaceId(), "my-project-id");
    return workspace.getWorkspaceId();
}
Also used : Workspace(bio.terra.workspace.service.workspace.model.Workspace)

Example 23 with Workspace

use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.

the class WorkspaceApiController method getWorkspace.

@Override
public ResponseEntity<ApiWorkspaceDescription> getWorkspace(@PathVariable("workspaceId") UUID id) {
    AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
    logger.info("Getting workspace {} for {}", id, userRequest.getEmail());
    Workspace workspace = workspaceService.getWorkspace(id, userRequest);
    ApiWorkspaceDescription desc = buildWorkspaceDescription(workspace);
    logger.info("Got workspace {} for {}", desc, userRequest.getEmail());
    return new ResponseEntity<>(desc, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) ApiWorkspaceDescription(bio.terra.workspace.generated.model.ApiWorkspaceDescription) ApiCreatedWorkspace(bio.terra.workspace.generated.model.ApiCreatedWorkspace) Workspace(bio.terra.workspace.service.workspace.model.Workspace) ApiClonedWorkspace(bio.terra.workspace.generated.model.ApiClonedWorkspace)

Example 24 with Workspace

use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.

the class WorkspaceApiController method listWorkspaces.

@Override
public ResponseEntity<ApiWorkspaceDescriptionList> listWorkspaces(Integer offset, Integer limit) {
    AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
    logger.info("Listing workspaces for {}", userRequest.getEmail());
    ControllerValidationUtils.validatePaginationParams(offset, limit);
    List<Workspace> workspaces = workspaceService.listWorkspaces(userRequest, offset, limit);
    var response = new ApiWorkspaceDescriptionList().workspaces(workspaces.stream().map(this::buildWorkspaceDescription).collect(Collectors.toList()));
    return new ResponseEntity<>(response, HttpStatus.OK);
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) ApiWorkspaceDescriptionList(bio.terra.workspace.generated.model.ApiWorkspaceDescriptionList) ApiCreatedWorkspace(bio.terra.workspace.generated.model.ApiCreatedWorkspace) Workspace(bio.terra.workspace.service.workspace.model.Workspace) ApiClonedWorkspace(bio.terra.workspace.generated.model.ApiClonedWorkspace)

Example 25 with Workspace

use of bio.terra.workspace.service.workspace.model.Workspace in project terra-workspace-manager by DataBiosphere.

the class WsmApplicationService method getWorkspaceApplication.

public WsmWorkspaceApplication getWorkspaceApplication(AuthenticatedUserRequest userRequest, UUID workspaceId, UUID applicationId) {
    Workspace workspace = workspaceService.validateWorkspaceAndAction(userRequest, workspaceId, SamConstants.SamWorkspaceAction.READ);
    stageService.assertMcWorkspace(workspace, "getWorkspaceApplication");
    return applicationDao.getWorkspaceApplication(workspaceId, applicationId);
}
Also used : Workspace(bio.terra.workspace.service.workspace.model.Workspace)

Aggregations

Workspace (bio.terra.workspace.service.workspace.model.Workspace)56 Test (org.junit.jupiter.api.Test)32 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)23 UUID (java.util.UUID)13 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)9 BaseUnitTest (bio.terra.workspace.common.BaseUnitTest)8 FlightDebugInfo (bio.terra.stairway.FlightDebugInfo)6 HashMap (java.util.HashMap)6 FlightMap (bio.terra.stairway.FlightMap)5 StepStatus (bio.terra.stairway.StepStatus)5 ApiClonedWorkspace (bio.terra.workspace.generated.model.ApiClonedWorkspace)5 ApiCreatedWorkspace (bio.terra.workspace.generated.model.ApiCreatedWorkspace)5 SpendProfileId (bio.terra.workspace.service.spendprofile.SpendProfileId)5 DisabledIfEnvironmentVariable (org.junit.jupiter.api.condition.DisabledIfEnvironmentVariable)5 ResponseEntity (org.springframework.http.ResponseEntity)5 Traced (io.opencensus.contrib.spring.aop.Traced)4 FlightState (bio.terra.stairway.FlightState)3 ControlledBigQueryDatasetResource (bio.terra.workspace.service.resource.controlled.cloud.gcp.bqdataset.ControlledBigQueryDatasetResource)3 CreateWorkspaceStep (bio.terra.workspace.service.workspace.flight.CreateWorkspaceStep)3 GcpCloudContext (bio.terra.workspace.service.workspace.model.GcpCloudContext)3