class StackImageUpdateActions {

    @Bean(name = "SET_IMAGE_STATE")
    public AbstractStackImageUpdateAction<?> setImageAction() {
        return new AbstractStackImageUpdateAction<>(StackEvent.class) {
            @Override
            protected void doExecute(StackContext context, StackEvent payload, Map<Object, Object> variables) {
                CloudStack cloudStack = getCloudStackConverter().convert(context.getStack());
                Collection<Resource> resources = getResourceService().getAllByStackId(context.getStack().getId());
                List<CloudResource> cloudResources =
                        resources.stream().map(resource -> getResourceToCloudResourceConverter().convert(resource)).collect(Collectors.toList());
                UpdateImageRequest<Selectable> request =
                        new UpdateImageRequest<>(context.getCloudContext(), context.getCloudCredential(), cloudStack, cloudResources);
                sendEvent(context, request);
            }
        };
    }

}