def append_v3_routers(self, mapper, routers):
        routers.append(
            router.Router(controllers.DomainV3(),
                          'domains',
                          'domain',
                          resource_descriptions=self.v3_resources))

        config_controller = controllers.DomainConfigV3()

        self._add_resource(
            mapper,
            config_controller,
            path='/domains/{domain_id}/config',
            get_head_action='get_domain_config',
            put_action='create_domain_config',
            patch_action='update_domain_config_only',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config'),
            status=json_home.Status.EXPERIMENTAL,
            path_vars={'domain_id': json_home.Parameters.DOMAIN_ID})

        config_group_param = (
            json_home.build_v3_parameter_relation('config_group'))
        self._add_resource(
            mapper,
            config_controller,
            path='/domains/{domain_id}/config/{group}',
            get_head_action='get_domain_config',
            patch_action='update_domain_config_group',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_group'),
            status=json_home.Status.EXPERIMENTAL,
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param
            })

        self._add_resource(
            mapper,
            config_controller,
            path='/domains/{domain_id}/config/{group}/{option}',
            get_head_action='get_domain_config',
            patch_action='update_domain_config',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_option'),
            status=json_home.Status.EXPERIMENTAL,
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param,
                'option':
                json_home.build_v3_parameter_relation('config_option')
            })

        routers.append(
            router.Router(controllers.ProjectV3(),
                          'projects',
                          'project',
                          resource_descriptions=self.v3_resources))
Beispiel #2
0
    def append_v3_routers(self, mapper, routers):
        routers.append(
            router.Router(controllers.DomainV3(),
                          'domains', 'domain',
                          resource_descriptions=self.v3_resources))

        config_controller = controllers.DomainConfigV3()

        self._add_resource(
            mapper, config_controller,
            path='/domains/{domain_id}/config',
            get_head_action='get_domain_config',
            put_action='create_domain_config',
            patch_action='update_domain_config_only',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config'),
            status=json_home.Status.EXPERIMENTAL,
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID
            })

        config_group_param = (
            json_home.build_v3_parameter_relation('config_group'))
        self._add_resource(
            mapper, config_controller,
            path='/domains/{domain_id}/config/{group}',
            get_head_action='get_domain_config',
            patch_action='update_domain_config_group',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_group'),
            status=json_home.Status.EXPERIMENTAL,
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param
            })

        self._add_resource(
            mapper, config_controller,
            path='/domains/{domain_id}/config/{group}/{option}',
            get_head_action='get_domain_config',
            patch_action='update_domain_config',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_option'),
            status=json_home.Status.EXPERIMENTAL,
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param,
                'option': json_home.build_v3_parameter_relation(
                    'config_option')
            })

        routers.append(
            router.Router(controllers.ProjectV3(),
                          'projects', 'project',
                          resource_descriptions=self.v3_resources))
Beispiel #3
0
    def append_v3_routers(self, mapper, routers):
        ec2_controller = controllers.Ec2ControllerV3()
        # validation
        self._add_resource(
            mapper, ec2_controller,
            path='/ec2tokens',
            post_action='authenticate',
            rel=build_resource_relation(resource_name='ec2tokens'))

        # crud
        self._add_resource(
            mapper, ec2_controller,
            path='/users/{user_id}/credentials/OS-EC2',
            get_head_action='ec2_list_credentials',
            post_action='ec2_create_credential',
            rel=build_resource_relation(resource_name='user_credentials'),
            path_vars={
                'user_id': json_home.Parameters.USER_ID,
            })
        self._add_resource(
            mapper, ec2_controller,
            path='/users/{user_id}/credentials/OS-EC2/{credential_id}',
            get_head_action='ec2_get_credential',
            delete_action='ec2_delete_credential',
            rel=build_resource_relation(resource_name='user_credential'),
            path_vars={
                'credential_id':
                json_home.build_v3_parameter_relation('credential_id'),
                'user_id': json_home.Parameters.USER_ID,
            })
 def test_build_v3_parameter_relation(self):
     parameter_name = self.getUniqueString()
     relation = json_home.build_v3_parameter_relation(parameter_name)
     exp_relation = (
         'http://docs.openstack.org/api/openstack-identity/3/param/%s' %
         parameter_name)
     self.assertThat(relation, matchers.Equals(exp_relation))
    def test_construct_resource_map(self):
        param_relation = json_home.build_v3_parameter_relation(
            'argument_id')
        url = '/v3/arguments/<string:argument_id>'
        old_url = ['/v3/old_arguments/<string:argument_id>']
        resource_name = 'arguments'

        mapping = flask_common.construct_resource_map(
            resource=_TestResourceWithCollectionInfo,
            url=url,
            resource_kwargs={},
            alternate_urls=old_url,
            rel=resource_name,
            status=json_home.Status.EXPERIMENTAL,
            path_vars={'argument_id': param_relation},
            resource_relation_func=json_home.build_v3_resource_relation)
        self.assertEqual(_TestResourceWithCollectionInfo,
                         mapping.resource)
        self.assertEqual(url, mapping.url)
        self.assertEqual(old_url, mapping.alternate_urls)
        self.assertEqual(json_home.build_v3_resource_relation(resource_name),
                         mapping.json_home_data.rel)
        self.assertEqual(json_home.Status.EXPERIMENTAL,
                         mapping.json_home_data.status)
        self.assertEqual({'argument_id': param_relation},
                         mapping.json_home_data.path_vars)
Beispiel #6
0
    def add_routes(self, mapper):
        ec2_controller = controllers.Ec2ControllerV3()
        # validation
        self._add_resource(
            mapper,
            ec2_controller,
            path='/ec2tokens',
            post_action='authenticate',
            rel=build_resource_relation(resource_name='ec2tokens'))

        # crud
        self._add_resource(
            mapper,
            ec2_controller,
            path='/users/{user_id}/credentials/OS-EC2',
            get_head_action='ec2_list_credentials',
            post_action='ec2_create_credential',
            rel=build_resource_relation(resource_name='user_credentials'),
            path_vars={
                'user_id': json_home.Parameters.USER_ID,
            })
        self._add_resource(
            mapper,
            ec2_controller,
            path='/users/{user_id}/credentials/OS-EC2/{credential_id}',
            get_head_action='ec2_get_credential',
            delete_action='ec2_delete_credential',
            rel=build_resource_relation(resource_name='user_credential'),
            path_vars={
                'credential_id':
                json_home.build_v3_parameter_relation('credential_id'),
                'user_id':
                json_home.Parameters.USER_ID,
            })
 def test_build_v3_parameter_relation(self):
     parameter_name = self.getUniqueString()
     relation = json_home.build_v3_parameter_relation(parameter_name)
     exp_relation = (
         'http://docs.openstack.org/api/openstack-identity/3/param/%s' %
         parameter_name)
     self.assertThat(relation, matchers.Equals(exp_relation))
Beispiel #8
0
    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']))

        if self._resource_descriptions is not None:
            # Add the collection resource and entity resource to the resource
            # descriptions.

            collection_rel = json_home.build_v3_resource_relation(
                self.collection_key)
            self._resource_descriptions.append(
                (collection_rel,
                 {
                     'href': collection_path,
                 }
                 ))

            if self._is_entity_implemented:
                entity_rel = json_home.build_v3_resource_relation(self.key)
                id_str = '%s_id' % self.key
                id_param_rel = json_home.build_v3_parameter_relation(id_str)
                self._resource_descriptions.append(
                    (entity_rel,
                     {
                         'href-template': entity_path,
                         'href-vars': {
                             id_str: id_param_rel,
                         },
                     }
                     ))
Beispiel #9
0
    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=self.method_template % 'create_%s' % self.key,
                       conditions=dict(method=['POST']))
        mapper.connect(collection_path,
                       controller=self.controller,
                       action=self.method_template % 'list_%s' %
                       self.collection_key,
                       conditions=dict(method=['GET', 'HEAD']))
        mapper.connect(entity_path,
                       controller=self.controller,
                       action=self.method_template % 'get_%s' % self.key,
                       conditions=dict(method=['GET', 'HEAD']))
        mapper.connect(entity_path,
                       controller=self.controller,
                       action=self.method_template % 'update_%s' % self.key,
                       conditions=dict(method=['PATCH']))
        mapper.connect(entity_path,
                       controller=self.controller,
                       action=self.method_template % 'delete_%s' % self.key,
                       conditions=dict(method=['DELETE']))

        # Add the collection resource and entity resource to the resource
        # descriptions.

        collection_rel = json_home.build_v3_resource_relation(
            self.collection_key)
        rel_data = {
            'href': collection_path,
        }
        self._resource_descriptions.append((collection_rel, rel_data))
        json_home.JsonHomeResources.append_resource(collection_rel, rel_data)

        if self._is_entity_implemented:
            entity_rel = json_home.build_v3_resource_relation(self.key)
            id_str = '%s_id' % self.key
            id_param_rel = json_home.build_v3_parameter_relation(id_str)
            entity_rel_data = {
                'href-template': entity_path,
                'href-vars': {
                    id_str: id_param_rel,
                },
            }
            self._resource_descriptions.append((entity_rel, entity_rel_data))
            json_home.JsonHomeResources.append_resource(
                entity_rel, entity_rel_data)
Beispiel #10
0
    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=self.method_template % "create_%s" % self.key,
            conditions=dict(method=["POST"]),
        )
        mapper.connect(
            collection_path,
            controller=self.controller,
            action=self.method_template % "list_%s" % self.collection_key,
            conditions=dict(method=["GET"]),
        )
        mapper.connect(
            entity_path,
            controller=self.controller,
            action=self.method_template % "get_%s" % self.key,
            conditions=dict(method=["GET"]),
        )
        mapper.connect(
            entity_path,
            controller=self.controller,
            action=self.method_template % "update_%s" % self.key,
            conditions=dict(method=["PATCH"]),
        )
        mapper.connect(
            entity_path,
            controller=self.controller,
            action=self.method_template % "delete_%s" % self.key,
            conditions=dict(method=["DELETE"]),
        )

        # Add the collection resource and entity resource to the resource
        # descriptions.

        collection_rel = json_home.build_v3_resource_relation(self.collection_key)
        rel_data = {"href": collection_path}
        self._resource_descriptions.append((collection_rel, rel_data))

        if self._is_entity_implemented:
            entity_rel = json_home.build_v3_resource_relation(self.key)
            id_str = "%s_id" % self.key
            id_param_rel = json_home.build_v3_parameter_relation(id_str)
            entity_rel_data = {"href-template": entity_path, "href-vars": {id_str: id_param_rel}}
            self._resource_descriptions.append((entity_rel, entity_rel_data))
