use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvDeleteActions method finishedAction.
@Bean(name = "ENV_DELETE_FINISHED_STATE")
public Action<?, ?> finishedAction() {
return new AbstractEnvDeleteAction<>(ResourceCrnPayload.class) {
@Override
protected void doExecute(CommonContext context, ResourceCrnPayload payload, Map<Object, Object> variables) {
environmentService.findEnvironmentById(payload.getResourceId()).ifPresentOrElse(env -> {
String originalName = env.getName();
env.setName(generateArchiveName(env.getName()));
env.setDeletionTimestamp(new Date().getTime());
env.setStatus(EnvironmentStatus.ARCHIVED);
env.setStatusReason(null);
env.setArchived(true);
env.setProxyConfig(null);
Environment result = environmentService.save(env);
EnvironmentDto environmentDto = environmentService.getEnvironmentDto(result);
SimpleEnvironmentResponse simpleResponse = environmentResponseConverter.dtoToSimpleResponse(environmentDto, true, true);
simpleResponse.setName(originalName);
metricService.incrementMetricCounter(MetricType.ENV_DELETION_FINISHED, environmentDto);
eventService.sendEventAndNotificationWithPayload(environmentDto, context.getFlowTriggerUserCrn(), ResourceEvent.ENVIRONMENT_DELETION_FINISHED, simpleResponse);
}, () -> LOGGER.error("Cannot finish the delete flow because the environment does not exist: {}. " + "But the flow will continue, how can this happen?", payload.getResourceId()));
LOGGER.info("Flow entered into ENV_DELETE_FINISHED_STATE");
sendEvent(context, FINALIZE_ENV_DELETE_EVENT.event(), payload);
}
};
}
use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EventSenderService method sendEventAndNotification.
public void sendEventAndNotification(EnvironmentDto environmentDto, String userCrn, ResourceEvent resourceEvent, Collection<?> messageArgs) {
SimpleEnvironmentResponse simpleResponse = environmentResponseConverter.dtoToSimpleResponse(environmentDto, true, true);
sendEventAndNotificationWithPayload(environmentDto, userCrn, resourceEvent, simpleResponse, messageArgs);
}
use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvironmentDeleteByNameAction method environmentAction.
@Override
protected EnvironmentTestDto environmentAction(TestContext testContext, EnvironmentTestDto testDto, EnvironmentClient client) throws Exception {
SimpleEnvironmentResponse delete = client.getDefaultClient().environmentV1Endpoint().deleteByName(testDto.getName(), cascading, false);
testDto.setResponseSimpleEnv(delete);
Log.whenJson("Environment delete response: ", delete);
return testDto;
}
use of com.sequenceiq.environment.api.v1.environment.model.response.SimpleEnvironmentResponse in project cloudbreak by hortonworks.
the class EnvironmentCascadingDeleteAction method action.
@Override
public EnvironmentTestDto action(TestContext testContext, EnvironmentTestDto testDto, EnvironmentClient environmentClient) throws Exception {
Log.when(LOGGER, "Environment cascading delete request, crn: " + testDto.getResponse().getCrn());
SimpleEnvironmentResponse delete = environmentClient.getDefaultClient().environmentV1Endpoint().deleteByCrn(testDto.getResponse().getCrn(), true, false);
testDto.setResponseSimpleEnv(delete);
Log.whenJson(LOGGER, " Environment cascading delete response: ", delete);
return testDto;
}
Aggregations