From 35bc126876de4b3d4e1c68b56dadbcdee5a37a46 Mon Sep 17 00:00:00 2001 From: Michael Krotscheck Date: Tue, 28 Oct 2014 15:14:23 -0700 Subject: [PATCH] Add a rest endpoint to retreive system information The only information retreived in this change is the storyboard version. Keeping the object broad so additional info can piggy back down the road. Change-Id: I86a2bbdc367b9abb179937d74f4aa5ed937b077e --- doc/source/webapi/v1.rst | 9 +++++++ storyboard/api/v1/system_info.py | 40 ++++++++++++++++++++++++++++++ storyboard/api/v1/v1_controller.py | 2 ++ storyboard/api/v1/wmodels.py | 13 ++++++++++ 4 files changed, 64 insertions(+) create mode 100644 storyboard/api/v1/system_info.py diff --git a/doc/source/webapi/v1.rst b/doc/source/webapi/v1.rst index d4eac7b6..dbd8f48d 100644 --- a/doc/source/webapi/v1.rst +++ b/doc/source/webapi/v1.rst @@ -42,6 +42,10 @@ Users .. rest-controller:: storyboard.api.v1.users:UsersController :webprefix: /v1/users +System Info +=========== +.. rest-controller:: storyboard.api.v1.system_info:SystemInfoController + :webprefix: /v1/systeminfo ############ Object model @@ -81,3 +85,8 @@ User ==== .. autotype:: storyboard.api.v1.users.User :members: + +SystemInfo +========== +.. autotype:: storyboard.api.v1.system_info.SystemInfo + :members: diff --git a/storyboard/api/v1/system_info.py b/storyboard/api/v1/system_info.py new file mode 100644 index 00000000..d69c1293 --- /dev/null +++ b/storyboard/api/v1/system_info.py @@ -0,0 +1,40 @@ +# Copyright (c) 2013 Hewlett-Packard Development Company, L.P. +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or +# implied. +# See the License for the specific language governing permissions and +# limitations under the License. + +from oslo.config import cfg +from pbr.version import VersionInfo +from pecan import rest +from pecan.secure import secure +from storyboard.api.auth import authorization_checks as checks +from storyboard.api.v1 import wmodels +import wsmeext.pecan as wsme_pecan + +CONF = cfg.CONF + + +class SystemInfoController(rest.RestController): + """REST controller for sysinfo endpoint. + + Provides Get methods for System information. + """ + + @secure(checks.guest) + @wsme_pecan.wsexpose(wmodels.SystemInfo) + def get(self): + """Retrieve the Storyboard system information. + """ + sb_ver = VersionInfo('storyboard') + + return wmodels.SystemInfo(version=sb_ver.version_string()) diff --git a/storyboard/api/v1/v1_controller.py b/storyboard/api/v1/v1_controller.py index 703dc0a6..97b44315 100644 --- a/storyboard/api/v1/v1_controller.py +++ b/storyboard/api/v1/v1_controller.py @@ -19,6 +19,7 @@ from storyboard.api.v1.projects import ProjectsController from storyboard.api.v1.stories import StoriesController from storyboard.api.v1.subscription_events import SubscriptionEventsController from storyboard.api.v1.subscriptions import SubscriptionsController +from storyboard.api.v1.system_info import SystemInfoController from storyboard.api.v1.tasks import TasksController from storyboard.api.v1.teams import TeamsController from storyboard.api.v1.users import UsersController @@ -34,5 +35,6 @@ class V1Controller(object): tasks = TasksController() subscriptions = SubscriptionsController() subscription_events = SubscriptionEventsController() + systeminfo = SystemInfoController() openid = AuthController() diff --git a/storyboard/api/v1/wmodels.py b/storyboard/api/v1/wmodels.py index ace5344b..1a192456 100644 --- a/storyboard/api/v1/wmodels.py +++ b/storyboard/api/v1/wmodels.py @@ -36,6 +36,19 @@ class Comment(base.APIBase): """Is this an active comment, or has it been deleted?""" +class SystemInfo(base.APIBase): + """Represents the system information for Storyboard + """ + + version = wtypes.text + """The application version.""" + + @classmethod + def sample(cls): + return cls( + version="338c2d6") + + class Project(base.APIBase): """The Storyboard Registry describes the open source world as ProjectGroups and Projects. Each ProjectGroup may be responsible for several Projects.