Where is the mapping for the call 'POST /groups'?

Asked by Marcos Lobo

Hi,

For this API call:

curl -i -H "X-Auth-Token: admin1token" -H "Content-Type: application/json" -d '{"group": {"name": "Group2"}}' http://localhost:35357/v3/groups

Where is the file that mapping this call?. I was thinking that (maybe) it was at /keytsone/identity/routers.py, in the "append_v3_routers" method... but it's not.

Thank you.

Best regards,
Marcos.

Question information

Language:
English Edit question
Status:
Solved
For:
OpenStack Identity (keystone) Edit question
Assignee:
No assignee Edit question
Solved by:
Haneef Ali
Solved:
Last query:
Last reply:
Revision history for this message
Haneef Ali (haneef) said :
#1

Check common.routers.py - It is common for all resources. append_v3_routers calls this with the params ( users,domains,groups etc)

Revision history for this message
Marcos Lobo (marcos-fermin-lobo) said :
#2

Hi Haneef Ali,

I think there is not in this file. This is the content of common/router.py and it does not contain append_v3_routers (such as identity/router.py)

from keystone.common import wsgi

class Router(wsgi.ComposableRouter):
    def __init__(self, controller, collection_key, key):
        self.controller = controller
        self.key = key
        self.collection_key = collection_key

    def add_routes(self, mapper):
        collection_path = '/%(collection_key)s' % {
            'collection_key': self.collection_key}
        entity_path = '/%(collection_key)s/{%(key)s_id}' % {
            'collection_key': self.collection_key,
            'key': self.key}

        mapper.connect(
            collection_path,
            controller=self.controller,
            action='create_%s' % self.key,
            conditions=dict(method=['POST']))
        mapper.connect(
            collection_path,
            controller=self.controller,
            action='list_%s' % self.collection_key,
            conditions=dict(method=['GET']))
        mapper.connect(
            entity_path,
            controller=self.controller,
            action='get_%s' % self.key,
            conditions=dict(method=['GET']))
        mapper.connect(
            entity_path,
            controller=self.controller,
            action='update_%s' % self.key,
            conditions=dict(method=['PATCH']))
        mapper.connect(
            entity_path,
            controller=self.controller,
            action='delete_%s' % self.key,
            conditions=dict(method=['DELETE']))

Thank you.

Revision history for this message
Best Haneef Ali (haneef) said :
#3

This class is instantiated with collection name as "domains", groups, users etc. All of them follow the same pattern. So if you instantiate with collection name as "group" then, you get routes for "list_groups", "create_groups", "delete_groups" etc

If you look at append_v3_routers in identity/routers.py, you can see

 project_controller = controllers.ProjectV3()
    routers.append(
        router.Router(project_controller,
                      'projects', 'project'))

group_controller = controllers.GroupV3()
    routers.append(
        router.Router(group_controller,
                      'groups', 'group'))

etc which does adds those routes

Revision history for this message
Marcos Lobo (marcos-fermin-lobo) said :
#4

Thanks Haneef Ali, that solved my question.