@ExecuteOn(TaskExecutors.IO)
    @Post(uri = "/{namespace}/{flowId}/{triggerId}/restart")
    @Operation(tags = {"Triggers"}, summary = "Restart a trigger")
    public HttpResponse<?> restart(
        @Parameter(description = "The namespace") @PathVariable String namespace,
        @Parameter(description = "The flow id") @PathVariable String flowId,
        @Parameter(description = "The trigger id") @PathVariable String triggerId
    ) throws HttpStatusException {
        Optional<Trigger> triggerOpt = triggerRepository.findLast(TriggerContext.builder()
            .tenantId(tenantService.resolveTenant())
            .namespace(namespace)
            .flowId(flowId)
            .triggerId(triggerId)
            .build());

        if (triggerOpt.isEmpty()) {
            return HttpResponse.notFound();
        }

        var trigger = triggerOpt.get().toBuilder()
            .workerId(null)
            .evaluateRunningDate(null)
            .date(null)
            .build();

        this.executionKilledQueue.emit(ExecutionKilledTrigger
            .builder()
            .tenantId(trigger.getTenantId())
            .namespace(trigger.getNamespace())
            .flowId(trigger.getFlowId())
            .triggerId(trigger.getTriggerId())
            .build()
        );

        // this will make the trigger restarting
        // be careful that, as everything is asynchronous, it can be restarted before it is killed
        this.triggerQueue.emit(trigger);

        return HttpResponse.ok(trigger);
    }
@Test
    void restart() {
        Flow flow = generateFlow("flow-with-triggers");
        jdbcFlowRepository.create(flow, flow.generateSource(), flow);

        Trigger trigger = Trigger.builder()
            .flowId(flow.getId())
            .namespace(flow.getNamespace())
            .triggerId("trigger-to-restart")
            .executionId(IdUtils.create())
            .disabled(true)
            .build();

        jdbcTriggerRepository.create(trigger);

        HttpResponse<?> restarted = client.toBlocking().exchange(HttpRequest.POST(("/api/v1/triggers/io.kestra.tests.schedule/flow-with-triggers/trigger-to-restart/restart"), null));
        assertThat(restarted.getStatus(), is(HttpStatus.OK));

        assertThrows(HttpClientResponseException.class, () -> client.toBlocking().exchange(HttpRequest.POST(("/api/v1/triggers/notfound/notfound/notfound/restart"), null)));
    }