API endpoint to trigger reports as jobs#2298
Draft
Flix6x wants to merge 3 commits into
Draft
Conversation
Add POST /api/v3_0/assets/<id>/reports/trigger, which queues a one-off reporting job on the reporting queue, mirroring how forecasts and schedules are triggered via the API. The job status can be polled via the generic GET /api/v3_0/jobs/<uuid> endpoint. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
Documentation build overview
36 files changed ·
|
The report trigger endpoint now applies the same sensor-access guard as automation creation: the caller must be able to read every input sensor and record data on every output sensor. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Closes #2288 (API part): adds
POST /api/v3_0/assets/<id>/reports/trigger, which queues a one-off reporting job on thereportingqueue, mirroring how forecasts and schedules are triggered via the API. Builds on the reports-as-jobs infrastructure from #2297.Request body
{ "reporter": "PandasReporter", "config": { ... reporter configuration (static, stored on the reporter's data source) ... }, "parameters": { "input": [...], "output": [...], "start": "...", "end": "..." } }reporter(required): reporter class registered in FlexMeasures or a plugin (seeflexmeasures show reporters).config(optional): validated by the reporter's config schema.parameters(required): validated against the baseReporterParametersSchemaand then by the reporter's own parameters schema; must reference at least oneoutputsensor.Response
{"status": "PROCESSED", "report": "<job UUID>", "message": "Request has been processed."}The job status can be polled via the existing generic
GET /api/v3_0/jobs/<uuid>endpoint, and the queued job records its trigger as{"origin": "API"}in the job meta.Permissions
The asset in the URL path scopes permissions:
create-childrenaccess is required (any account member, or consultants), matching the schedule trigger endpoint. Output sensors are assumed to belong to the asset or its (grand)children (documented, not hard-enforced), and parameters without any output are rejected with a 422.Look & Feel
New endpoint documented in the Swagger UI (with a
PandasReporterexample), indocumentation/features/reporting.rst("Automating reports") and in the API change log.How to test
Covers the permission matrix (anonymous 401 / other account 403 / account member 200), successful queueing (job on the
reportingqueue withmeta["trigger"] == {"origin": "API"}), and a range of invalid messages (missing timing fields, missing output, unknown reporter, invalid config, missing required fields) each yielding a 422 without queueing a job.🤖 Generated with Claude Code
https://claude.ai/code/session_01Rbix8k1JfeUWNXEmHEZVpX