Skip to content

Commit

Permalink
Merge 288defa into 6e9c32f
Browse files Browse the repository at this point in the history
  • Loading branch information
Flix6x committed May 5, 2023
2 parents 6e9c32f + 288defa commit 8fcce5d
Show file tree
Hide file tree
Showing 18 changed files with 102 additions and 3,632 deletions.
26 changes: 26 additions & 0 deletions documentation/api/change_log.rst
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,11 @@ v3.0-0 | 2022-03-25
- Rewrote the sections on roles and sources into a combined section that refers to account roles rather than USEF roles.
- Deprecated the section on group notation.

v2.0-7 | 2022-05-05
"""""""""""""""""""

*API v2.0 is removed.*

v2.0-6 | 2022-04-26
"""""""""""""""""""

Expand Down Expand Up @@ -163,6 +168,12 @@ v2.0-0 | 2020-11-14

- Added REST endpoints for managing assets: `/assets/` (GET, POST) and `/asset/<id>` (GET, PATCH, DELETE).


v1.3-14 | 2022-05-05
""""""""""""""""""""

*API v1.3 is removed.*

v1.3-13 | 2022-04-26
""""""""""""""""""""

Expand Down Expand Up @@ -259,6 +270,11 @@ v1.3-0 | 2020-01-28
- The *postUdiEvent* endpoint now triggers scheduling jobs to be set up (rather than scheduling directly triggered by the *getDeviceMessage* endpoint)
- The *getDeviceMessage* now queries the job queue and database for an available schedule

v1.2-6 | 2022-05-05
"""""""""""""""""""

*API v1.2 is removed.*

v1.2-5 | 2022-04-26
"""""""""""""""""""

Expand Down Expand Up @@ -315,6 +331,11 @@ v1.2-0 | 2018-09-08
- Added a description of the *postUdiEvent* endpoint in the Prosumer and Simulation sections
- Added a description of the *getDeviceMessage* endpoint in the Prosumer and Simulation sections

v1.1-8 | 2022-05-05
"""""""""""""""""""

*API v1.1 is removed.*

v1.1-7 | 2022-04-26
"""""""""""""""""""

Expand Down Expand Up @@ -378,6 +399,11 @@ v1.1-0 | 2018-07-15

- Added a description of the *getPrognosis* endpoint in the Supplier section

v1.0-4 | 2022-05-05
"""""""""""""""""""

*API v1.0 is removed.*

v1.0-3 | 2022-04-26
"""""""""""""""""""

Expand Down
1 change: 1 addition & 0 deletions documentation/changelog.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ Infrastructure / Support
----------------------

* The setting FLEXMEASURES_PLUGINS can be set as environment variable now (as a comma-separated list) [see `PR #660 <https://www.github.com/FlexMeasures/flexmeasures/pull/660>`_]
* Remove API versions 1.0, 1.1, 1.2, 1.3 and 2.0, while allowing hosts to switch between ``HTTP status 410 (Gone)`` and ``HTTP status 404 (Not Found)``responses [see `PR #667 <https://www.github.com/FlexMeasures/flexmeasures/pull/667>`_]
.. warning:: The setting `FLEXMEASURES_PLUGIN_PATHS` has been deprecated since v0.7. It has now been sunset. Please replace it with :ref:`plugin-config`.
Expand Down
6 changes: 3 additions & 3 deletions documentation/configuration.rst
Original file line number Diff line number Diff line change
Expand Up @@ -618,10 +618,10 @@ FLEXMEASURES_API_SUNSET_ACTIVE
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Allow control over the effect of sunsetting API versions.
Specifically, if True, the endpoints in sunset versions will return ``HTTP status 410 (Gone)`` status codes.
If False, the endpoints will work like before, including Deprecation and Sunset headers in their response.
Specifically, if True, the endpoints of sunset API versions will return ``HTTP status 410 (Gone)`` status codes.
If False, these endpoints will either return ``HTTP status 404 (Not Found) status codes``, or work like before (including Deprecation and Sunset headers in their response), depending on whether the installed FlexMeasures version still contains the endpoint implementations.

Default: ``True``
Default: ``False``

FLEXMEASURES_API_SUNSET_DATE
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down
16 changes: 14 additions & 2 deletions flexmeasures/api/common/utils/deprecation_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,16 @@ def sunset_blueprint(
api_version_sunset: str,
sunset_link: str,
api_version_upgrade_to: str = "3.0",
blueprint_contents_removed: bool = True,
):
"""Sunsets every route on a blueprint by returning 410 (Gone) responses.
"""Sunsets every route on a blueprint by returning 410 (Gone) responses, if sunset is active.
Such errors will be logged by utils.error_utils.error_handling_router.
Whether the sunset is active can be toggled using the config setting "FLEXMEASURES_API_SUNSET_ACTIVE".
If inactive, either:
- return 404 (Not Found) if the blueprint contents have been removed, or
- pass the request to be handled by the endpoint implementation.
Errors will be logged by utils.error_utils.error_handling_router.
"""

def let_host_switch_to_returning_410():
Expand All @@ -30,6 +36,12 @@ def let_host_switch_to_returning_410():
410,
f"API version {api_version_sunset} has been sunset. Please upgrade to API version {api_version_upgrade_to}. See {_sunset_link} for more information.",
)
elif blueprint_contents_removed:
abort(404)
else:
# Sunset is inactive and blueprint contents are still there,
# so we let the request pass to the endpoint implementation
pass

blueprint.before_request(let_host_switch_to_returning_410)

Expand Down
Loading

0 comments on commit 8fcce5d

Please sign in to comment.