Search in sources :

Example 1 with ApiWorkspaceDescription

use of bio.terra.workspace.generated.model.ApiWorkspaceDescription 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 2 with ApiWorkspaceDescription

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

the class WorkspaceApiController method buildWorkspaceDescription.

private ApiWorkspaceDescription buildWorkspaceDescription(Workspace workspace) {
    ApiGcpContext gcpContext = gcpCloudContextService.getGcpCloudContext(workspace.getWorkspaceId()).map(GcpCloudContext::toApi).orElse(null);
    ApiAzureContext azureContext = azureCloudContextService.getAzureCloudContext(workspace.getWorkspaceId()).map(AzureCloudContext::toApi).orElse(null);
    // Convert the property map to API format
    ApiProperties apiProperties = new ApiProperties();
    workspace.getProperties().forEach((k, v) -> apiProperties.add(new ApiProperty().key(k).value(v)));
    // When we have another cloud context, we will need to do a similar retrieval for it.
    return new ApiWorkspaceDescription().id(workspace.getWorkspaceId()).spendProfile(workspace.getSpendProfileId().map(SpendProfileId::getId).orElse(null)).stage(workspace.getWorkspaceStage().toApiModel()).gcpContext(gcpContext).azureContext(azureContext).displayName(workspace.getDisplayName().orElse(null)).description(workspace.getDescription().orElse(null)).properties(apiProperties);
}
Also used : ApiProperty(bio.terra.workspace.generated.model.ApiProperty) ApiProperties(bio.terra.workspace.generated.model.ApiProperties) ApiGcpContext(bio.terra.workspace.generated.model.ApiGcpContext) ApiWorkspaceDescription(bio.terra.workspace.generated.model.ApiWorkspaceDescription) SpendProfileId(bio.terra.workspace.service.spendprofile.SpendProfileId) ApiAzureContext(bio.terra.workspace.generated.model.ApiAzureContext)

Example 3 with ApiWorkspaceDescription

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

the class WorkspaceApiController method updateWorkspace.

@Override
public ResponseEntity<ApiWorkspaceDescription> updateWorkspace(@PathVariable("workspaceId") UUID workspaceId, @RequestBody ApiUpdateWorkspaceRequestBody body) {
    AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
    logger.info("Updating workspace {} for {}", workspaceId, userRequest.getEmail());
    Map<String, String> propertyMap = null;
    if (body.getProperties() != null) {
        propertyMap = propertyMapFromApi(body.getProperties());
    }
    Workspace workspace = workspaceService.updateWorkspace(userRequest, workspaceId, body.getDisplayName(), body.getDescription(), propertyMap);
    ApiWorkspaceDescription desc = buildWorkspaceDescription(workspace);
    logger.info("Updated 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)

Aggregations

ApiWorkspaceDescription (bio.terra.workspace.generated.model.ApiWorkspaceDescription)3 ApiClonedWorkspace (bio.terra.workspace.generated.model.ApiClonedWorkspace)2 ApiCreatedWorkspace (bio.terra.workspace.generated.model.ApiCreatedWorkspace)2 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)2 Workspace (bio.terra.workspace.service.workspace.model.Workspace)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ApiAzureContext (bio.terra.workspace.generated.model.ApiAzureContext)1 ApiGcpContext (bio.terra.workspace.generated.model.ApiGcpContext)1 ApiProperties (bio.terra.workspace.generated.model.ApiProperties)1 ApiProperty (bio.terra.workspace.generated.model.ApiProperty)1 SpendProfileId (bio.terra.workspace.service.spendprofile.SpendProfileId)1