use of bio.terra.workspace.generated.model.ApiWorkspaceStageModel in project terra-workspace-manager by DataBiosphere.
the class WorkspaceApiController method createWorkspace.
@Override
public ResponseEntity<ApiCreatedWorkspace> createWorkspace(@RequestBody ApiCreateWorkspaceRequestBody body) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
logger.info("Creating workspace {} for {} subject {}", body.getId(), userRequest.getEmail(), userRequest.getSubjectId());
// Existing client libraries should not need to know about the stage, as they won't use any of
// the features it gates. If stage isn't specified in a create request, we default to
// RAWLS_WORKSPACE.
ApiWorkspaceStageModel requestStage = body.getStage();
requestStage = (requestStage == null ? ApiWorkspaceStageModel.RAWLS_WORKSPACE : requestStage);
WorkspaceStage internalStage = WorkspaceStage.fromApiModel(requestStage);
Optional<SpendProfileId> spendProfileId = Optional.ofNullable(body.getSpendProfile()).map(SpendProfileId::new);
Workspace workspace = Workspace.builder().workspaceId(body.getId()).spendProfileId(spendProfileId.orElse(null)).workspaceStage(internalStage).displayName(body.getDisplayName()).description(body.getDescription()).properties(propertyMapFromApi(body.getProperties())).build();
UUID createdId = workspaceService.createWorkspace(workspace, userRequest);
ApiCreatedWorkspace responseWorkspace = new ApiCreatedWorkspace().id(createdId);
logger.info("Created workspace {} for {}", responseWorkspace, userRequest.getEmail());
return new ResponseEntity<>(responseWorkspace, HttpStatus.OK);
}
Aggregations