Port identity v2 to resource2
This change moves over the identity v2 service to resource2/proxy2. It's mostly a renaming and updating to fit the new API. Change-Id: I95ab21c13bcdc24bf5daadf58f79d0f53c8bd75e
This commit is contained in:
parent
749abc7195
commit
21dcba4d53
@ -12,7 +12,15 @@ The identity high-level interface is available through the ``identity``
|
||||
member of a :class:`~openstack.connection.Connection` object. The
|
||||
``identity`` member will only be added if the service is detected.
|
||||
|
||||
User Operations
|
||||
Extension Operations
|
||||
^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
.. autoclass:: openstack.identity.v2._proxy.Proxy
|
||||
|
||||
.. automethod:: openstack.identity.v2._proxy.Proxy.get_extension
|
||||
.. automethod:: openstack.identity.v2._proxy.Proxy.extensions
|
||||
|
||||
User Operations
|
||||
^^^^^^^^^^^^^^^
|
||||
|
||||
.. autoclass:: openstack.identity.v2._proxy.Proxy
|
||||
|
@ -10,14 +10,36 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
from openstack.identity.v2 import extension as _extension
|
||||
from openstack.identity.v2 import role as _role
|
||||
from openstack.identity.v2 import tenant as _tenant
|
||||
from openstack.identity.v2 import user as _user
|
||||
from openstack import proxy
|
||||
from openstack import proxy2 as proxy
|
||||
|
||||
|
||||
class Proxy(proxy.BaseProxy):
|
||||
|
||||
def extensions(self):
|
||||
"""Retrieve a generator of extensions
|
||||
|
||||
:returns: A generator of extension instances.
|
||||
:rtype: :class:`~openstack.identity.v2.extension.Extension`
|
||||
"""
|
||||
return self._list(_extension.Extension, paginated=False)
|
||||
|
||||
def get_extension(self, extension):
|
||||
"""Get a single extension
|
||||
|
||||
:param extension: The value can be the ID of an extension or a
|
||||
:class:`~openstack.identity.v2.extension.Extension`
|
||||
instance.
|
||||
|
||||
:returns: One :class:`~openstack.identity.v2.extension.Extension`
|
||||
:raises: :class:`~openstack.exceptions.ResourceNotFound`
|
||||
when no extension can be found.
|
||||
"""
|
||||
return self._get(_extension.Extension, extension)
|
||||
|
||||
def create_role(self, **attrs):
|
||||
"""Create a new role from attributes
|
||||
|
||||
|
@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.identity import identity_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Extension(resource.Resource):
|
||||
@ -22,29 +22,30 @@ class Extension(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_list = True
|
||||
allow_get = True
|
||||
|
||||
# Properties
|
||||
#: A unique identifier, which will be used for accessing the extension
|
||||
#: through a dedicated url ``/extensions/*alias*``. The extension
|
||||
#: alias uniquely identifies an extension and is prefixed by a vendor
|
||||
#: identifier. *Type: string*
|
||||
alias = resource.prop('alias')
|
||||
alias = resource.Body('alias', alternate_id=True)
|
||||
#: A description of the extension. *Type: string*
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: Links to the documentation in various format. *Type: string*
|
||||
links = resource.prop('links')
|
||||
links = resource.Body('links')
|
||||
#: The name of the extension. *Type: string*
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
#: The second unique identifier of the extension after the alias.
|
||||
#: It is usually a URL which will be used. Example:
|
||||
#: "http://docs.openstack.org/identity/api/ext/s3tokens/v1.0"
|
||||
#: *Type: string*
|
||||
namespace = resource.prop('namespace')
|
||||
namespace = resource.Body('namespace')
|
||||
#: The last time the extension has been modified (update date).
|
||||
updated_at = resource.prop('updated')
|
||||
updated_at = resource.Body('updated')
|
||||
|
||||
@classmethod
|
||||
def list(cls, session, **params):
|
||||
def list(cls, session, paginated=False, **params):
|
||||
resp = session.get(cls.base_path, endpoint_filter=cls.service,
|
||||
params=params)
|
||||
resp = resp.json()
|
||||
|
@ -12,7 +12,7 @@
|
||||
|
||||
from openstack import format
|
||||
from openstack.identity import identity_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Role(resource.Resource):
|
||||
@ -23,16 +23,16 @@ class Role(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: The description of the role. *Type: string*
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: Setting this attribute to ``False`` prevents this role from being
|
||||
#: available in the role list. *Type: bool*
|
||||
is_enabled = resource.prop('enabled', type=format.BoolStr)
|
||||
is_enabled = resource.Body('enabled', type=format.BoolStr)
|
||||
#: Unique role name. *Type: string*
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
|
@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.identity import identity_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class Tenant(resource.Resource):
|
||||
@ -22,18 +22,18 @@ class Tenant(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: The description of the tenant. *Type: string*
|
||||
description = resource.prop('description')
|
||||
description = resource.Body('description')
|
||||
#: Setting this attribute to ``False`` prevents users from authorizing
|
||||
#: against this tenant. Additionally, all pre-existing tokens authorized
|
||||
#: for the tenant are immediately invalidated. Re-enabling a tenant
|
||||
#: does not re-enable pre-existing tokens. *Type: bool*
|
||||
is_enabled = resource.prop('enabled', type=bool)
|
||||
is_enabled = resource.Body('enabled', type=bool)
|
||||
#: Unique tenant name. *Type: string*
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
|
@ -11,7 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
from openstack.identity import identity_service
|
||||
from openstack import resource
|
||||
from openstack import resource2 as resource
|
||||
|
||||
|
||||
class User(resource.Resource):
|
||||
@ -22,18 +22,18 @@ class User(resource.Resource):
|
||||
|
||||
# capabilities
|
||||
allow_create = True
|
||||
allow_retrieve = True
|
||||
allow_get = True
|
||||
allow_update = True
|
||||
allow_delete = True
|
||||
allow_list = True
|
||||
|
||||
# Properties
|
||||
#: The email of this user. *Type: string*
|
||||
email = resource.prop('email')
|
||||
email = resource.Body('email')
|
||||
#: Setting this value to ``False`` prevents the user from authenticating or
|
||||
#: receiving authorization. Additionally, all pre-existing tokens held by
|
||||
#: the user are immediately invalidated. Re-enabling a user does not
|
||||
#: re-enable pre-existing tokens. *Type: bool*
|
||||
is_enabled = resource.prop('enabled', type=bool)
|
||||
is_enabled = resource.Body('enabled', type=bool)
|
||||
#: The name of this user. *Type: string*
|
||||
name = resource.prop('name')
|
||||
name = resource.Body('name')
|
||||
|
@ -35,13 +35,13 @@ class TestExtension(testtools.TestCase):
|
||||
self.assertEqual('/extensions', sot.base_path)
|
||||
self.assertEqual('identity', sot.service.service_type)
|
||||
self.assertFalse(sot.allow_create)
|
||||
self.assertFalse(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertFalse(sot.allow_update)
|
||||
self.assertFalse(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = extension.Extension(EXAMPLE)
|
||||
sot = extension.Extension(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['alias'], sot.alias)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertEqual(EXAMPLE['links'], sot.links)
|
||||
@ -62,7 +62,7 @@ class TestExtension(testtools.TestCase):
|
||||
resp.json = mock.Mock(return_value=resp.body)
|
||||
session = mock.Mock()
|
||||
session.get = mock.Mock(return_value=resp)
|
||||
sot = extension.Extension(EXAMPLE)
|
||||
sot = extension.Extension(**EXAMPLE)
|
||||
result = sot.list(session)
|
||||
self.assertEqual(next(result).name, 'a')
|
||||
self.assertEqual(next(result).name, 'b')
|
||||
|
@ -14,7 +14,7 @@ from openstack.identity.v2 import _proxy
|
||||
from openstack.identity.v2 import role
|
||||
from openstack.identity.v2 import tenant
|
||||
from openstack.identity.v2 import user
|
||||
from openstack.tests.unit import test_proxy_base
|
||||
from openstack.tests.unit import test_proxy_base2 as test_proxy_base
|
||||
|
||||
|
||||
class TestIdentityProxy(test_proxy_base.TestProxyBase):
|
||||
|
@ -32,14 +32,13 @@ class TestRole(testtools.TestCase):
|
||||
self.assertEqual('/OS-KSADM/roles', sot.base_path)
|
||||
self.assertEqual('identity', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = role.Role(EXAMPLE)
|
||||
self.assertTrue(sot.enabled)
|
||||
sot = role.Role(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||
self.assertEqual(EXAMPLE['name'], sot.name)
|
||||
|
@ -32,13 +32,13 @@ class TestTenant(testtools.TestCase):
|
||||
self.assertEqual('/tenants', sot.base_path)
|
||||
self.assertEqual('identity', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = tenant.Tenant(EXAMPLE)
|
||||
sot = tenant.Tenant(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['description'], sot.description)
|
||||
self.assertTrue(sot.is_enabled)
|
||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||
|
@ -32,13 +32,13 @@ class TestUser(testtools.TestCase):
|
||||
self.assertEqual('/users', sot.base_path)
|
||||
self.assertEqual('identity', sot.service.service_type)
|
||||
self.assertTrue(sot.allow_create)
|
||||
self.assertTrue(sot.allow_retrieve)
|
||||
self.assertTrue(sot.allow_get)
|
||||
self.assertTrue(sot.allow_update)
|
||||
self.assertTrue(sot.allow_delete)
|
||||
self.assertTrue(sot.allow_list)
|
||||
|
||||
def test_make_it(self):
|
||||
sot = user.User(EXAMPLE)
|
||||
sot = user.User(**EXAMPLE)
|
||||
self.assertEqual(EXAMPLE['email'], sot.email)
|
||||
self.assertTrue(sot.is_enabled)
|
||||
self.assertEqual(EXAMPLE['id'], sot.id)
|
||||
|
Loading…
x
Reference in New Issue
Block a user