Search in sources :

Example 96 with FlightMap

use of bio.terra.stairway.FlightMap in project terra-workspace-manager by DataBiosphere.

the class AzureTestUtils method deleteControlledResourceInputParameters.

public FlightMap deleteControlledResourceInputParameters(UUID workspaceId, UUID resourceId, AuthenticatedUserRequest userRequest, ControlledResource resource) {
    FlightMap inputs = new FlightMap();
    inputs.put(ResourceKeys.RESOURCE, resource);
    inputs.put(WorkspaceFlightMapKeys.WORKSPACE_ID, workspaceId.toString());
    inputs.put(WorkspaceFlightMapKeys.ResourceKeys.RESOURCE_ID, resourceId.toString());
    inputs.put(JobMapKeys.AUTH_USER_INFO.getKeyName(), userRequest);
    return inputs;
}
Also used : FlightMap(bio.terra.stairway.FlightMap)

Example 97 with FlightMap

use of bio.terra.stairway.FlightMap in project terra-workspace-manager by DataBiosphere.

the class SyncSamGroupsStep method doStep.

// Note that the SamService.syncWorkspacePolicy is already idempotent, so this doesn't need to
// be explicitly handled here.
@Override
public StepResult doStep(FlightContext flightContext) throws InterruptedException, RetryException {
    // This cannot be an ImmutableMap, as those do not deserialize properly with Jackson.
    var workspaceRoleGroupMap = new HashMap<WsmIamRole, String>();
    workspaceRoleGroupMap.put(WsmIamRole.OWNER, samService.syncWorkspacePolicy(workspaceId, WsmIamRole.OWNER, userRequest));
    workspaceRoleGroupMap.put(WsmIamRole.APPLICATION, samService.syncWorkspacePolicy(workspaceId, WsmIamRole.APPLICATION, userRequest));
    workspaceRoleGroupMap.put(WsmIamRole.WRITER, samService.syncWorkspacePolicy(workspaceId, WsmIamRole.WRITER, userRequest));
    workspaceRoleGroupMap.put(WsmIamRole.READER, samService.syncWorkspacePolicy(workspaceId, WsmIamRole.READER, userRequest));
    FlightMap workingMap = flightContext.getWorkingMap();
    workingMap.put(WorkspaceFlightMapKeys.IAM_GROUP_EMAIL_MAP, workspaceRoleGroupMap);
    return StepResult.getStepResultSuccess();
}
Also used : HashMap(java.util.HashMap) FlightMap(bio.terra.stairway.FlightMap)

Example 98 with FlightMap

use of bio.terra.stairway.FlightMap in project terra-workspace-manager by DataBiosphere.

the class ApplicationAbleDaoStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
    FlightMap workingMap = context.getWorkingMap();
    FlightUtils.validateRequiredEntries(workingMap, WsmApplicationKeys.APPLICATION_ABLE_DAO, WsmApplicationKeys.WSM_APPLICATION);
    // if the application was in the correct database state in precheck, we do nothing
    if (workingMap.get(WsmApplicationKeys.APPLICATION_ABLE_DAO, Boolean.class)) {
        return StepResult.getStepResultSuccess();
    }
    WsmWorkspaceApplication wsmApp;
    if (ableEnum == AbleEnum.ENABLE) {
        wsmApp = applicationDao.enableWorkspaceApplication(workspaceId, applicationId);
    } else {
        wsmApp = applicationDao.disableWorkspaceApplication(workspaceId, applicationId);
    }
    workingMap.put(JobMapKeys.RESPONSE.getKeyName(), wsmApp);
    return StepResult.getStepResultSuccess();
}
Also used : FlightMap(bio.terra.stairway.FlightMap) WsmWorkspaceApplication(bio.terra.workspace.service.workspace.model.WsmWorkspaceApplication)

Example 99 with FlightMap

use of bio.terra.stairway.FlightMap in project terra-workspace-manager by DataBiosphere.

