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