Skip to content

CRUD for automations in the API and UI#2294

Draft
Flix6x wants to merge 2 commits into
feat/2288-schedule-automationsfrom
feat/2288-automations-crud
Draft

CRUD for automations in the API and UI#2294
Flix6x wants to merge 2 commits into
feat/2288-schedule-automationsfrom
feat/2288-automations-crud

Conversation

@Flix6x

@Flix6x Flix6x commented Jul 11, 2026

Copy link
Copy Markdown
Member

Description

Milestone 3 of #2288 (stacked on #2293, which is stacked on #2290): automations can now be created, edited and deleted through the API and the UI.

  • API (all documented in OpenAPI, all requiring account admin or consultant rights — the same principals that may delete the asset, matching the Automation ACL):
    • POST /assets/<id>/automations — create an automation; parameters are validated by the schema matching the automation type (forecast parameters or a schedule trigger message). Response includes any validation warnings.
    • PATCH /assets/<id>/automations/<automation_id> — update name, cron string and/or activation status.
    • DELETE /assets/<id>/automations/<automation_id> — delete (already-queued jobs are unaffected).
    • Nonexistent/mismatched automation ids yield the documented 404 without leaking id existence across accounts.
  • UI: the automations page gets a New automation modal (name, type, cron string, JSON parameters, active) and per-row (De)activate / Delete actions — rendered only for users with management rights.
  • Refactor: create/update/delete logic including audit-log records moved into flexmeasures/data/services/automations.py, shared by the CLI commands and the new endpoints (audit messages now say "via CLI" or "via API" consistently).

How to test

As an account admin, open /assets/<id>/automations and use the New automation button, or:

curl -X POST .../api/v3_0/assets/<id>/automations -H "Authorization: <token>" -H "Content-Type: application/json" \
  -d '{"name": "Nightly schedules", "cronstr": "0 0 * * *", "type": "schedules", "parameters": {"duration": "PT12H"}}'

Tests: pytest flexmeasures/api/v3_0/tests/test_automations_api.py flexmeasures/cli/tests/test_automations.py (permission matrix: plain member 403, account admin OK, other account 403).

🤖 Generated with Claude Code

https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX

Flix6x and others added 2 commits July 11, 2026 18:44
- New endpoints on assets: POST /automations (create, validating parameters
  by automation type), PATCH /automations/<id> (name, cron string, activation
  status) and DELETE /automations/<id>. Managing automations requires the
  same principals that may delete the asset (account admins and consultants).
- The UI automations page gets a 'New automation' modal and per-row
  (de)activate and delete actions, shown to users with management rights.
- Creation, update and deletion logic (incl. audit log records) moved into
  the automations service, shared by the CLI commands and the API endpoints.

Part of #2288

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant