v3 Role CRUD

Change-Id: Iacb6e56ef60537b7cd3a4fbe3db1f0db1604fdc2
This commit is contained in:
Dolph Mathews
2012-09-11 15:34:56 -05:00
committed by Gerrit Code Review
parent ac3beb3671
commit f885c0d09a
3 changed files with 73 additions and 0 deletions

View File

@@ -19,6 +19,7 @@ from keystoneclient.v2_0 import client
from keystoneclient.v3 import endpoints from keystoneclient.v3 import endpoints
from keystoneclient.v3 import domains from keystoneclient.v3 import domains
from keystoneclient.v3 import policies from keystoneclient.v3 import policies
from keystoneclient.v3 import roles
from keystoneclient.v3 import services from keystoneclient.v3 import services
@@ -64,6 +65,7 @@ class Client(client.Client):
self.endpoints = endpoints.EndpointManager(self) self.endpoints = endpoints.EndpointManager(self)
self.domains = domains.DomainManager(self) self.domains = domains.DomainManager(self)
self.policies = policies.PolicyManager(self) self.policies = policies.PolicyManager(self)
self.roles = roles.RoleManager(self)
self.services = services.ServiceManager(self) self.services = services.ServiceManager(self)
# NOTE(gabriel): If we have a pre-defined endpoint then we can # NOTE(gabriel): If we have a pre-defined endpoint then we can

View File

@@ -0,0 +1,52 @@
# Copyright 2011 OpenStack LLC.
# Copyright 2011 Nebula, Inc.
# All Rights Reserved.
#
# 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 keystoneclient import base
class Role(base.Resource):
"""Represents an Identity role.
Attributes:
* id: a uuid that identifies the role
* name: user-facing identifier
"""
pass
class RoleManager(base.CrudManager):
"""Manager class for manipulating Identity roles."""
resource_class = Role
collection_key = 'roles'
key = 'role'
def create(self, name):
return super(RoleManager, self).create(
name=name)
def get(self, role):
return super(RoleManager, self).get(
role_id=base.getid(role))
def update(self, role, name=None):
return super(RoleManager, self).update(
role_id=base.getid(role),
name=name)
def delete(self, role):
return super(RoleManager, self).delete(
role_id=base.getid(role))

19
tests/v3/test_roles.py Normal file
View File

@@ -0,0 +1,19 @@
import uuid
from keystoneclient.v3 import roles
from tests.v3 import utils
class RoleTests(utils.TestCase, utils.CrudTests):
def setUp(self):
super(RoleTests, self).setUp()
self.additionalSetUp()
self.key = 'role'
self.collection_key = 'roles'
self.model = roles.Role
self.manager = self.client.roles
def new_ref(self, **kwargs):
kwargs = super(RoleTests, self).new_ref(**kwargs)
kwargs.setdefault('name', uuid.uuid4().hex)
return kwargs