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);
}
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));
}
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);
}
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.");
}
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);
}
Aggregations