From c11547badde8aec7576389c32a220b373f35fa87 Mon Sep 17 00:00:00 2001 From: Adam Coldrick Date: Fri, 15 Mar 2019 10:44:23 +0000 Subject: [PATCH] Include enabled features in /v1/systeminfo output Currently the /v1/systeminfo endpoint is largely useless and just returns the version of the API as specified in setup.cfg. This commit adds functionality to also return information about which features are enabled in a specific backend's configuration. Change-Id: I9934f656643bb764edc986231b198d92ddc66934 --- storyboard/api/v1/system_info.py | 10 +++++++++- storyboard/api/v1/wmodels.py | 4 ++++ storyboard/tests/api/test_system_info.py | 2 +- 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/storyboard/api/v1/system_info.py b/storyboard/api/v1/system_info.py index 103b313c..4374153a 100644 --- a/storyboard/api/v1/system_info.py +++ b/storyboard/api/v1/system_info.py @@ -1,4 +1,5 @@ # Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# Copyright (c) 2019 Codethink Ltd. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -41,5 +42,12 @@ class SystemInfoController(rest.RestController): """ sb_ver = VersionInfo('storyboard-api') + config = { + 'enable_editable_comments': CONF.enable_editable_comments, + 'enable_notifications': CONF.enable_notifications + } - return wmodels.SystemInfo(version=sb_ver.version_string()) + return wmodels.SystemInfo( + config=config, + version=sb_ver.version_string() + ) diff --git a/storyboard/api/v1/wmodels.py b/storyboard/api/v1/wmodels.py index d6a91156..eb623fb4 100644 --- a/storyboard/api/v1/wmodels.py +++ b/storyboard/api/v1/wmodels.py @@ -64,12 +64,16 @@ class SystemInfo(base.APIBase): """Represents the system information for Storyboard """ + config = {wtypes.text: bool} + """Information about enabled features from configuration.""" + version = wtypes.text """The application version.""" @classmethod def sample(cls): return cls( + config={"enable_editable_comments": True}, version="338c2d6") diff --git a/storyboard/tests/api/test_system_info.py b/storyboard/tests/api/test_system_info.py index 891d3a65..5151730b 100644 --- a/storyboard/tests/api/test_system_info.py +++ b/storyboard/tests/api/test_system_info.py @@ -28,4 +28,4 @@ class TestSystemInfo(base.FunctionalTest): preferences work properly. """ response = self.get_json(self.resource) - self.assertEqual(1, len(response)) + self.assertEqual(2, len(response))