Search in sources :

Example 1 with Resource

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

the class Resolve method execute.

/**
 * Resolve a resource in the workspace to its cloud identifier.
 */
@Override
protected void execute() {
    workspaceOption.overrideIfSpecified();
    Resource resource = Context.requireWorkspace().getResource(resourceNameOption.name);
    String cloudId;
    switch(resource.getResourceType()) {
        case GCS_BUCKET:
            cloudId = ((GcsBucket) resource).resolve(!excludeBucketPrefix);
            break;
        case GCS_OBJECT:
            cloudId = ((GcsObject) resource).resolve(!excludeBucketPrefix);
            break;
        case BQ_DATASET:
            cloudId = ((BqDataset) resource).resolve(bqPathFormat);
            break;
        case BQ_TABLE:
            cloudId = ((BqTable) resource).resolve(bqPathFormat);
            break;
        default:
            cloudId = resource.resolve();
    }
    formatOption.printReturnValue(cloudId);
}
Also used : Resource(bio.terra.cli.businessobject.Resource) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Example 2 with Resource

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

the class Clone method buildUfClonedResource.

private UFClonedResource buildUfClonedResource(Workspace sourceWorkspace, Workspace destinationWorkspace, ResourceCloneDetails resourceCloneDetails) {
    Resource sourceResource = sourceWorkspace.getResource(resourceCloneDetails.getName());
    final Resource destinationResource;
    if (CloneResourceResult.SUCCEEDED == resourceCloneDetails.getResult()) {
        destinationResource = destinationWorkspace.getResource(resourceCloneDetails.getName());
    } else {
        destinationResource = null;
    }
    return new UFClonedResource(resourceCloneDetails, sourceResource.serializeToCommand(), Optional.ofNullable(destinationResource).map(Resource::serializeToCommand).orElse(null));
}
Also used : UFClonedResource(bio.terra.cli.serialization.userfacing.UFClonedResource) Resource(bio.terra.cli.businessobject.Resource) UFClonedResource(bio.terra.cli.serialization.userfacing.UFClonedResource)

Example 3 with Resource

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

the class CheckAccess method execute.

/**
 * Check if the user and their proxy group have access to a referenced resource in the workspace.
 */
@Override
protected void execute() {
    workspaceOption.overrideIfSpecified();
    Resource resource = Context.requireWorkspace().getResource(resourceNameOption.name);
    boolean proxyGroupHasAccess = resource.checkAccess();
    formatOption.printReturnValue(proxyGroupHasAccess, this::printText);
}
Also used : Resource(bio.terra.cli.businessobject.Resource) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Example 4 with Resource

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

the class Delete method execute.

/**
 * Delete a resource from the workspace.
 */
@Override
protected void execute() {
    workspaceOption.overrideIfSpecified();
    Resource resourceToDelete = Context.requireWorkspace().getResource(resourceNameOption.name);
    // print details about the resource before showing the delete prompt
    resourceToDelete.serializeToCommand().print();
    deletePromptOption.confirmOrThrow();
    resourceToDelete.delete();
    OUT.println("Resource successfully deleted.");
}
Also used : Resource(bio.terra.cli.businessobject.Resource) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Example 5 with Resource

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

the class Describe method execute.

/**
 * Describe a resource.
 */
@Override
protected void execute() {
    workspaceOption.overrideIfSpecified();
    Resource resource = Context.requireWorkspace().getResource(resourceNameOption.name);
    formatOption.printReturnValue(resource.serializeToCommand(), UFResource::print);
}
Also used : UFResource(bio.terra.cli.serialization.userfacing.UFResource) UFResource(bio.terra.cli.serialization.userfacing.UFResource) Resource(bio.terra.cli.businessobject.Resource) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Aggregations

Resource (bio.terra.cli.businessobject.Resource)6 WorkspaceOverride (bio.terra.cli.command.shared.options.WorkspaceOverride)4 Workspace (bio.terra.cli.businessobject.Workspace)1 GcpNotebook (bio.terra.cli.businessobject.resource.GcpNotebook)1 UserActionableException (bio.terra.cli.exception.UserActionableException)1 UFClonedResource (bio.terra.cli.serialization.userfacing.UFClonedResource)1 UFResource (bio.terra.cli.serialization.userfacing.UFResource)1