Merge "identity: Add support for endpoint projects"
This commit is contained in:
commit
42011c556b
@ -67,7 +67,7 @@ Project Operations
|
||||
.. autoclass:: openstack.identity.v3._proxy.Proxy
|
||||
:noindex:
|
||||
:members: create_project, update_project, delete_project, get_project,
|
||||
find_project, projects, user_projects
|
||||
find_project, projects, user_projects, endpoint_projects
|
||||
|
||||
Service Operations
|
||||
^^^^^^^^^^^^^^^^^^
|
||||
|
@ -736,6 +736,23 @@ class Proxy(proxy.Proxy):
|
||||
user = self._get_resource(_user.User, user)
|
||||
return self._list(_project.UserProject, user_id=user.id, **query)
|
||||
|
||||
def endpoint_projects(self, endpoint, **query):
|
||||
"""Retrieve a generator of projects which are associated with the
|
||||
endpoint.
|
||||
|
||||
:param endpoint: Either the endpoint ID or an instance of
|
||||
:class:`~openstack.identity.v3.endpoint.Endpoint`
|
||||
:param kwargs query: Optional query parameters to be sent to limit
|
||||
the resources being returned.
|
||||
|
||||
:returns: A generator of project instances.
|
||||
:rtype: :class:`~openstack.identity.v3.project.EndpointProject`
|
||||
"""
|
||||
endpoint_id = self._get_resource(_endpoint.Endpoint, endpoint).id
|
||||
return self._list(
|
||||
_project.EndpointProject, endpoint_id=endpoint_id, **query
|
||||
)
|
||||
|
||||
def update_project(self, project, **attrs):
|
||||
"""Update a project
|
||||
|
||||
|
@ -161,10 +161,25 @@ class Project(resource.Resource, tag.TagMixin):
|
||||
|
||||
|
||||
class UserProject(Project):
|
||||
resource_key = 'project'
|
||||
resources_key = 'projects'
|
||||
base_path = '/users/%(user_id)s/projects'
|
||||
|
||||
#: The ID for the user from the URI of the resource
|
||||
user_id = resource.URI('user_id')
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_fetch = False
|
||||
allow_commit = False
|
||||
allow_delete = False
|
||||
allow_list = True
|
||||
|
||||
|
||||
class EndpointProject(Project):
|
||||
base_path = '/OS-EP-FILTER/endpoints/%(endpoint_id)s/projects'
|
||||
|
||||
#: The ID for the endpoint from the URI of the resource
|
||||
endpoint_id = resource.URI('endpoint_id')
|
||||
|
||||
# capabilities
|
||||
allow_create = False
|
||||
allow_fetch = False
|
||||
|
@ -36,6 +36,7 @@ from openstack.identity.v3 import user
|
||||
from openstack.tests.unit import test_proxy_base
|
||||
|
||||
USER_ID = 'user-id-' + uuid.uuid4().hex
|
||||
ENDPOINT_ID = 'user-id-' + uuid.uuid4().hex
|
||||
|
||||
|
||||
class TestIdentityProxyBase(test_proxy_base.TestProxyBase):
|
||||
@ -302,6 +303,14 @@ class TestIdentityProxyProject(TestIdentityProxyBase):
|
||||
expected_kwargs={'user_id': USER_ID},
|
||||
)
|
||||
|
||||
def test_endpoint_projects(self):
|
||||
self.verify_list(
|
||||
self.proxy.endpoint_projects,
|
||||
project.EndpointProject,
|
||||
method_kwargs={'endpoint': ENDPOINT_ID},
|
||||
expected_kwargs={'endpoint_id': ENDPOINT_ID},
|
||||
)
|
||||
|
||||
def test_project_update(self):
|
||||
self.verify_update(self.proxy.update_project, project.Project)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user