use of bio.terra.workspace.generated.model.ApiCreatedControlledGcpAiNotebookInstanceResult in project terra-workspace-manager by DataBiosphere.
the class ControlledGcpResourceApiController method getCreateAiNotebookInstanceResult.
@Override
public ResponseEntity<ApiCreatedControlledGcpAiNotebookInstanceResult> getCreateAiNotebookInstanceResult(UUID workspaceId, String jobId) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ApiCreatedControlledGcpAiNotebookInstanceResult result = fetchNotebookInstanceCreateResult(jobId, userRequest);
return new ResponseEntity<>(result, getAsyncResponseCode(result.getJobReport()));
}
use of bio.terra.workspace.generated.model.ApiCreatedControlledGcpAiNotebookInstanceResult in project terra-workspace-manager by DataBiosphere.
the class ControlledGcpResourceApiController method createAiNotebookInstance.
@Override
public ResponseEntity<ApiCreatedControlledGcpAiNotebookInstanceResult> createAiNotebookInstance(UUID workspaceId, @Valid ApiCreateControlledGcpAiNotebookInstanceRequestBody body) {
AuthenticatedUserRequest userRequest = getAuthenticatedInfo();
ControlledResourceFields commonFields = toCommonFields(workspaceId, body.getCommon(), userRequest);
String projectId = workspaceService.getAuthorizedRequiredGcpProject(workspaceId, userRequest);
ControlledAiNotebookInstanceResource resource = ControlledAiNotebookInstanceResource.builder().common(commonFields).location(body.getAiNotebookInstance().getLocation()).projectId(projectId).instanceId(Optional.ofNullable(body.getAiNotebookInstance().getInstanceId()).orElse(ControlledAiNotebookInstanceResource.generateInstanceId(commonFields.getAssignedUser()))).build();
String jobId = controlledResourceService.createAiNotebookInstance(resource, body.getAiNotebookInstance(), commonFields.getIamRole(), body.getJobControl(), getAsyncResultEndpoint(body.getJobControl().getId(), "create-result"), userRequest);
ApiCreatedControlledGcpAiNotebookInstanceResult result = fetchNotebookInstanceCreateResult(jobId, userRequest);
return new ResponseEntity<>(result, getAsyncResponseCode((result.getJobReport())));
}
use of bio.terra.workspace.generated.model.ApiCreatedControlledGcpAiNotebookInstanceResult in project terra-workspace-manager by DataBiosphere.
the class ControlledGcpResourceApiController method fetchNotebookInstanceCreateResult.
private ApiCreatedControlledGcpAiNotebookInstanceResult fetchNotebookInstanceCreateResult(String jobId, AuthenticatedUserRequest userRequest) {
AsyncJobResult<ControlledAiNotebookInstanceResource> jobResult = jobService.retrieveAsyncJobResult(jobId, ControlledAiNotebookInstanceResource.class, userRequest);
ApiGcpAiNotebookInstanceResource apiResource = null;
if (jobResult.getJobReport().getStatus().equals(ApiJobReport.StatusEnum.SUCCEEDED)) {
ControlledAiNotebookInstanceResource resource = jobResult.getResult();
apiResource = resource.toApiResource();
}
return new ApiCreatedControlledGcpAiNotebookInstanceResult().jobReport(jobResult.getJobReport()).errorReport(jobResult.getApiErrorReport()).aiNotebookInstance(apiResource);
}
Aggregations