Search in sources :

Example 1 with ApiCreatedControlledGcpAiNotebookInstanceResult

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()));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ApiCreatedControlledGcpAiNotebookInstanceResult(bio.terra.workspace.generated.model.ApiCreatedControlledGcpAiNotebookInstanceResult) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest)

Example 2 with ApiCreatedControlledGcpAiNotebookInstanceResult

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())));
}
Also used : ResponseEntity(org.springframework.http.ResponseEntity) ApiCreatedControlledGcpAiNotebookInstanceResult(bio.terra.workspace.generated.model.ApiCreatedControlledGcpAiNotebookInstanceResult) AuthenticatedUserRequest(bio.terra.workspace.service.iam.AuthenticatedUserRequest) ControlledResourceFields(bio.terra.workspace.service.resource.controlled.model.ControlledResourceFields) ControlledAiNotebookInstanceResource(bio.terra.workspace.service.resource.controlled.cloud.gcp.ainotebook.ControlledAiNotebookInstanceResource)

Example 3 with ApiCreatedControlledGcpAiNotebookInstanceResult

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);
}
Also used : ApiGcpAiNotebookInstanceResource(bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceResource) ApiCreatedControlledGcpAiNotebookInstanceResult(bio.terra.workspace.generated.model.ApiCreatedControlledGcpAiNotebookInstanceResult) ControlledAiNotebookInstanceResource(bio.terra.workspace.service.resource.controlled.cloud.gcp.ainotebook.ControlledAiNotebookInstanceResource)

Aggregations

ApiCreatedControlledGcpAiNotebookInstanceResult (bio.terra.workspace.generated.model.ApiCreatedControlledGcpAiNotebookInstanceResult)3 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)2 ControlledAiNotebookInstanceResource (bio.terra.workspace.service.resource.controlled.cloud.gcp.ainotebook.ControlledAiNotebookInstanceResource)2 ResponseEntity (org.springframework.http.ResponseEntity)2 ApiGcpAiNotebookInstanceResource (bio.terra.workspace.generated.model.ApiGcpAiNotebookInstanceResource)1 ControlledResourceFields (bio.terra.workspace.service.resource.controlled.model.ControlledResourceFields)1