Beispiel #11
0
    def test_construct_resource_map(self):
        resource_name = 'arguments'
        param_relation = json_home.build_v3_parameter_relation(
            'argument_id')
        alt_rel_func = functools.partial(
            json_home.build_v3_extension_resource_relation,
            extension_name='extension', extension_version='1.0')
        url = '/v3/arguments/<string:argument_id>'
        old_url = [dict(
            url='/v3/old_arguments/<string:argument_id>',
            json_home=flask_common.construct_json_home_data(
                rel='arguments',
                resource_relation_func=alt_rel_func)
        )]

        mapping = flask_common.construct_resource_map(
            resource=_TestResourceWithCollectionInfo,
            url=url,
            resource_kwargs={},
            alternate_urls=old_url,
            rel=resource_name,
            status=json_home.Status.EXPERIMENTAL,
            path_vars={'argument_id': param_relation},
            resource_relation_func=json_home.build_v3_resource_relation)
        self.assertEqual(_TestResourceWithCollectionInfo,
                         mapping.resource)
        self.assertEqual(url, mapping.url)
        self.assertEqual(json_home.build_v3_resource_relation(resource_name),
                         mapping.json_home_data.rel)
        self.assertEqual(json_home.Status.EXPERIMENTAL,
                         mapping.json_home_data.status)
        self.assertEqual({'argument_id': param_relation},
                         mapping.json_home_data.path_vars)
        # Check the alternate URL data is populated sanely
        self.assertEqual(1, len(mapping.alternate_urls))
        alt_url_data = mapping.alternate_urls[0]
        self.assertEqual(old_url[0]['url'], alt_url_data['url'])
        self.assertEqual(old_url[0]['json_home'], alt_url_data['json_home'])
Beispiel #12
0
class UserAPI(ks_flask.APIBase):
    _name = 'users'
    _import_name = __name__
    resources = [UserResource]
    resource_mapping = [
        ks_flask.construct_resource_map(
            resource=UserChangePasswordResource,
            url='/users/<string:user_id>/password',
            resource_kwargs={},
            rel='user_change_password',
            path_vars={'user_id': json_home.Parameters.USER_ID}),
        ks_flask.construct_resource_map(
            resource=UserGroupsResource,
            url='/users/<string:user_id>/groups',
            resource_kwargs={},
            rel='user_groups',
            path_vars={'user_id': json_home.Parameters.USER_ID}),
        ks_flask.construct_resource_map(
            resource=UserProjectsResource,
            url='/users/<string:user_id>/projects',
            resource_kwargs={},
            rel='user_projects',
            path_vars={'user_id': json_home.Parameters.USER_ID}),
        ks_flask.construct_resource_map(
            resource=UserOSEC2CredentialsResourceListCreate,
            url='/users/<string:user_id>/credentials/OS-EC2',
            resource_kwargs={},
            rel='user_credentials',
            resource_relation_func=(
                json_home_relations.os_ec2_resource_rel_func),
            path_vars={'user_id': json_home.Parameters.USER_ID}),
        ks_flask.construct_resource_map(
            resource=UserOSEC2CredentialsResourceGetDelete,
            url=('/users/<string:user_id>/credentials/OS-EC2/'
                 '<string:credential_id>'),
            resource_kwargs={},
            rel='user_credential',
            resource_relation_func=(
                json_home_relations.os_ec2_resource_rel_func),
            path_vars={
                'credential_id':
                json_home.build_v3_parameter_relation('credential_id'),
                'user_id':
                json_home.Parameters.USER_ID
            }),
        ks_flask.construct_resource_map(
            resource=OAuth1ListAccessTokensResource,
            url='/users/<string:user_id>/OS-OAUTH1/access_tokens',
            resource_kwargs={},
            rel='user_access_tokens',
            resource_relation_func=(
                json_home_relations.os_oauth1_resource_rel_func),
            path_vars={'user_id': json_home.Parameters.USER_ID}),
        ks_flask.construct_resource_map(
            resource=OAuth1AccessTokenCRUDResource,
            url=('/users/<string:user_id>/OS-OAUTH1/'
                 'access_tokens/<string:access_token_id>'),
            resource_kwargs={},
            rel='user_access_token',
            resource_relation_func=(
                json_home_relations.os_oauth1_resource_rel_func),
            path_vars={
                'access_token_id': ACCESS_TOKEN_ID_PARAMETER_RELATION,
                'user_id': json_home.Parameters.USER_ID
            }),
        ks_flask.construct_resource_map(
            resource=OAuth1AccessTokenRoleListResource,
            url=('/users/<string:user_id>/OS-OAUTH1/access_tokens/'
                 '<string:access_token_id>/roles'),
            resource_kwargs={},
            rel='user_access_token_roles',
            resource_relation_func=(
                json_home_relations.os_oauth1_resource_rel_func),
            path_vars={
                'access_token_id': ACCESS_TOKEN_ID_PARAMETER_RELATION,
                'user_id': json_home.Parameters.USER_ID
            }),
        ks_flask.construct_resource_map(
            resource=OAuth1AccessTokenRoleResource,
            url=('/users/<string:user_id>/OS-OAUTH1/access_tokens/'
                 '<string:access_token_id>/roles/<string:role_id>'),
            resource_kwargs={},
            rel='user_access_token_role',
            resource_relation_func=(
                json_home_relations.os_oauth1_resource_rel_func),
            path_vars={
                'access_token_id': ACCESS_TOKEN_ID_PARAMETER_RELATION,
                'role_id': json_home.Parameters.ROLE_ID,
                'user_id': json_home.Parameters.USER_ID
            }),
        ks_flask.construct_resource_map(
            resource=UserAppCredListCreateResource,
            url='/users/<string:user_id>/application_credentials',
            resource_kwargs={},
            rel='application_credentials',
            path_vars={'user_id': json_home.Parameters.USER_ID}),
        ks_flask.construct_resource_map(
            resource=UserAppCredGetDeleteResource,
            url=('/users/<string:user_id>/application_credentials/'
                 '<string:application_credential_id>'),
            resource_kwargs={},
            rel='application_credential',
            path_vars={
                'user_id':
                json_home.Parameters.USER_ID,
                'application_credential_id':
                json_home.Parameters.APPLICATION_CRED_ID
            })
    ]
