Filter services by type
        ^^^^^^^^^^^^^^^^^^^^^^^

        It is possible to filter services by their types. Example:

          /api/services/?service_type=DigitalOcean&service_type=OpenStack
175065
def list(self, request, *args, **kwargs):
        
        return super(ServicesViewSet, self).list(request, *args, **kwargs)
675682
def filter(self, resource_manager, **params):
        """"""
        m = self.resolve(resource_manager.resource_type)
        client = local_session(self.session_factory).client(m.service)

        enum_op, path, extra_args = m.enum_spec
        if extra_args:
            params.update(extra_args)

        parent_type, parent_key, annotate_parent = m.parent_spec
        parents = self.manager.get_resource_manager(parent_type)
        parent_ids = [p[parents.resource_type.id] for p in parents.resources()]

        # Bail out with no parent ids...
        existing_param = parent_key in params
        if not existing_param and len(parent_ids) == 0:
            return []

        # Handle a query with parent id
        if existing_param:
            return self._invoke_client_enum(client, enum_op, params, path)

        # Have to query separately for each parent's children.
        results = []
        for parent_id in parent_ids:
            merged_params = self.get_parent_parameters(params, parent_id, parent_key)
            subset = self._invoke_client_enum(
                client, enum_op, merged_params, path, retry=self.manager.retry)
            if annotate_parent:
                for r in subset:
                    r[self.parent_key] = parent_id
            if subset and self.capture_parent_id:
                results.extend([(parent_id, s) for s in subset])
            elif subset:
                results.extend(subset)
        return results
11152
function (query, results) {
        // Filter components out of the results.
        return YArray.filter(results, function (result) {
            return result.raw.resultType === 'component' ? false : result;
        });
    }
1357099
function (type, opts, cb) {
            var ret;
            var ds = this.metadataDataset.from("pg_class")
                .filter({relkind: type}).select("relname")
                .exclude({relname: {like: this.SYSTEM_TABLE_REGEXP}})
                .join("pg_namespace", {oid: identifier("relnamespace")});
            ds = this.__filterSchema(ds, opts);
            var m = this.outputIdentifierFunc;
            if (cb) {
                ret = when(cb(ds));
            } else {
                ret = ds.map(function (r) {
                    return m(r.relname);
                });
            }
            return ret.promise();
        }
315834
function filter(data, query) {
  var results = [];
  var push = true;

  // omit every result that doesn't pass _every_ filter
  data.forEach((val) => {
    var push = true;

    // if we fail a filter condition, then don't push
    // check if we're over the max price
    if (query.maxPrice > 0) {
      if (val.price.value > query.maxPrice) {
        push = false;
      }
    }

    // check if the city is included
    if (query.cities.length > 0) {
      if (!query.cities.includes(val.location.city)) {
        push = false;
      }
    }

    // check if the type is anywhere to be found
    var found = false;
    if (query.types.length > 0) {
      query.types.forEach((type) => {
        if (val.types.includes(type)) found = true;
      });
    } else {
      // assume it's found if there's no `query.types` on the request
      found = true;
    }
    if (!found) {
      push = false;
    }

    // if we found something, then push it to the results array
    if (push) {
      results.push(val);
    }
  });

  return results;
}
711732
function filterWhere(q, filter) {
    if (typeof filter !== 'object' || filter.where === undefined)
      return;

    if (Object.keys(filter.where).length !== 0) {
      check(q, filter.where);
      q.where(filter.where);
    }
  }
890063
def filter(self, datasource_type, datasource_id, column):
        
        # TODO: Cache endpoint by user, datasource and column
        datasource = ConnectorRegistry.get_datasource(
            datasource_type, datasource_id, db.session)
        if not datasource:
            return json_error_response(DATASOURCE_MISSING_ERR)
        security_manager.assert_datasource_permission(datasource)
        payload = json.dumps(
            datasource.values_for_column(
                column,
                config.get('FILTER_SELECT_ROW_LIMIT', 10000),
            ),
            default=utils.json_int_dttm_ser)
        return json_success(payload)
