
Added teams endpoint with support for nested Users resource. Change-Id: I5d93e91c268d5b35d10641bfce13e425f153d40d
51 lines
1.3 KiB
Python
51 lines
1.3 KiB
Python
# Copyright (c) 2014 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 storyboardclient import base
|
|
from storyboardclient.v1 import users
|
|
|
|
|
|
class UsersNestedManager(base.BaseNestedManager):
|
|
parent_url_key = "teams"
|
|
url_key = "users"
|
|
resource_class = users.User
|
|
|
|
def add(self, user):
|
|
if isinstance(user, users.User):
|
|
user_id = user.id
|
|
else:
|
|
user_id = user
|
|
|
|
self.put(id=user_id)
|
|
|
|
def remove(self, user):
|
|
if isinstance(user, users.User):
|
|
user_id = user.id
|
|
else:
|
|
user_id = user
|
|
|
|
self.delete(id=user_id)
|
|
|
|
|
|
class Team(base.BaseObject):
|
|
name = None
|
|
|
|
users = UsersNestedManager
|
|
|
|
|
|
class TeamsManager(base.BaseManager):
|
|
url_key = "teams"
|
|
resource_class = Team
|