Beispiel #13
0
    def append_v3_routers(self, mapper, routers):
        routers.append(
            router.Router(controllers.DomainV3(),
                          'domains', 'domain',
                          resource_descriptions=self.v3_resources))

        config_controller = controllers.DomainConfigV3()
        tag_controller = controllers.ProjectTagV3()

        self._add_resource(
            mapper, config_controller,
            path='/domains/{domain_id}/config',
            get_head_action='get_domain_config',
            put_action='create_domain_config',
            patch_action='update_domain_config_only',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config'),
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID
            })

        config_group_param = (
            json_home.build_v3_parameter_relation('config_group'))
        self._add_resource(
            mapper, config_controller,
            path='/domains/{domain_id}/config/{group}',
            get_head_action='get_domain_config_wrapper',
            patch_action='update_domain_config_group',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_group'),
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param
            })

        self._add_resource(
            mapper, config_controller,
            path='/domains/{domain_id}/config/{group}/{option}',
            get_head_action='get_domain_config_wrapper',
            patch_action='update_domain_config',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_option'),
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param,
                'option': json_home.build_v3_parameter_relation(
                    'config_option')
            })

        self._add_resource(
            mapper, config_controller,
            path='/domains/config/default',
            get_head_action='get_domain_config_default',
            rel=json_home.build_v3_resource_relation('domain_config_default'))

        self._add_resource(
            mapper, config_controller,
            path='/domains/config/{group}/default',
            get_head_action='get_domain_config_default',
            rel=json_home.build_v3_resource_relation(
                'domain_config_default_group'),
            path_vars={
                'group': config_group_param
            })

        self._add_resource(
            mapper, config_controller,
            path='/domains/config/{group}/{option}/default',
            get_head_action='get_domain_config_default',
            rel=json_home.build_v3_resource_relation(
                'domain_config_default_option'),
            path_vars={
                'group': config_group_param,
                'option': json_home.build_v3_parameter_relation(
                    'config_option')
            })

        routers.append(
            router.Router(controllers.ProjectV3(),
                          'projects', 'project',
                          resource_descriptions=self.v3_resources))

        self._add_resource(
            mapper, tag_controller,
            path='/projects/{project_id}/tags',
            get_head_action='list_project_tags',
            put_action='update_project_tags',
            delete_action='delete_project_tags',
            rel=json_home.build_v3_resource_relation(
                'project_tags'),
            path_vars={
                'project_id': json_home.Parameters.PROJECT_ID
            })

        self._add_resource(
            mapper, tag_controller,
            path='/projects/{project_id}/tags/{value}',
            get_head_action='get_project_tag',
            put_action='create_project_tag',
            delete_action='delete_project_tag',
            rel=json_home.build_v3_resource_relation(
                'project_tags'),
            path_vars={
                'project_id': json_home.Parameters.PROJECT_ID,
                'value': json_home.Parameters.TAG_VALUE
            })
Beispiel #14
0
BASE_EP_POLICY = "/policies/{policy_id}/OS-ENDPOINT-POLICY"
BASE_EP_FILTER_PREFIX = "/OS-EP-FILTER"
BASE_EP_FILTER = BASE_EP_FILTER_PREFIX + "/endpoint_groups/{endpoint_group_id}"
BASE_ACCESS_TOKEN = "/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}"

# TODO(stevemar): Use BASE_IDP_PROTOCOL when bug 1420125 is resolved.
FEDERATED_AUTH_URL = "/OS-FEDERATION/identity_providers/{identity_provider}" "/protocols/{protocol}/auth"

