
This is initial commit adding pecan/wsme framework. Example operations are: * GET /v1/project_groups * GET /v1/project_groups/<group_name> * GET /v1/projects * GET /v1/projects/<project_name> * GET /v1/teams * GET /v1/teams/<team_name> * POST /v1/teams * POST /v1/teams/add_user * GET /v1/users * GET /v1/users/<username> * POST /v1/users * PUT /v1/users/<username> * GET /v1/stories * GET /v1/stories/<story_id> * POST /v1/stories * PUT /v1/stories * POST /v1/stories/add_task * POST /v1/stories/add_comment * GET /v1/tasks * GET /v1/tasks/<task_id> * PUT /v1/tasks More detailed documentation will be added later to a wiki page. Tests will be added in a separate CR. Auth stuff will be added in a separate CR after it is dicussed. Change-Id: Ibace8cf7dd5bb933b0d2484b1d57b79bb8441a28
51 lines
1.7 KiB
Python
51 lines
1.7 KiB
Python
# Copyright (c) 2013 Mirantis Inc.
|
|
#
|
|
# 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 pecan import rest
|
|
from wsme.exc import ClientSideError
|
|
import wsmeext.pecan as wsme_pecan
|
|
|
|
import storyboard.api.v1.wsme_models as wsme_models
|
|
|
|
|
|
class UsersController(rest.RestController):
|
|
|
|
@wsme_pecan.wsexpose([wsme_models.User])
|
|
def get(self):
|
|
users = wsme_models.User.get_all()
|
|
return users
|
|
|
|
@wsme_pecan.wsexpose(wsme_models.User, unicode)
|
|
def get_one(self, username):
|
|
user = wsme_models.User.get(username=username)
|
|
if not user:
|
|
raise ClientSideError("User %s not found" % username,
|
|
status_code=404)
|
|
return user
|
|
|
|
@wsme_pecan.wsexpose(wsme_models.User, wsme_models.User)
|
|
def post(self, user):
|
|
created_user = wsme_models.User.create(wsme_entry=user)
|
|
if not created_user:
|
|
raise ClientSideError("Could not create User")
|
|
return created_user
|
|
|
|
@wsme_pecan.wsexpose(wsme_models.User, unicode, wsme_models.User)
|
|
def put(self, username, user):
|
|
updated_user = wsme_models.User.update("username", username, user)
|
|
if not updated_user:
|
|
raise ClientSideError("Could not update user %s" % username)
|
|
return updated_user
|