"""Automation API URL configuration.

Endpoints implemented in tasks 3.3.3, 3.7.6, 3.8.1, 3.10.1–3.10.2.

Planned routes
--------------
GET  /api/v1/automation/rules/
POST /api/v1/automation/rules/
GET  /api/v1/automation/rules/{id}/
PATCH /api/v1/automation/rules/{id}/
DELETE /api/v1/automation/rules/{id}/
POST /api/v1/automation/rules/{id}/toggle/
POST /api/v1/automation/rules/{id}/run-now/
GET  /api/v1/automation/rules/{id}/executions/
GET  /api/v1/automation/templates/
POST /api/v1/automation/rules/from-template/{template_id}/
GET  /api/v1/automation/actions/
GET  /api/v1/automation/trigger-events/
GET  /api/v1/automation/condition-fields/{event_name}/
GET  /api/v1/automation/webhooks/
POST /api/v1/automation/webhooks/
...
"""

from __future__ import annotations

from django.urls import path

from simorgh.apps.automation.api import views

app_name = "automation"

urlpatterns = [
    # Action discovery (task 3.3.3)
    path("actions/", views.action_list, name="action-list"),

    # Rule Engine UI Schema (task 3.10.1 + 3.10.2)
    path("trigger-events/", views.trigger_events, name="trigger-events"),
    path("condition-fields/<str:event_name>/", views.condition_fields, name="condition-fields"),

    # Rule CRUD + sub-actions (task 3.8.1)
    # NOTE: more-specific patterns MUST come before the generic <rule_id> catch-all.
    path("rules/from-template/<str:template_id>/", views.rule_from_template, name="rule-from-template"),
    path("rules/<str:rule_id>/toggle/", views.rule_toggle, name="rule-toggle"),
    path("rules/<str:rule_id>/run-now/", views.rule_run_now, name="rule-run-now"),
    path("rules/<str:rule_id>/executions/", views.rule_executions, name="rule-executions"),
    path("rules/<str:rule_id>/", views.rule_detail, name="rule-detail"),
    path("rules/", views.rule_list, name="rule-list"),

    # Templates (task 3.8.1)
    path("templates/", views.template_list, name="template-list"),

    # Webhook CRUD (task 3.7.6)
    path("webhooks/", views.webhook_list, name="webhook-list"),
    path("webhooks/<str:endpoint_id>/", views.webhook_detail, name="webhook-detail"),
    path("webhooks/<str:endpoint_id>/deliveries/", views.webhook_deliveries, name="webhook-deliveries"),
    path("webhooks/<str:endpoint_id>/test/", views.webhook_test, name="webhook-test"),
]
