Search in sources :

Example 1 with AWSInstance

use of org.finra.gatekeeper.services.accessrequest.model.AWSInstance in project Gatekeeper by FINRAOS.

the class AccessRequestService method updateInstanceStatus.

public AccessRequest updateInstanceStatus(AccessRequest accessRequest) {
    AWSEnvironment environment = new AWSEnvironment(accessRequest.getAccount(), accessRequest.getRegion());
    List<AWSInstance> requestedInstances = accessRequest.getInstances();
    List<String> instanceIds = requestedInstances.stream().map(instance -> instance.getInstanceId()).collect(Collectors.toList());
    Map<String, String> instances = ssmService.checkInstancesWithSsm(environment, instanceIds);
    requestedInstances.forEach(instance -> instance.setStatus(instances.get(instance.getInstanceId()) != null ? instances.get(instance.getInstanceId()) : "Unknown"));
    accessRequest.setInstances(requestedInstances);
    accessRequestRepository.save(accessRequest);
    return accessRequest;
}
Also used : RuntimeService(org.activiti.engine.RuntimeService) GatekeeperRoleService(org.finra.gatekeeper.services.auth.GatekeeperRoleService) AccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.AccessRequestWrapper) AccessRequest(org.finra.gatekeeper.services.accessrequest.model.AccessRequest) java.util(java.util) TaskService(org.activiti.engine.TaskService) PreAuthorize(org.springframework.security.access.prepost.PreAuthorize) LoggerFactory(org.slf4j.LoggerFactory) Autowired(org.springframework.beans.factory.annotation.Autowired) ActiveAccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper) GatekeeperApprovalProperties(org.finra.gatekeeper.configuration.properties.GatekeeperApprovalProperties) GatekeeperUserEntry(org.finra.gatekeeper.common.services.user.model.GatekeeperUserEntry) AWSInstance(org.finra.gatekeeper.services.accessrequest.model.AWSInstance) Account(org.finra.gatekeeper.common.services.account.model.Account) CompletedAccessRequestWrapper(org.finra.gatekeeper.controllers.wrappers.CompletedAccessRequestWrapper) HistoryService(org.activiti.engine.HistoryService) Task(org.activiti.engine.task.Task) AccessRequestRepository(org.finra.gatekeeper.services.accessrequest.model.AccessRequestRepository) Logger(org.slf4j.Logger) GatekeeperException(org.finra.gatekeeper.exception.GatekeeperException) Collectors(java.util.stream.Collectors) HistoricVariableInstance(org.activiti.engine.history.HistoricVariableInstance) AccountInformationService(org.finra.gatekeeper.common.services.account.AccountInformationService) RequestStatus(org.finra.gatekeeper.services.accessrequest.model.RequestStatus) Component(org.springframework.stereotype.Component) AccessRequestController(org.finra.gatekeeper.controllers.AccessRequestController) SsmService(org.finra.gatekeeper.services.aws.SsmService) GatekeeperRole(org.finra.gatekeeper.services.auth.GatekeeperRole) AWSEnvironment(org.finra.gatekeeper.services.aws.model.AWSEnvironment) AWSInstance(org.finra.gatekeeper.services.accessrequest.model.AWSInstance) AWSEnvironment(org.finra.gatekeeper.services.aws.model.AWSEnvironment)

Aggregations

java.util (java.util)1 Collectors (java.util.stream.Collectors)1 HistoryService (org.activiti.engine.HistoryService)1 RuntimeService (org.activiti.engine.RuntimeService)1 TaskService (org.activiti.engine.TaskService)1 HistoricVariableInstance (org.activiti.engine.history.HistoricVariableInstance)1 Task (org.activiti.engine.task.Task)1 AccountInformationService (org.finra.gatekeeper.common.services.account.AccountInformationService)1 Account (org.finra.gatekeeper.common.services.account.model.Account)1 GatekeeperUserEntry (org.finra.gatekeeper.common.services.user.model.GatekeeperUserEntry)1 GatekeeperApprovalProperties (org.finra.gatekeeper.configuration.properties.GatekeeperApprovalProperties)1 AccessRequestController (org.finra.gatekeeper.controllers.AccessRequestController)1 AccessRequestWrapper (org.finra.gatekeeper.controllers.wrappers.AccessRequestWrapper)1 ActiveAccessRequestWrapper (org.finra.gatekeeper.controllers.wrappers.ActiveAccessRequestWrapper)1 CompletedAccessRequestWrapper (org.finra.gatekeeper.controllers.wrappers.CompletedAccessRequestWrapper)1 GatekeeperException (org.finra.gatekeeper.exception.GatekeeperException)1 AWSInstance (org.finra.gatekeeper.services.accessrequest.model.AWSInstance)1 AccessRequest (org.finra.gatekeeper.services.accessrequest.model.AccessRequest)1 AccessRequestRepository (org.finra.gatekeeper.services.accessrequest.model.AccessRequestRepository)1 RequestStatus (org.finra.gatekeeper.services.accessrequest.model.RequestStatus)1