Search in sources :

Example 1 with UpdateResourceParams

use of bio.terra.cli.serialization.userfacing.input.UpdateResourceParams 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)

Example 2 with UpdateResourceParams

use of bio.terra.cli.serialization.userfacing.input.UpdateResourceParams in project terra-cli by DataBiosphere.

the class GcsObject method updateReferenced.

/**
 * Update a GCS bucket object referenced resource in the workspace.
 */
public void updateReferenced(UpdateReferencedGcsObjectParams updateParams) {
    UpdateResourceParams resourceParams = updateParams.resourceFields;
    if (resourceParams.name != null) {
        validateEnvironmentVariableName(updateParams.resourceFields.name);
    }
    WorkspaceManagerService.fromContext().updateReferencedGcsObject(Context.requireWorkspace().getId(), id, updateParams);
    if (updateParams.bucketName != null) {
        this.bucketName = updateParams.bucketName;
    }
    if (updateParams.objectName != null) {
        this.objectName = updateParams.objectName;
    }
    super.updatePropertiesAndSync(resourceParams);
}
Also used : UpdateResourceParams(bio.terra.cli.serialization.userfacing.input.UpdateResourceParams)

Aggregations

UpdateResourceParams (bio.terra.cli.serialization.userfacing.input.UpdateResourceParams)2 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 UFGcsObject (bio.terra.cli.serialization.userfacing.resource.UFGcsObject)1