diff --git a/api-ref/source/introspection-api-versions.inc b/api-ref/source/introspection-api-versions.inc index 86b9ea4de..b7e64bed5 100644 --- a/api-ref/source/introspection-api-versions.inc +++ b/api-ref/source/introspection-api-versions.inc @@ -12,14 +12,20 @@ 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 ``. 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 `` 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 ================= diff --git a/ironic_inspector/test/unit/test_main.py b/ironic_inspector/test/unit/test_main.py index da8fe56d9..b5ae21397 100644 --- a/ironic_inspector/test/unit/test_main.py +++ b/ironic_inspector/test/unit/test_main.py @@ -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, diff --git a/releasenotes/notes/parse-headers-with-the-microversion-parse-library-1b655eb52998f1df.yaml b/releasenotes/notes/parse-headers-with-the-microversion-parse-library-1b655eb52998f1df.yaml new file mode 100644 index 000000000..b46e0c800 --- /dev/null +++ b/releasenotes/notes/parse-headers-with-the-microversion-parse-library-1b655eb52998f1df.yaml @@ -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 '.