the class ApplicationAbleIamStep method doStep.

@Override
public StepResult doStep(FlightContext context) throws InterruptedException, RetryException {
    FlightMap workingMap = context.getWorkingMap();
    FlightUtils.validateRequiredEntries(workingMap, WsmApplicationKeys.WSM_APPLICATION, WsmApplicationKeys.APPLICATION_ABLE_SAM);
    // if the application was in the correct Sam state in precheck, then we do nothing
    if (workingMap.get(WsmApplicationKeys.APPLICATION_ABLE_SAM, Boolean.class)) {
        return StepResult.getStepResultSuccess();
    }
    WsmApplication application = workingMap.get(WsmApplicationKeys.WSM_APPLICATION, WsmApplication.class);
    if (ableEnum == AbleEnum.ENABLE) {
        samService.grantWorkspaceRole(workspaceId, userRequest, WsmIamRole.APPLICATION, application.getServiceAccount());
    } else {
        samService.removeWorkspaceRole(workspaceId, userRequest, WsmIamRole.APPLICATION, application.getServiceAccount());
    }
    return StepResult.getStepResultSuccess();
}
Also used : WsmApplication(bio.terra.workspace.service.workspace.model.WsmApplication) FlightMap(bio.terra.stairway.FlightMap)

Example 100 with FlightMap

use of bio.terra.stairway.FlightMap in project terra-workspace-manager by DataBiosphere.

the class ApplicationAbleIamStep method undoStep.

@Override
public StepResult undoStep(FlightContext context) throws InterruptedException {
    FlightMap workingMap = context.getWorkingMap();
    // if the application was not already enabled in Sam when we started, we do not undo it
    if (workingMap.get(WsmApplicationKeys.APPLICATION_ABLE_SAM, Boolean.class)) {
        return StepResult.getStepResultSuccess();
    }
    WsmApplication application = workingMap.get(WsmApplicationKeys.WSM_APPLICATION, WsmApplication.class);
    if (ableEnum == AbleEnum.ENABLE) {
        samService.removeWorkspaceRole(workspaceId, userRequest, WsmIamRole.APPLICATION, application.getServiceAccount());
    } else {
        samService.grantWorkspaceRole(workspaceId, userRequest, WsmIamRole.APPLICATION, application.getServiceAccount());
    }
    return StepResult.getStepResultSuccess();
}
Also used : WsmApplication(bio.terra.workspace.service.workspace.model.WsmApplication) FlightMap(bio.terra.stairway.FlightMap)

Aggregations

FlightMap (bio.terra.stairway.FlightMap)147 StepResult (bio.terra.stairway.StepResult)38 UUID (java.util.UUID)29 FlightState (bio.terra.stairway.FlightState)20 DatabaseOperationException (bio.terra.stairway.exception.DatabaseOperationException)14 Test (org.junit.jupiter.api.Test)14 Dataset (bio.terra.service.dataset.Dataset)9 IOException (java.io.IOException)9 IamRole (bio.terra.service.iam.IamRole)8 AuthenticatedUserRequest (bio.terra.workspace.service.iam.AuthenticatedUserRequest)8 HashMap (java.util.HashMap)8 DuplicateFlightIdException (bio.terra.stairway.exception.DuplicateFlightIdException)7 CloningInstructions (bio.terra.workspace.service.resource.model.CloningInstructions)7 FlightDebugInfo (bio.terra.stairway.FlightDebugInfo)6 BaseConnectedTest (bio.terra.workspace.common.BaseConnectedTest)6 FileSystemAbortTransactionException (bio.terra.service.filedata.exception.FileSystemAbortTransactionException)5 Snapshot (bio.terra.service.snapshot.Snapshot)5 FlightNotFoundException (bio.terra.stairway.exception.FlightNotFoundException)5 StairwayExecutionException (bio.terra.stairway.exception.StairwayExecutionException)5 BaseUnitTest (bio.terra.workspace.common.BaseUnitTest)5