'Return an iterable of api_models.Resource instances
:param user: Optional ID for user that owns the resource.
:param project: Optional ID for project that owns the resource.
:param source: Optional source filter.
:param start_timestamp: Optional modified timestamp start range.
:param start_timestamp_op: Optional start time operator, like gt, ge.
:param end_timestamp: Optional modified timestamp end range.
:param end_timestamp_op: Optional end time operator, like lt, le.
:param metaquery: Optional dict with metadata to match on.
:param resource: Optional resource filter.
:param limit: Maximum number of results to return.'

def get_resources(self, user=None, project=None, source=None, start_timestamp=None, start_timestamp_op=None, end_timestamp=None, end_timestamp_op=None, metaquery=None, resource=None, limit=None):

    if (limit == 0):
        return
    s_filter = storage.SampleFilter(user=user, project=project, source=source, start_timestamp=start_timestamp, start_timestamp_op=start_timestamp_op, end_timestamp=end_timestamp, end_timestamp_op=end_timestamp_op, metaquery=metaquery, resource=resource)
    session = self._engine_facade.get_session()
    has_timestamp = (start_timestamp or end_timestamp)
    if (self.conf.database.sql_expire_samples_only or has_timestamp):
        res_q = session.query(distinct(models.Resource.resource_id)).join(models.Sample, (models.Sample.resource_id == models.Resource.internal_id))
    else:
        res_q = session.query(distinct(models.Resource.resource_id))
    res_q = make_query_from_filter(session, res_q, s_filter, require_meter=False)
    res_q = (res_q.limit(limit) if limit else res_q)
    for res_id in res_q.all():
        min_max_q = session.query(func.max(models.Sample.timestamp).label('max_timestamp'), func.min(models.Sample.timestamp).label('min_timestamp')).join(models.Resource, (models.Resource.internal_id == models.Sample.resource_id)).filter((models.Resource.resource_id == res_id[0]))
        min_max_q = make_query_from_filter(session, min_max_q, s_filter, require_meter=False)
        min_max = min_max_q.first()
        res_q = session.query(models.Resource.resource_id, models.Resource.user_id, models.Resource.project_id, models.Resource.source_id, models.Resource.resource_metadata).join(models.Sample, (models.Sample.resource_id == models.Resource.internal_id)).filter((models.Sample.timestamp == min_max.max_timestamp)).filter((models.Resource.resource_id == res_id[0])).order_by(models.Sample.id.desc()).limit(1)
        res = res_q.first()
        (yield api_models.Resource(resource_id=res.resource_id, project_id=res.project_id, first_sample_timestamp=min_max.min_timestamp, last_sample_timestamp=min_max.max_timestamp, source=res.source_id, user_id=res.user_id, metadata=res.resource_metadata))
