Search in sources :

Example 1 with GcpNotebook

use of bio.terra.cli.businessobject.resource.GcpNotebook in project terra-cli by DataBiosphere.

the class NotebookInstance method toInstanceName.

public InstanceName toInstanceName() {
    Workspace workspace = Context.requireWorkspace();
    if (argGroup.resourceName != null) {
        Resource resource = workspace.getResource(argGroup.resourceName);
        if (!resource.getResourceType().equals(Resource.Type.AI_NOTEBOOK)) {
            throw new UserActionableException("Only able to use notebook commands on notebook resources, but specified resource is " + resource.getResourceType());
        }
        GcpNotebook gcpNotebook = (GcpNotebook) resource;
        return InstanceName.builder().projectId(gcpNotebook.getProjectId()).location(gcpNotebook.getLocation()).instanceId(gcpNotebook.getInstanceId()).build();
    } else {
        return InstanceName.builder().projectId(workspace.getGoogleProjectId()).location(location).instanceId(argGroup.instanceId).build();
    }
}
Also used : Resource(bio.terra.cli.businessobject.Resource) UserActionableException(bio.terra.cli.exception.UserActionableException) GcpNotebook(bio.terra.cli.businessobject.resource.GcpNotebook) Workspace(bio.terra.cli.businessobject.Workspace)

Aggregations

Resource (bio.terra.cli.businessobject.Resource)1 Workspace (bio.terra.cli.businessobject.Workspace)1 GcpNotebook (bio.terra.cli.businessobject.resource.GcpNotebook)1 UserActionableException (bio.terra.cli.exception.UserActionableException)1