1194218
function filterByMethods(req) {
        if(_config.allowedMethods) {
            return _config.allowedMethods.indexOf(req.method) > -1;
        } else if(_config.blockedMethods){
            return !(_config.blockedMethods.indexOf(req.method) > -1);
        } else {
            return true;
        }
    }
887644
def _common(ret, name, service_name, kwargs):
    '''
    
    '''
    if 'interface' not in kwargs and 'public_url' not in kwargs:
        kwargs['interface'] = name
    service = __salt__['keystoneng.service_get'](name_or_id=service_name)

    if not service:
        ret['comment'] = 'Cannot find service'
        ret['result'] = False
        return (False, ret)

    filters = kwargs.copy()
    filters.pop('enabled', None)
    filters.pop('url', None)
    filters['service_id'] = service.id
    kwargs['service_name_or_id'] = service.id
    endpoints = __salt__['keystoneng.endpoint_search'](filters=filters)

    if len(endpoints) > 1:
        ret['comment'] = "Multiple endpoints match criteria"
        ret['result'] = False
        return ret
    endpoint = endpoints[0] if endpoints else None
    return (True, endpoint)
255814
def search(type)
      resource_class = parse_type(type)
      client_setup
      filter = parse_hash(options['filter'])
      matches = resource_class.find_by(@client, filter)
      if matches.empty? # Search with integers & booleans converted
        filter = parse_hash(options['filter'], true)
        matches = resource_class.find_by(@client, filter) unless filter == options['filter']
      end
      if options['attribute']
        data = select_attributes_from_multiple(options['attribute'], matches)
        output data, -2 # Shift left by 2 so things look right
      else # List names only by default
        names = []
        matches.each { |m| names.push(m['name']) }
        output names
      end
    end
1073441
function(filters) {
      filters = _.clone(filters || {});
      var endpoint = api;

      if (config.parent && !filters[config.parent.key]) {
        throw new Error("fetchAll: must supply the parent.key as a filter to fetch all entities");
      }

      if (config.parent) {
        endpoint.one(config.parent.entity, filters[config.parent.key]);
        // since the filtering is happening in the endpoint url we dont need filters
        delete filters[config.parent.key];
      }

      return endpoint
        .all(config.entity)
        .filter(filters)
        .get()
        .then(function(results) {
          return results.map(this.create);
        // }.bind(this), console.error);
        }.bind(this), function(err) {console.log(err); throw new Error(err);});
    }
301485
def filter_generic(self, content_object=None, **kwargs):
        
        if content_object:
            kwargs['content_type'] = ContentType.objects.get_for_model(
                content_object
            )
            kwargs['object_id'] = content_object.id

        return self.filter(**kwargs)
890987
def list_service_providers(self, retrieve_all=True, **_params):
        """"""
        # Pass filters in "params" argument to do_request
        return self.list('service_providers', self.service_providers_path,
                         retrieve_all, **_params)
375157
private Filter analyze(final IWhere _where, final IOrder _order, final List<Type> _types)
    {
        iWhere = _where;
        iOrder = _order;
        types = _types;
        return this;
    }
44074
function(type) {

	var items = _.filter(process.env, function(value, key) {

		var pattern = new RegExp('CORS\_ALLOWED\_' + type.toUpperCase(), 'i')

		return key.match(pattern);

	});

	return items.join(', ') || '*';

}
939514
function filterTasks (type, tasks, alltasks) {
    var contains = function (task) {
        return _.includes(tasks, task.name);
    };

    if (type === 'include') {
        return _.filter(alltasks, contains);
    } else if (type === 'exclude') {
        return _.reject(alltasks, contains);
    }
    return alltasks;
}
514991
def filters(type=nil)
      unless(type)
        @filters.dup
      else
        const = Splib.find_const(type)
        type = const unless const.nil?
        @filters[type] ? @filters[type].dup : nil
      end
    end