use of bio.terra.workspace.generated.model.ApiGcpGcsBucketCreationParameters in project terra-workspace-manager by DataBiosphere.
the class CopyGcsBucketDefinitionStep method getDestinationCreationParameters.
private ApiGcpGcsBucketCreationParameters getDestinationCreationParameters(FlightMap inputParameters, FlightMap workingMap) {
final ApiGcpGcsBucketCreationParameters sourceCreationParameters = workingMap.get(ControlledResourceKeys.CREATION_PARAMETERS, ApiGcpGcsBucketCreationParameters.class);
final Optional<String> suppliedLocation = Optional.ofNullable(inputParameters.get(ControlledResourceKeys.LOCATION, String.class));
// Override the location parameter if it was specified
if (suppliedLocation.isPresent()) {
return new ApiGcpGcsBucketCreationParameters().defaultStorageClass(sourceCreationParameters.getDefaultStorageClass()).lifecycle(sourceCreationParameters.getLifecycle()).name(sourceCreationParameters.getName()).location(suppliedLocation.get());
} else {
return sourceCreationParameters;
}
}
use of bio.terra.workspace.generated.model.ApiGcpGcsBucketCreationParameters in project terra-workspace-manager by DataBiosphere.
the class RetrieveGcsBucketCloudAttributesStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws InterruptedException, RetryException {
final FlightMap workingMap = flightContext.getWorkingMap();
final String projectId = gcpCloudContextService.getRequiredGcpProject(bucketResource.getWorkspaceId());
// get the storage cow
final StorageCow storageCow = crlService.createStorageCow(projectId);
// get the existing bucket cow
final BucketCow existingBucketCow = storageCow.get(bucketResource.getBucketName());
if (existingBucketCow == null) {
logger.error("Can't construct COW for pre-existing bucket {}", bucketResource.getBucketName());
return new StepResult(StepStatus.STEP_RESULT_FAILURE_FATAL, null);
}
// get the attributes
final BucketInfo existingBucketInfo = existingBucketCow.getBucketInfo();
switch(retrievalMode) {
case UPDATE_PARAMETERS:
final ApiGcpGcsBucketUpdateParameters existingUpdateParameters = GcsApiConversions.toUpdateParameters(existingBucketInfo);
workingMap.put(ControlledResourceKeys.PREVIOUS_UPDATE_PARAMETERS, existingUpdateParameters);
break;
case CREATION_PARAMETERS:
final ApiGcpGcsBucketCreationParameters creationParameters = GcsApiConversions.toCreationParameters(existingBucketInfo);
workingMap.put(ControlledResourceKeys.CREATION_PARAMETERS, creationParameters);
break;
default:
throw new BadRequestException(String.format("Unsupported Retrieval mode %s", retrievalMode));
}
return StepResult.getStepResultSuccess();
}
Aggregations