summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDolph Mathews <dolph.mathews@gmail.com>2012-09-11 15:34:56 -0500
committerGerrit Code Review <review@openstack.org>2012-10-08 23:02:30 +0000
commitf885c0d09a6464e0d94d1c295a605877d711f88a (patch)
treed58eaace8a2752398ab378ddc0e697979d241dec
parentac3beb3671cdccf9a5285e8b2296e950b1a8be9b (diff)
downloadpython-keystoneclient-f885c0d09a6464e0d94d1c295a605877d711f88a.tar.gz
v3 Role CRUD
Change-Id: Iacb6e56ef60537b7cd3a4fbe3db1f0db1604fdc2
-rw-r--r--keystoneclient/v3/client.py2
-rw-r--r--keystoneclient/v3/roles.py52
-rw-r--r--tests/v3/test_roles.py19
3 files changed, 73 insertions, 0 deletions
diff --git a/keystoneclient/v3/client.py b/keystoneclient/v3/client.py
index 3117c2a..f2ea9b5 100644
--- a/keystoneclient/v3/client.py
+++ b/keystoneclient/v3/client.py
@@ -19,6 +19,7 @@ from keystoneclient.v2_0 import client
from keystoneclient.v3 import endpoints
from keystoneclient.v3 import domains
from keystoneclient.v3 import policies
+from keystoneclient.v3 import roles
from keystoneclient.v3 import services
@@ -64,6 +65,7 @@ class Client(client.Client):
self.endpoints = endpoints.EndpointManager(self)
self.domains = domains.DomainManager(self)
self.policies = policies.PolicyManager(self)
+ self.roles = roles.RoleManager(self)
self.services = services.ServiceManager(self)
# NOTE(gabriel): If we have a pre-defined endpoint then we can
diff --git a/keystoneclient/v3/roles.py b/keystoneclient/v3/roles.py
new file mode 100644
index 0000000..0e0c180
--- /dev/null
+++ b/keystoneclient/v3/roles.py
@@ -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))
diff --git a/tests/v3/test_roles.py b/tests/v3/test_roles.py
new file mode 100644
index 0000000..ef1f7ce
--- /dev/null
+++ b/tests/v3/test_roles.py
@@ -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