Exemple #1
0
def disable_extension_by_service_plugin(core_plugin, service_plugin):
    if ('filter-validation' in core_plugin.supported_extension_aliases
            and not api_common.is_filter_validation_supported(service_plugin)):
        core_plugin.supported_extension_aliases.remove('filter-validation')
        LOG.info(
            'Disable filter validation extension by service plugin '
            '%s.', service_plugin.__class__.__name__)
Exemple #2
0
 def _is_filter_validation_supported(self):
     return api_common.is_filter_validation_supported(self._plugin)
Exemple #3
0
 def _is_filter_validation_supported(self):
     return api_common.is_filter_validation_supported(self._plugin)
Exemple #4
0
def disable_extension_by_service_plugin(core_plugin, service_plugin):
    if ('filter-validation' in core_plugin.supported_extension_aliases and
            not api_common.is_filter_validation_supported(service_plugin)):
        core_plugin.supported_extension_aliases.remove('filter-validation')
        LOG.info('Disable filter validation extension by service plugin '
                 '%s.', service_plugin.__class__.__name__)
Exemple #5
0
    def __init__(self,
                 collection,
                 resource,
                 plugin=None,
                 resource_info=None,
                 allow_pagination=None,
                 allow_sorting=None,
                 parent_resource=None,
                 member_actions=None,
                 collection_actions=None,
                 item=None,
                 action_status=None):
        # Ensure dashes are always replaced with underscores
        self.collection = collection and collection.replace('-', '_')
        self.resource = resource and resource.replace('-', '_')
        self._member_actions = member_actions or {}
        self._collection_actions = collection_actions or {}
        self._resource_info = resource_info
        self._plugin = plugin
        # Controllers for some resources that are not mapped to anything in
        # RESOURCE_ATTRIBUTE_MAP will not have anything in _resource_info
        if self.resource_info:
            self._mandatory_fields = set([
                field for (field, data) in self.resource_info.items()
                if data.get('required_by_policy')
            ])
            if 'tenant_id' in self._mandatory_fields:
                # ensure that project_id is queried in the database when
                # tenant_id is required
                self._mandatory_fields.add('project_id')
        else:
            self._mandatory_fields = set()
        self.allow_pagination = allow_pagination
        if self.allow_pagination is None:
            self.allow_pagination = True
        self.allow_sorting = allow_sorting
        if self.allow_sorting is None:
            self.allow_sorting = True
        self.native_pagination = api_common.is_native_pagination_supported(
            self.plugin)
        self.native_sorting = api_common.is_native_sorting_supported(
            self.plugin)
        if self.allow_pagination and self.native_pagination:
            if not self.native_sorting:
                raise exceptions.Invalid(
                    _("Native pagination depends on native sorting"))
        self.filter_validation = api_common.is_filter_validation_supported(
            self.plugin)
        self.primary_key = self._get_primary_key()

        self.parent = parent_resource
        parent_resource = '_%s' % parent_resource if parent_resource else ''
        self._parent_id_name = ('%s_id' % self.parent if self.parent else None)
        self._plugin_handlers = {
            self.LIST: 'get%s_%s' % (parent_resource, self.collection),
            self.SHOW: 'get%s_%s' % (parent_resource, self.resource)
        }
        for action in [self.CREATE, self.UPDATE, self.DELETE]:
            self._plugin_handlers[action] = '%s%s_%s' % (
                action, parent_resource, self.resource)
        self.item = item
        self.action_status = action_status or {}