use of bio.terra.cli.serialization.userfacing.input.UpdateReferencedGcsObjectParams in project terra-cli by DataBiosphere.
the class GcsObject method execute.
/**
* Update a bucket object in the workspace.
*/
@Override
protected void execute() {
workspaceOption.overrideIfSpecified();
// all update parameters are optional, but make sure at least one is specified
if (!resourceUpdateOptions.isDefined() && newObjectName == null && newBucketName.getNewBucketName() == null) {
throw new UserActionableException("Specify at least one property to update.");
}
// get the resource and make sure it's the right type
bio.terra.cli.businessobject.resource.GcsObject resource = Context.requireWorkspace().getResource(resourceUpdateOptions.resourceNameOption.name).castToType(Resource.Type.GCS_OBJECT);
UpdateResourceParams updateResourceParams = resourceUpdateOptions.populateMetadataFields().build();
UpdateReferencedGcsObjectParams gcsObjectParams = new UpdateReferencedGcsObjectParams.Builder().resourceFields(updateResourceParams).bucketName(newBucketName.getNewBucketName()).objectName(newObjectName).build();
resource.updateReferenced(gcsObjectParams);
formatOption.printReturnValue(new UFGcsObject(resource), GcsObject::printText);
}
Aggregations