Search in sources :

Example 1 with ApiCloneWorkspaceResult

use of bio.terra.workspace.generated.model.ApiCloneWorkspaceResult in project terra-workspace-manager by DataBiosphere.

the class WorkspaceApiController method getCloneWorkspaceResult.

/**
 * Return the workspace clone result, including job result and error result.
 *
 * @param workspaceId - source workspace ID
 * @param jobId - ID of flight
 * @return - response with result
 */
@Override
public ResponseEntity<ApiCloneWorkspaceResult> getCloneWorkspaceResult(UUID workspaceId, String jobId) {
    final AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
    final ApiCloneWorkspaceResult result = fetchCloneWorkspaceResult(jobId, userRequest);
    return new ResponseEntity<>(result, getAsyncResponseCode(result.getJobReport()));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ApiCloneWorkspaceResult(bio.terra.workspace.generated.model.ApiCloneWorkspaceResult) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest)

Example 2 with ApiCloneWorkspaceResult

use of bio.terra.workspace.generated.model.ApiCloneWorkspaceResult in project terra-workspace-manager by DataBiosphere.

the class WorkspaceApiController method cloneWorkspace.

/**
 * Clone an entire workspace by creating a new workspace and cloning the workspace's resources
 * into it.
 *
 * @param workspaceId - ID of source workspace
 * @param body - request body
 * @return - result structure for the overall clone operation with details for each resource
 */
@Override
public ResponseEntity<ApiCloneWorkspaceResult> cloneWorkspace(UUID workspaceId, @Valid ApiCloneWorkspaceRequest body) {
    final AuthenticatedUserRequest petRequest = getCloningCredentials(workspaceId);
    Optional<SpendProfileId> spendProfileId = Optional.ofNullable(body.getSpendProfile()).map(SpendProfileId::new);
    // Construct the target workspace object from the inputs
    Workspace destinationWorkspace = Workspace.builder().workspaceId(UUID.randomUUID()).spendProfileId(spendProfileId.orElse(null)).workspaceStage(WorkspaceStage.MC_WORKSPACE).displayName(body.getDisplayName()).description(body.getDescription()).properties(propertyMapFromApi(body.getProperties())).build();
    final String jobId = workspaceService.cloneWorkspace(workspaceId, petRequest, body.getLocation(), destinationWorkspace);
    final ApiCloneWorkspaceResult result = fetchCloneWorkspaceResult(jobId, getAuthenticatedInfo());
    return new ResponseEntity<>(result, getAsyncResponseCode(result.getJobReport()));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ApiCloneWorkspaceResult(bio.terra.workspace.generated.model.ApiCloneWorkspaceResult) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) SpendProfileId(bio.terra.workspace.service.spendprofile.SpendProfileId) ApiCreatedWorkspace(bio.terra.workspace.generated.model.ApiCreatedWorkspace) Workspace(bio.terra.workspace.service.workspace.model.Workspace) ApiClonedWorkspace(bio.terra.workspace.generated.model.ApiClonedWorkspace)

Aggregations

ApiCloneWorkspaceResult (bio.terra.workspace.generated.model.ApiCloneWorkspaceResult)2 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ApiClonedWorkspace (bio.terra.workspace.generated.model.ApiClonedWorkspace)1 ApiCreatedWorkspace (bio.terra.workspace.generated.model.ApiCreatedWorkspace)1 SpendProfileId (bio.terra.workspace.service.spendprofile.SpendProfileId)1 Workspace (bio.terra.workspace.service.workspace.model.Workspace)1