use of bio.terra.workspace.generated.model.ApiGcpGcsBucketUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class UpdateGcsBucketStep method doStep.
@Override
public StepResult doStep(FlightContext flightContext) throws InterruptedException, RetryException {
final FlightMap inputMap = flightContext.getInputParameters();
final ApiGcpGcsBucketUpdateParameters updateParameters = inputMap.get(UPDATE_PARAMETERS, ApiGcpGcsBucketUpdateParameters.class);
return updateBucket(updateParameters);
}
use of bio.terra.workspace.generated.model.ApiGcpGcsBucketUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class ControlledResourceServiceTest method updateGcsBucketUndo.
@Test
@DisabledIfEnvironmentVariable(named = "TEST_ENV", matches = BUFFER_SERVICE_DISABLED_ENVS_REG_EX)
void updateGcsBucketUndo() throws Exception {
ControlledGcsBucketResource createdBucket = createDefaultSharedGcsBucket(workspace, user);
Map<String, StepStatus> retrySteps = new HashMap<>();
retrySteps.put(RetrieveControlledResourceMetadataStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(UpdateControlledResourceMetadataStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(RetrieveGcsBucketCloudAttributesStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
retrySteps.put(UpdateGcsBucketStep.class.getName(), StepStatus.STEP_RESULT_FAILURE_RETRY);
jobService.setFlightDebugInfoForTest(FlightDebugInfo.newBuilder().undoStepFailures(retrySteps).lastStepFailure(true).build());
// update the bucket
String newName = "NEW_bucketname";
String newDescription = "new resource description";
// Service methods which wait for a flight to complete will throw an
// InvalidResultStateException when that flight fails without a cause, which occurs when a
// flight fails via debugInfo.
assertThrows(InvalidResultStateException.class, () -> controlledResourceService.updateGcsBucket(createdBucket, ControlledResourceFixtures.BUCKET_UPDATE_PARAMETERS_2, user.getAuthenticatedRequest(), newName, newDescription));
// check the properties stored on the cloud were not updated
BucketInfo updatedBucket = crlService.createStorageCow(projectId).get(createdBucket.getBucketName()).getBucketInfo();
ApiGcpGcsBucketUpdateParameters cloudParameters = GcsApiConversions.toUpdateParameters(updatedBucket);
assertNotEquals(ControlledResourceFixtures.BUCKET_UPDATE_PARAMETERS_2, cloudParameters);
// check the properties stored in WSM were not updated
ControlledGcsBucketResource fetchedResource = controlledResourceService.getControlledResource(workspace.getWorkspaceId(), createdBucket.getResourceId(), user.getAuthenticatedRequest()).castByEnum(WsmResourceType.CONTROLLED_GCP_GCS_BUCKET);
assertEquals(createdBucket.getName(), fetchedResource.getName());
assertEquals(createdBucket.getDescription(), fetchedResource.getDescription());
}
use of bio.terra.workspace.generated.model.ApiGcpGcsBucketUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class GcsApiConversionsTest method testToUpdateParameters.
@Test
public void testToUpdateParameters() {
final ApiGcpGcsBucketUpdateParameters updateParameters1 = toUpdateParameters(GCS_BUCKET_INFO_1);
assertEquals(ApiGcpGcsBucketDefaultStorageClass.STANDARD, updateParameters1.getDefaultStorageClass());
final ApiGcpGcsBucketLifecycle wsmLifecycle = updateParameters1.getLifecycle();
assertThat(wsmLifecycle.getRules(), hasSize(2));
final ApiGcpGcsBucketLifecycleRule rule1 = wsmLifecycle.getRules().get(0);
assertEquals(ApiGcpGcsBucketLifecycleRuleActionType.DELETE, rule1.getAction().getType());
assertNull(rule1.getAction().getStorageClass());
final ApiGcpGcsBucketLifecycleRule rule2 = wsmLifecycle.getRules().get(1);
assertEquals(ApiGcpGcsBucketLifecycleRuleActionType.SET_STORAGE_CLASS, rule2.getAction().getType());
assertEquals(ApiGcpGcsBucketDefaultStorageClass.STANDARD, rule2.getAction().getStorageClass());
}
use of bio.terra.workspace.generated.model.ApiGcpGcsBucketUpdateParameters 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();
}
use of bio.terra.workspace.generated.model.ApiGcpGcsBucketUpdateParameters in project terra-workspace-manager by DataBiosphere.
the class UpdateGcsBucketStep method undoStep.
// Restore the previous values of the update parameters
@Override
public StepResult undoStep(FlightContext flightContext) throws InterruptedException {
final FlightMap workingMap = flightContext.getWorkingMap();
final ApiGcpGcsBucketUpdateParameters previousUpdateParameters = workingMap.get(PREVIOUS_UPDATE_PARAMETERS, ApiGcpGcsBucketUpdateParameters.class);
return updateBucket(previousUpdateParameters);
}
Aggregations