use of bio.terra.workspace.service.workspace.model.WsmApplication 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.workspace.service.workspace.model.WsmApplication 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