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