Search in sources :

Example 1 with GcpAiNotebookInstanceCreationParameters

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;
}
Also used : GcpAiNotebookInstanceCreationParameters(bio.terra.workspace.model.GcpAiNotebookInstanceCreationParameters) ControlledResourceCommonFields(bio.terra.workspace.model.ControlledResourceCommonFields) CreateControlledGcpAiNotebookInstanceRequestBody(bio.terra.workspace.model.CreateControlledGcpAiNotebookInstanceRequestBody) JobControl(bio.terra.workspace.model.JobControl) GcpAiNotebookInstanceVmImage(bio.terra.workspace.model.GcpAiNotebookInstanceVmImage)

Aggregations

ControlledResourceCommonFields (bio.terra.workspace.model.ControlledResourceCommonFields)1 CreateControlledGcpAiNotebookInstanceRequestBody (bio.terra.workspace.model.CreateControlledGcpAiNotebookInstanceRequestBody)1 GcpAiNotebookInstanceCreationParameters (bio.terra.workspace.model.GcpAiNotebookInstanceCreationParameters)1 GcpAiNotebookInstanceVmImage (bio.terra.workspace.model.GcpAiNotebookInstanceVmImage)1 JobControl (bio.terra.workspace.model.JobControl)1