OpenStack Identity (Keystone)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

routers.py 3.8KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  1. # Copyright 2014 IBM Corp.
  2. #
  3. # Licensed under the Apache License, Version 2.0 (the "License"); you may
  4. # not use this file except in compliance with the License. You may obtain
  5. # a copy of the License at
  6. #
  7. # http://www.apache.org/licenses/LICENSE-2.0
  8. #
  9. # Unless required by applicable law or agreed to in writing, software
  10. # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
  11. # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
  12. # License for the specific language governing permissions and limitations
  13. # under the License.
  14. import functools
  15. from keystone.common import json_home
  16. from keystone.common import wsgi
  17. from keystone.endpoint_policy import controllers
  18. build_resource_relation = functools.partial(
  19. json_home.build_v3_extension_resource_relation,
  20. extension_name='OS-ENDPOINT-POLICY', extension_version='1.0')
  21. class Routers(wsgi.RoutersBase):
  22. PATH_PREFIX = '/OS-ENDPOINT-POLICY'
  23. _path_prefixes = ('OS-ENDPOINT-POLICY',)
  24. def append_v3_routers(self, mapper, routers):
  25. endpoint_policy_controller = controllers.EndpointPolicyV3Controller()
  26. self._add_resource(
  27. mapper, endpoint_policy_controller,
  28. path='/endpoints/{endpoint_id}' + self.PATH_PREFIX + '/policy',
  29. get_head_action='get_policy_for_endpoint',
  30. rel=build_resource_relation(resource_name='endpoint_policy'),
  31. path_vars={'endpoint_id': json_home.Parameters.ENDPOINT_ID})
  32. self._add_resource(
  33. mapper, endpoint_policy_controller,
  34. path='/policies/{policy_id}' + self.PATH_PREFIX + '/endpoints',
  35. get_head_action='list_endpoints_for_policy',
  36. rel=build_resource_relation(resource_name='policy_endpoints'),
  37. path_vars={'policy_id': json_home.Parameters.POLICY_ID})
  38. self._add_resource(
  39. mapper, endpoint_policy_controller,
  40. path=('/policies/{policy_id}' + self.PATH_PREFIX +
  41. '/endpoints/{endpoint_id}'),
  42. get_head_action='check_policy_association_for_endpoint',
  43. put_action='create_policy_association_for_endpoint',
  44. delete_action='delete_policy_association_for_endpoint',
  45. rel=build_resource_relation(
  46. resource_name='endpoint_policy_association'),
  47. path_vars={
  48. 'policy_id': json_home.Parameters.POLICY_ID,
  49. 'endpoint_id': json_home.Parameters.ENDPOINT_ID,
  50. })
  51. self._add_resource(
  52. mapper, endpoint_policy_controller,
  53. path=('/policies/{policy_id}' + self.PATH_PREFIX +
  54. '/services/{service_id}'),
  55. get_head_action='check_policy_association_for_service',
  56. put_action='create_policy_association_for_service',
  57. delete_action='delete_policy_association_for_service',
  58. rel=build_resource_relation(
  59. resource_name='service_policy_association'),
  60. path_vars={
  61. 'policy_id': json_home.Parameters.POLICY_ID,
  62. 'service_id': json_home.Parameters.SERVICE_ID,
  63. })
  64. self._add_resource(
  65. mapper, endpoint_policy_controller,
  66. path=('/policies/{policy_id}' + self.PATH_PREFIX +
  67. '/services/{service_id}/regions/{region_id}'),
  68. get_head_action='check_policy_association_for_region_and_service',
  69. put_action='create_policy_association_for_region_and_service',
  70. delete_action='delete_policy_association_for_region_and_service',
  71. rel=build_resource_relation(
  72. resource_name='region_and_service_policy_association'),
  73. path_vars={
  74. 'policy_id': json_home.Parameters.POLICY_ID,
  75. 'service_id': json_home.Parameters.SERVICE_ID,
  76. 'region_id': json_home.Parameters.REGION_ID,
  77. })