use of bio.terra.workspace.generated.model.ApiGcpContext 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);
}
use of bio.terra.workspace.generated.model.ApiGcpContext in project terra-workspace-manager by DataBiosphere.
the class WorkspaceApiController method fetchCreateCloudContextResult.
private ApiCreateCloudContextResult fetchCreateCloudContextResult(String jobId, AuthenticatedUserRequest userRequest) {
final AsyncJobResult<CloudContextHolder> jobResult = jobService.retrieveAsyncJobResult(jobId, CloudContextHolder.class, userRequest);
ApiGcpContext gcpContext = null;
ApiAzureContext azureContext = null;
if (jobResult.getJobReport().getStatus().equals(StatusEnum.SUCCEEDED)) {
gcpContext = Optional.ofNullable(jobResult.getResult().getGcpCloudContext()).map(c -> new ApiGcpContext().projectId(c.getGcpProjectId())).orElse(null);
azureContext = Optional.ofNullable(jobResult.getResult().getAzureCloudContext()).map(c -> new ApiAzureContext().tenantId(c.getAzureTenantId()).subscriptionId(c.getAzureSubscriptionId()).resourceGroupId(c.getAzureResourceGroupId())).orElse(null);
}
return new ApiCreateCloudContextResult().jobReport(jobResult.getJobReport()).errorReport(jobResult.getApiErrorReport()).gcpContext(gcpContext).azureContext(azureContext);
}
Aggregations