Search in sources :

Example 1 with UpdateReferencedGcsObjectParams

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);
}
Also used : UFGcsObject(bio.terra.cli.serialization.userfacing.resource.UFGcsObject) UFGcsObject(bio.terra.cli.serialization.userfacing.resource.UFGcsObject) UserActionableException(bio.terra.cli.exception.UserActionableException) UpdateReferencedGcsObjectParams(bio.terra.cli.serialization.userfacing.input.UpdateReferencedGcsObjectParams) UpdateResourceParams(bio.terra.cli.serialization.userfacing.input.UpdateResourceParams) WorkspaceOverride(bio.terra.cli.command.shared.options.WorkspaceOverride)

Aggregations

WorkspaceOverride (bio.terra.cli.command.shared.options.WorkspaceOverride)1 UserActionableException (bio.terra.cli.exception.UserActionableException)1 UpdateReferencedGcsObjectParams (bio.terra.cli.serialization.userfacing.input.UpdateReferencedGcsObjectParams)1 UpdateResourceParams (bio.terra.cli.serialization.userfacing.input.UpdateResourceParams)1 UFGcsObject (bio.terra.cli.serialization.userfacing.resource.UFGcsObject)1