Skip to content

use the 202 status consistently in triggering endpoints #2224

Open
nhoening wants to merge 9 commits into
mainfrom
feat/api/use-202-status-consistenly-in-triggering-and-fetching-endpoints
Open

use the 202 status consistently in triggering endpoints #2224
nhoening wants to merge 9 commits into
mainfrom
feat/api/use-202-status-consistenly-in-triggering-and-fetching-endpoints

Conversation

@nhoening

@nhoening nhoening commented Jun 5, 2026

Copy link
Copy Markdown
Member

Description

Use 202 in triggering endoints (forecasting scheduling) and provide follow-up URLs in the response.

Closes #2171

  • changes three trigger endpoint to return 202 when the job is accepted (instead of 200): sensor schedule trigger, asset schedule trigger, and sensor forecast trigger.
  • updates tutorial docs, too: toy-example-expanded.rst and toy-example-from-scratch.rst.
  • introduces job_id as the canonical response field while keeping legacy schedule / forecast fields for compatibility.
  • adds _deprecated_fields metadata, to deprecate fields in endpoints, and for schedule / forecast fields, employ it with use: "job_id" and deprecated_since: "1.0.0".
  • generalizes request_accepted_for_processing(...) so accepted job responses can include legacy keys and result URLs.

Look & Feel

Mainly Sphinx and Swaggerdocs.

How to test

The only new test is test_get_schedule_unfinished_job_returns_202_when_sunset_active.

A bunch of tests simply check for 202 now instead of 200.

… scheduling) and provide follow-up URLs in the response

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening self-assigned this Jun 5, 2026
@nhoening nhoening added this to the 1.0.0 milestone Jun 5, 2026
nhoening added 3 commits June 6, 2026 01:18
…ished (just like get_forecast) - for now only use this (over the old 400 code) if API_SUNSET is being used

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…ering-and-fetching-endpoints

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…ering-and-fetching-endpoints

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@read-the-docs-community

read-the-docs-community Bot commented Jul 11, 2026

Copy link
Copy Markdown

nhoening added 3 commits July 12, 2026 01:52
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Signed-off-by: Nicolas Höning <nicolas@seita.nl>
@nhoening nhoening requested a review from Flix6x July 12, 2026 20:32
Comment thread documentation/api/introduction.rst Outdated

{
"status": "ACCEPTED",
"job_id": "364bfd06-c1fa-430b-8d25-8f5a547651fb",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rationale: API policy specifies no id in API keys.

Suggested change
"job_id": "364bfd06-c1fa-430b-8d25-8f5a547651fb",
"job": "364bfd06-c1fa-430b-8d25-8f5a547651fb",

Comment thread documentation/api/introduction.rst Outdated
{
"status": "ACCEPTED",
"job_id": "364bfd06-c1fa-430b-8d25-8f5a547651fb",
"job_monitor_url": "/api/v3_0/jobs/364bfd06-c1fa-430b-8d25-8f5a547651fb",

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Rationale:

  • API policy specifies kebab-case keys in API
  • (to discuss) Not just for progress monitoring; (some) results live there, too. Do we want to keep two endpoints? Right now we have one for the schedule, and the other for job progress and constraints analysis, and I am at least planning to also let it contain the core result (schedule, forecast, report).
Suggested change
"job_monitor_url": "/api/v3_0/jobs/364bfd06-c1fa-430b-8d25-8f5a547651fb",
"job-url": "/api/v3_0/jobs/364bfd06-c1fa-430b-8d25-8f5a547651fb",

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we want to keep two endpoints?

Are you suggesting to deprecate GET /api/v3_0/sensors/{id}/schedules/{uuid} and GET /api/v3_0/sensors/{id}/forecasts/{uuid}

I believe that could make things easier. Less endpoints to learn for users, for us to maintain.
Once, we discussed making a REST-like resource for scheduling jobs, forecasting jobs (and now possibly also reporting jobs). I don't think we want to really go there anymore. Triggering does live on asset and sensor resources, though. I am curious where reporting triggers will live.

Anyway, with that discussion we're moving out of the scope of this PR here.

For here, I am fine to (already) work with results-url, as you suggest below, next to job-url. One of them could be retired later, but I don't know which right now.

Comment thread documentation/api/introduction.rst Outdated
Comment thread documentation/api/introduction.rst
Comment thread documentation/api/introduction.rst
Comment thread documentation/api/introduction.rst Outdated
Comment thread documentation/api/introduction.rst
Comment thread documentation/changelog.rst Outdated
Comment thread documentation/changelog.rst Outdated
v1.0.0 | July XX, 2026
============================

.. warning:: As of this release we standardize asynchronous job responses to use the `job_id` field and return HTTP `202 Accepted` when a background job is queued. Legacy response fields such as ``schedule`` and ``forecast`` will be deprecated; clients should migrate to `job_id` (see the Infrastructure / Support section below for migration details).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The cross-reference is just throwing up another curtain. You have to find the section below, then read it to notice it has almost nothing to add, then follow up on the reference there to actually find more info.

Better would be to directly cross-reference some material that is actionable to clients, rather than an issue or PR. In addition, that material might reference the new docs on deprecation notices in responses.

Comment thread documentation/tut/toy-example-from-scratch.rst
nhoening added 2 commits July 15, 2026 00:43
…camel-case - even in existing job status endpoitn fields (using the new field-deprecation logic)

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
…ering-and-fetching-endpoints

Signed-off-by: Nicolas Höning <nicolas@seita.nl>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Switch forecasting and schedule - triggering endpoints to 202 Accepted

2 participants