Follow-up: Use ``microversion-parse`` to parse version headers in API requests

Adds a release note, unit test, and documentation update as a follow-up to the
`microversion-parse change <https://review.opendev.org/c/openstack/ironic-inspector/+/913794>`_

Change-Id: I2fc3ff32a96035e40d70c39ea34d494466060fb6
This commit is contained in:
cid 2024-04-18 01:48:35 +01:00
parent 8a9e03c3fb
commit 887b6c4f04
3 changed files with 26 additions and 4 deletions

View File

@ -12,14 +12,18 @@ Inspector API supports versioning. There are two kinds of versions:
- ``major versions``, which have dedicated urls.
- ``microversions``, which can be requested through the use of the
``X-OpenStack-Ironic-Inspector-API-Version`` header.
``X-OpenStack-Ironic-Inspector-API-Version`` header or the new standard singular header
``OpenStack-API-Version: baremetal-introspection <version>``.
The Version APIs work differently from other APIs as they *do not* require
authentication.
All API requests support the ``X-OpenStack-Ironic-Inspector-API-Version``
header. This header SHOULD be supplied with every request; in the absence of
this header, server will default to current supported version in all responses.
All API requests support the new standard singular header
``OpenStack-API-Version: baremetal-introspection <version>`` and the legacy
``X-OpenStack-Ironic-Inspector-API-Version`` header.
Either of these headers SHOULD be supplied with every request; in the absence of
both headers, server will default to current supported version in all responses.
List API versions
=================

View File

@ -763,6 +763,11 @@ class TestApiVersions(BaseAPITest):
main._format_version(main.CURRENT_API_VERSION)}
self._check_version_present(self.app.get('/', headers=headers))
def test_request_correct_version_with_standard_singular_header(self):
headers = {'OpenStack-API-Version': 'baremetal-introspection %s' %
main._format_version(main.CURRENT_API_VERSION)}
self._check_version_present(self.app.get('/', headers=headers))
def test_request_unsupported_version(self):
bad_version = (main.CURRENT_API_VERSION[0],
main.CURRENT_API_VERSION[1] + 1)
@ -782,6 +787,12 @@ class TestApiVersions(BaseAPITest):
self.assertEqual(200, res.status_code)
self._check_version_present(res)
def test_request_latest_version_with_standard_singular_header(self):
headers = {'OpenStack-API-Version': 'baremetal-introspection latest'}
res = self.app.get('/', headers=headers)
self.assertEqual(200, res.status_code)
self._check_version_present(res)
class TestPlugins(unittest.TestCase):
@mock.patch.object(example_plugin.ExampleProcessingHook,

View File

@ -0,0 +1,7 @@
---
features:
- |
Delegate parsing of version headers in API requests to the
``microversion-parse`` library which also adds support for the new
standard singular header:
'OpenStack-API-Version: baremetal-introspection <version>'.