use of bio.terra.workspace.model.GcpAiNotebookInstanceCreationParameters in project terra-workspace-manager by DataBiosphere.
the class NotebookUtils method makeControlledNotebookUserPrivate.
/**
* Create and return a private AI Platform Notebook controlled resource with constant values. This
* method calls the asynchronous creation endpoint and polls until the creation job completes.
*/
public static CreatedControlledGcpAiNotebookInstanceResult makeControlledNotebookUserPrivate(UUID workspaceId, @Nullable String instanceId, @Nullable String location, ControlledGcpResourceApi resourceApi) throws ApiException, InterruptedException {
// Fill out the minimum required fields to arbitrary values.
var creationParameters = new GcpAiNotebookInstanceCreationParameters().instanceId(instanceId).location(location).machineType("e2-standard-2").vmImage(new GcpAiNotebookInstanceVmImage().projectId("deeplearning-platform-release").imageFamily("r-latest-cpu-experimental"));
var commonParameters = new ControlledResourceCommonFields().name(RandomStringUtils.randomAlphabetic(6)).cloningInstructions(CloningInstructionsEnum.NOTHING).accessScope(AccessScope.PRIVATE_ACCESS).managedBy(ManagedBy.USER).privateResourceUser(null);
var body = new CreateControlledGcpAiNotebookInstanceRequestBody().aiNotebookInstance(creationParameters).common(commonParameters).jobControl(new JobControl().id(UUID.randomUUID().toString()));
var creationResult = resourceApi.createAiNotebookInstance(body, workspaceId);
String creationJobId = creationResult.getJobReport().getId();
creationResult = ClientTestUtils.pollWhileRunning(creationResult, () -> resourceApi.getCreateAiNotebookInstanceResult(workspaceId, creationJobId), CreatedControlledGcpAiNotebookInstanceResult::getJobReport, Duration.ofSeconds(10));
ClientTestUtils.assertJobSuccess("create ai notebook", creationResult.getJobReport(), creationResult.getErrorReport());
return creationResult;
}
Aggregations