use of bio.terra.workspace.generated.model.ApiCreateCloudContextResult in project terra-workspace-manager by DataBiosphere.
the class WorkspaceApiController method getCreateCloudContextResult.
@Override
public ResponseEntity<ApiCreateCloudContextResult> getCreateCloudContextResult(UUID id, String jobId) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ApiCreateCloudContextResult response = fetchCreateCloudContextResult(jobId, userRequest);
return new ResponseEntity<>(response, getAsyncResponseCode(response.getJobReport()));
}
use of bio.terra.workspace.generated.model.ApiCreateCloudContextResult 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);
}
use of bio.terra.workspace.generated.model.ApiCreateCloudContextResult in project terra-workspace-manager by DataBiosphere.
the class WorkspaceApiController method createCloudContext.
@Override
public ResponseEntity<ApiCreateCloudContextResult> createCloudContext(UUID id, @Valid ApiCreateCloudContextRequest body) {
ControllerValidationUtils.validateCloudPlatform(body.getCloudPlatform());
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
String jobId = body.getJobControl().getId();
String resultPath = getAsyncResultEndpoint(jobId);
if (body.getCloudPlatform() == ApiCloudPlatform.AZURE) {
ApiAzureContext azureContext = Optional.ofNullable(body.getAzureContext()).orElseThrow(() -> new CloudContextRequiredException("AzureContext is required when creating an azure cloud context for a workspace"));
workspaceService.createAzureCloudContext(id, jobId, userRequest, resultPath, AzureCloudContext.fromApi(azureContext));
} else {
workspaceService.createGcpCloudContext(id, jobId, userRequest, resultPath);
}
ApiCreateCloudContextResult response = fetchCreateCloudContextResult(jobId, userRequest);
return new ResponseEntity<>(response, getAsyncResponseCode(response.getJobReport()));
}
Aggregations