V3_JSON_HOME_RESOURCES_INHERIT_DISABLED = {
    json_home.build_v3_resource_relation("auth_tokens"): {"href": "/auth/tokens"},
    json_home.build_v3_resource_relation("auth_catalog"): {"href": "/auth/catalog"},
    json_home.build_v3_resource_relation("auth_projects"): {"href": "/auth/projects"},
    json_home.build_v3_resource_relation("auth_domains"): {"href": "/auth/domains"},
    json_home.build_v3_resource_relation("credential"): {
        "href-template": "/credentials/{credential_id}",
        "href-vars": {"credential_id": json_home.build_v3_parameter_relation("credential_id")},
    },
    json_home.build_v3_resource_relation("credentials"): {"href": "/credentials"},
    json_home.build_v3_resource_relation("domain"): {
        "href-template": "/domains/{domain_id}",
        "href-vars": {"domain_id": json_home.Parameters.DOMAIN_ID},
    },
    json_home.build_v3_resource_relation("domain_group_role"): {
        "href-template": "/domains/{domain_id}/groups/{group_id}/roles/{role_id}",
        "href-vars": {
            "domain_id": json_home.Parameters.DOMAIN_ID,
            "group_id": json_home.Parameters.GROUP_ID,
            "role_id": json_home.Parameters.ROLE_ID,
        },
    },
    json_home.build_v3_resource_relation("domain_group_roles"): {
Beispiel #15
0
    'OS-TRUST', '1.0', 'trust_id')

V3_JSON_HOME_RESOURCES_INHERIT_DISABLED = {
    json_home.build_v3_resource_relation('auth_tokens'): {
        'href': '/auth/tokens'},
    json_home.build_v3_resource_relation('auth_catalog'): {
        'href': '/auth/catalog'},
    json_home.build_v3_resource_relation('auth_projects'): {
        'href': '/auth/projects'},
    json_home.build_v3_resource_relation('auth_domains'): {
        'href': '/auth/domains'},
    json_home.build_v3_resource_relation('credential'): {
        'href-template': '/credentials/{credential_id}',
        'href-vars': {
            'credential_id':
            json_home.build_v3_parameter_relation('credential_id')}},
    json_home.build_v3_resource_relation('credentials'): {
        'href': '/credentials'},
    json_home.build_v3_resource_relation('domain'): {
        'href-template': '/domains/{domain_id}',
        'href-vars': {'domain_id': json_home.Parameters.DOMAIN_ID, }},
    json_home.build_v3_resource_relation('domain_group_role'): {
        'href-template':
        '/domains/{domain_id}/groups/{group_id}/roles/{role_id}',
        'href-vars': {
            'domain_id': json_home.Parameters.DOMAIN_ID,
            'group_id': json_home.Parameters.GROUP_ID,
            'role_id': json_home.Parameters.ROLE_ID, }},
    json_home.build_v3_resource_relation('domain_group_roles'): {
        'href-template': '/domains/{domain_id}/groups/{group_id}/roles',
        'href-vars': {
Beispiel #16
0
BASE_EP_POLICY = '/policies/{policy_id}/OS-ENDPOINT-POLICY'
BASE_EP_FILTER_PREFIX = '/OS-EP-FILTER'
BASE_EP_FILTER = BASE_EP_FILTER_PREFIX + '/endpoint_groups/{endpoint_group_id}'
BASE_ACCESS_TOKEN = (
    '/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}')

FEDERATED_AUTH_URL = ('/OS-FEDERATION/identity_providers/{idp_id}'
                      '/protocols/{protocol_id}/auth')
FEDERATED_IDP_SPECIFIC_WEBSSO = ('/auth/OS-FEDERATION/identity_providers/'
                                 '{idp_id}/protocols/{protocol_id}/websso')

APPLICATION_CREDENTIAL = ('/users/{user_id}/application_credentials/'
                          '{application_credential_id}')
APPLICATION_CREDENTIALS = '/users/{user_id}/application_credentials'
APPLICATION_CREDENTIAL_RELATION = (
    json_home.build_v3_parameter_relation('application_credential_id'))

ACCESS_RULE = '/users/{user_id}/access_rules/{access_rule_id}'
ACCESS_RULES = '/users/{user_id}/access_rules'
ACCESS_RULE_RELATION = json_home.build_v3_parameter_relation('access_rule_id')

V3_JSON_HOME_RESOURCES = {
    json_home.build_v3_resource_relation('auth_tokens'): {
        'href': '/auth/tokens'
    },
    json_home.build_v3_resource_relation('auth_catalog'): {
        'href': '/auth/catalog'
    },
    json_home.build_v3_resource_relation('auth_projects'): {
        'href': '/auth/projects'
    },
Beispiel #17
0
BASE_IDP_PROTOCOL = '/OS-FEDERATION/identity_providers/{idp_id}/protocols'
BASE_EP_POLICY = '/policies/{policy_id}/OS-ENDPOINT-POLICY'
BASE_EP_FILTER_PREFIX = '/OS-EP-FILTER'
BASE_EP_FILTER = BASE_EP_FILTER_PREFIX + '/endpoint_groups/{endpoint_group_id}'
BASE_ACCESS_TOKEN = (
    '/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}')

FEDERATED_AUTH_URL = ('/OS-FEDERATION/identity_providers/{idp_id}'
                      '/protocols/{protocol_id}/auth')
FEDERATED_IDP_SPECIFIC_WEBSSO = ('/auth/OS-FEDERATION/identity_providers/'
                                 '{idp_id}/protocols/{protocol_id}/websso')

APPLICATION_CREDENTIAL = ('/users/{user_id}/application_credentials/'
                          '{application_credential_id}')
APPLICATION_CREDENTIAL_RELATION = (
    json_home.build_v3_parameter_relation('application_credential_id'))

V3_JSON_HOME_RESOURCES = {
    json_home.build_v3_resource_relation('auth_tokens'): {
        'href': '/auth/tokens'},
    json_home.build_v3_resource_relation('auth_catalog'): {
        'href': '/auth/catalog'},
    json_home.build_v3_resource_relation('auth_projects'): {
        'href': '/auth/projects'},
    json_home.build_v3_resource_relation('auth_domains'): {
        'href': '/auth/domains'},
    json_home.build_v3_resource_relation('auth_system'): {
        'href': '/auth/system'},
    json_home.build_v3_resource_relation('credential'): {
        'href-template': '/credentials/{credential_id}',
        'href-vars': {
Beispiel #18
0
                                 '{idp_id}/protocols/{protocol_id}/websso')

V3_JSON_HOME_RESOURCES = {
    json_home.build_v3_resource_relation('auth_tokens'): {
        'href': '/auth/tokens'},
    json_home.build_v3_resource_relation('auth_catalog'): {
        'href': '/auth/catalog'},
    json_home.build_v3_resource_relation('auth_projects'): {
        'href': '/auth/projects'},
    json_home.build_v3_resource_relation('auth_domains'): {
        'href': '/auth/domains'},
    json_home.build_v3_resource_relation('credential'): {
        'href-template': '/credentials/{credential_id}',
        'href-vars': {
            'credential_id':
            json_home.build_v3_parameter_relation('credential_id')}},
    json_home.build_v3_resource_relation('credentials'): {
        'href': '/credentials'},
    json_home.build_v3_resource_relation('domain'): {
        'href-template': '/domains/{domain_id}',
        'href-vars': {'domain_id': json_home.Parameters.DOMAIN_ID, }},
    json_home.build_v3_resource_relation('domain_group_role'): {
        'href-template':
        '/domains/{domain_id}/groups/{group_id}/roles/{role_id}',
        'href-vars': {
            'domain_id': json_home.Parameters.DOMAIN_ID,
            'group_id': json_home.Parameters.GROUP_ID,
            'role_id': json_home.Parameters.ROLE_ID, }},
    json_home.build_v3_resource_relation('domain_group_roles'): {
        'href-template': '/domains/{domain_id}/groups/{group_id}/roles',
        'href-vars': {
Beispiel #19
0
    def append_v3_routers(self, mapper, routers):
        routers.append(
            router.Router(controllers.DomainV3(),
                          'domains',
                          'domain',
                          resource_descriptions=self.v3_resources))

        config_controller = controllers.DomainConfigV3()
        tag_controller = controllers.ProjectTagV3()

        self._add_resource(
            mapper,
            config_controller,
            path='/domains/{domain_id}/config',
            get_head_action='get_domain_config',
            put_action='create_domain_config',
            patch_action='update_domain_config_only',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config'),
            path_vars={'domain_id': json_home.Parameters.DOMAIN_ID})

        config_group_param = (
            json_home.build_v3_parameter_relation('config_group'))
        self._add_resource(
            mapper,
            config_controller,
            path='/domains/{domain_id}/config/{group}',
            get_head_action='get_domain_config_wrapper',
            patch_action='update_domain_config_group',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_group'),
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param
            })

        self._add_resource(
            mapper,
            config_controller,
            path='/domains/{domain_id}/config/{group}/{option}',
            get_head_action='get_domain_config_wrapper',
            patch_action='update_domain_config',
            delete_action='delete_domain_config',
            rel=json_home.build_v3_resource_relation('domain_config_option'),
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': config_group_param,
                'option':
                json_home.build_v3_parameter_relation('config_option')
            })

        self._add_resource(
            mapper,
            config_controller,
            path='/domains/config/default',
            get_head_action='get_domain_config_default',
            rel=json_home.build_v3_resource_relation('domain_config_default'))

        self._add_resource(mapper,
                           config_controller,
                           path='/domains/config/{group}/default',
                           get_head_action='get_domain_config_default',
                           rel=json_home.build_v3_resource_relation(
                               'domain_config_default_group'),
                           path_vars={'group': config_group_param})

        self._add_resource(
            mapper,
            config_controller,
            path='/domains/config/{group}/{option}/default',
            get_head_action='get_domain_config_default',
            rel=json_home.build_v3_resource_relation(
                'domain_config_default_option'),
            path_vars={
                'group': config_group_param,
                'option':
                json_home.build_v3_parameter_relation('config_option')
            })

        routers.append(
            router.Router(controllers.ProjectV3(),
                          'projects',
                          'project',
                          resource_descriptions=self.v3_resources))

        self._add_resource(
            mapper,
            tag_controller,
            path='/projects/{project_id}/tags',
            get_head_action='list_project_tags',
            put_action='update_project_tags',
            delete_action='delete_project_tags',
            rel=json_home.build_v3_resource_relation('project_tags'),
            path_vars={'project_id': json_home.Parameters.PROJECT_ID})

        self._add_resource(
            mapper,
            tag_controller,
            path='/projects/{project_id}/tags/{value}',
            get_head_action='get_project_tag',
            put_action='create_project_tag',
            delete_action='delete_project_tag',
            rel=json_home.build_v3_resource_relation('project_tags'),
            path_vars={
                'project_id': json_home.Parameters.PROJECT_ID,
                'value': json_home.Parameters.TAG_VALUE
            })
Beispiel #20
0
#      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.
"""WSGI Routers for the Application Credential service."""

from keystone.application_credential import controllers
from keystone.common import json_home
from keystone.common import wsgi

APP_CRED_RESOURCE_RELATION = json_home.build_v3_resource_relation(
    'application_credential')
APP_CRED_PARAMETER_RELATION = json_home.build_v3_parameter_relation(
    'application_credential_id')
APP_CRED_COLLECTION_PATH = '/users/{user_id}/application_credentials'
APP_CRED_RESOURCE_PATH = (
    '/users/{user_id}/application_credentials/{application_credential_id}')


class Routers(wsgi.RoutersBase):
    _path_prefixes = (
        APP_CRED_COLLECTION_PATH,
        'users',
    )

    def append_v3_routers(self, mapper, routers):
        app_cred_controller = controllers.ApplicationCredentialV3()

        self._add_resource(mapper,
Beispiel #21
0
class DomainAPI(ks_flask.APIBase):
    CONFIG_GROUP = json_home.build_v3_parameter_relation('config_group')
    CONFIG_OPTION = json_home.build_v3_parameter_relation('config_option')
    _name = 'domains'
    _import_name = __name__
    resources = [DomainResource]
    resource_mapping = [
        ks_flask.construct_resource_map(
            resource=DomainConfigResource,
            url=('/domains/<string:domain_id>/config'),
            resource_kwargs={},
            rel='domain_config',
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID}),
        ks_flask.construct_resource_map(
            resource=DomainConfigGroupResource,
            url='/domains/<string:domain_id>/config/<string:group>',
            resource_kwargs={},
            rel='domain_config_group',
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': CONFIG_GROUP}),
        ks_flask.construct_resource_map(
            resource=DomainConfigOptionResource,
            url=('/domains/<string:domain_id>/config/<string:group>'
                 '/<string:option>'),
            resource_kwargs={},
            rel='domain_config_option',
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group': CONFIG_GROUP,
                'option': CONFIG_OPTION}),
        ks_flask.construct_resource_map(
            resource=DefaultConfigResource,
            url=('/domains/config/default'),
            resource_kwargs={},
            rel='domain_config_default',
            path_vars={}),
        ks_flask.construct_resource_map(
            resource=DefaultConfigGroupResource,
            url='/domains/config/<string:group>/default',
            resource_kwargs={},
            rel='domain_config_default_group',
            path_vars={
                'group': CONFIG_GROUP}),
        ks_flask.construct_resource_map(
            resource=DefaultConfigOptionResource,
            url=('/domains/config/<string:group>'
                 '/<string:option>/default'),
            resource_kwargs={},
            rel='domain_config_default_option',
            path_vars={
                'group': CONFIG_GROUP,
                'option': CONFIG_OPTION}),
        ks_flask.construct_resource_map(
            resource=DomainUserListResource,
            url=('/domains/<string:domain_id>/users'
                 '/<string:user_id>/roles'),
            resource_kwargs={},
            rel='domain_user_roles',
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'user_id': json_home.Parameters.USER_ID,
            }),
        ks_flask.construct_resource_map(
            resource=DomainUserResource,
            url=('/domains/<string:domain_id>/users'
                 '/<string:user_id>/roles/<string:role_id>'),
            resource_kwargs={},
            rel='domain_user_role',
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'user_id': json_home.Parameters.USER_ID,
                'role_id': json_home.Parameters.ROLE_ID
            }),
        ks_flask.construct_resource_map(
            resource=DomainGroupListResource,
            url=('/domains/<string:domain_id>/groups'
                 '/<string:group_id>/roles'),
            resource_kwargs={},
            rel='domain_group_roles',
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group_id': json_home.Parameters.GROUP_ID,
            }),
        ks_flask.construct_resource_map(
            resource=DomainGroupResource,
            url=('/domains/<string:domain_id>/groups'
                 '/<string:group_id>/roles/<string:role_id>'),
            resource_kwargs={},
            rel='domain_group_role',
            path_vars={
                'domain_id': json_home.Parameters.DOMAIN_ID,
                'group_id': json_home.Parameters.GROUP_ID,
                'role_id': json_home.Parameters.ROLE_ID
            })
    ]
Beispiel #22
0
#      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.
"""WSGI Routers for the Application Credential service."""

from keystone.application_credential import controllers
from keystone.common import json_home
from keystone.common import wsgi

APP_CRED_RESOURCE_RELATION = json_home.build_v3_resource_relation(
    'application_credential')
APP_CRED_PARAMETER_RELATION = json_home.build_v3_parameter_relation(
    'application_credential_id')
APP_CRED_COLLECTION_PATH = '/users/{user_id}/application_credentials'
APP_CRED_RESOURCE_PATH = (
    '/users/{user_id}/application_credentials/{application_credential_id}'
)


class Routers(wsgi.RoutersBase):
    _path_prefixes = (APP_CRED_COLLECTION_PATH, 'users',)

    def append_v3_routers(self, mapper, routers):
        app_cred_controller = controllers.ApplicationCredentialV3()

        self._add_resource(
            mapper, app_cred_controller,
            path=APP_CRED_COLLECTION_PATH,
BASE_IDP_PROTOCOL = '/OS-FEDERATION/identity_providers/{idp_id}/protocols'
BASE_EP_POLICY = '/policies/{policy_id}/OS-ENDPOINT-POLICY'
BASE_EP_FILTER_PREFIX = '/OS-EP-FILTER'
BASE_EP_FILTER = BASE_EP_FILTER_PREFIX + '/endpoint_groups/{endpoint_group_id}'
BASE_ACCESS_TOKEN = (
    '/users/{user_id}/OS-OAUTH1/access_tokens/{access_token_id}')

FEDERATED_AUTH_URL = ('/OS-FEDERATION/identity_providers/{idp_id}'
                      '/protocols/{protocol_id}/auth')
FEDERATED_IDP_SPECIFIC_WEBSSO = ('/auth/OS-FEDERATION/identity_providers/'
                                 '{idp_id}/protocols/{protocol_id}/websso')

APPLICATION_CREDENTIAL = ('/users/{user_id}/application_credentials/'
                          '{application_credential_id}')
APPLICATION_CREDENTIAL_RELATION = (
    json_home.build_v3_parameter_relation('application_credential_id'))

V3_JSON_HOME_RESOURCES = {
    json_home.build_v3_resource_relation('auth_tokens'): {
        'href': '/auth/tokens'},
    json_home.build_v3_resource_relation('auth_catalog'): {
        'href': '/auth/catalog'},
    json_home.build_v3_resource_relation('auth_projects'): {
        'href': '/auth/projects'},
    json_home.build_v3_resource_relation('auth_domains'): {
        'href': '/auth/domains'},
    json_home.build_v3_resource_relation('auth_system'): {
        'href': '/auth/system'},
    json_home.build_v3_resource_relation('credential'): {
        'href-template': '/credentials/{credential_id}',
        'href-vars': {
Beispiel #24
0
                                 '{idp_id}/protocols/{protocol_id}/websso')

V3_JSON_HOME_RESOURCES = {
    json_home.build_v3_resource_relation('auth_tokens'): {
        'href': '/auth/tokens'},
    json_home.build_v3_resource_relation('auth_catalog'): {
        'href': '/auth/catalog'},
    json_home.build_v3_resource_relation('auth_projects'): {
        'href': '/auth/projects'},
    json_home.build_v3_resource_relation('auth_domains'): {
        'href': '/auth/domains'},
    json_home.build_v3_resource_relation('credential'): {
        'href-template': '/credentials/{credential_id}',
        'href-vars': {
            'credential_id':
            json_home.build_v3_parameter_relation('credential_id')}},
    json_home.build_v3_resource_relation('credentials'): {
        'href': '/credentials'},
    json_home.build_v3_resource_relation('domain'): {
        'href-template': '/domains/{domain_id}',
        'href-vars': {'domain_id': json_home.Parameters.DOMAIN_ID, }},
    json_home.build_v3_resource_relation('domain_group_role'): {
        'href-template':
        '/domains/{domain_id}/groups/{group_id}/roles/{role_id}',
        'href-vars': {
            'domain_id': json_home.Parameters.DOMAIN_ID,
            'group_id': json_home.Parameters.GROUP_ID,
            'role_id': json_home.Parameters.ROLE_ID, }},
    json_home.build_v3_resource_relation('domain_group_roles'): {
        'href-template': '/domains/{domain_id}/groups/{group_id}/roles',
        'href-vars': {
Beispiel #25
0
    def _add_resources(self):
        # Add resources that are standardized. Each resource implements a
        # base set of handling for a collection of entities such as
        # `users`. Resources are sourced from self.resources. Each resource
        # should have an attribute/property containing the `collection_key`
        # which is typically the "plural" form of the entity, e.g. `users` and
        # `member_key` which is typically the "singular" of the entity, e.g.
        # `user`. Resources are sourced from self.resources, each element is
        # simply a :class:`flask_restful.Resource`.
        for r in self.resources:
            c_key = getattr(r, 'collection_key', None)
            m_key = getattr(r, 'member_key', None)
            if not c_key or not m_key:
                LOG.debug(
                    'Unable to add resource %(resource)s to API '
                    '%(name)s, both `member_key` and `collection_key` '
                    'must be implemented. [collection_key(%(col_key)s) '
                    'member_key(%(m_key)s)]', {
                        'resource': r.__class__.view_class.__name__,
                        'name': self._name,
                        'col_key': c_key,
                        'm_key': m_key
                    })
                continue

            collection_path = '/%s' % c_key
            entity_path = '/%(collection_key)s/<string:%(member_key)s_id>' % {
                'collection_key': c_key,
                'member_key': m_key
            }
            # NOTE(morgan): The json-home form of the entity path is different
            # from the flask-url routing form.
            jh_e_path = _URL_SUBST.sub('{\\1}', entity_path)

            LOG.debug(
                'Adding standard routes to API %(name)s for `%(resource)s` '
                '[%(collection_path)s, %(entity_path)s]', {
                    'name': self._name,
                    'resource': r.__class__.__name__,
                    'collection_path': collection_path,
                    'entity_path': entity_path
                })
            self.api.add_resource(r, collection_path, entity_path)

            # Add JSON Home data
            collection_rel = json_home.build_v3_resource_relation(c_key)
            rel_data = {'href': collection_path}

            entity_rel = json_home.build_v3_resource_relation(m_key)
            id_str = '%s_id' % m_key
            id_param_rel = json_home.build_v3_parameter_relation(id_str)
            entity_rel_data = {
                'href-template': jh_e_path,
                'href-vars': {
                    id_str: id_param_rel
                }
            }

            json_home.JsonHomeResources.append_resource(
                collection_rel, rel_data)
            json_home.JsonHomeResources.append_resource(
                entity_rel, entity_rel_data)