Lists the clients associated with keywords.
500977
def ListClientsForKeywords(self, keywords, start_time=None):
    """"""
    res = {kw: [] for kw in keywords}
    for kw in keywords:
      for client_id, timestamp in iteritems(self.keywords.get(kw, {})):
        if start_time is not None and timestamp < start_time:
          continue
        res[kw].append(client_id)
    return res
1358472
async def ListKeys(self, entities, mode):
        '''
        
        '''
        # map input types to rpc msg
        _params = dict()
        msg = dict(type='KeyManager',
                   request='ListKeys',
                   version=1,
                   params=_params)
        _params['entities'] = entities
        _params['mode'] = mode
        reply = await self.rpc(msg)
        return reply
1027401
def SearchClients(query_str, token=None, limit=1000):
  """"""
  client_schema = aff4.AFF4Object.classes["VFSGRRClient"].SchemaCls
  index = client_index.CreateClientIndex(token=token)

  client_list = index.LookupClients([query_str])
  result_set = aff4.FACTORY.MultiOpen(client_list, token=token)
  results = []
  for result in result_set:
    results.append((result, str(result.Get(client_schema.HOSTNAME)),
                    str(result.Get(client_schema.OS_VERSION)),
                    str(result.Get(client_schema.PING))))
    if len(results) >= limit:
      break

  return results
105935
def AddClientKeywords(self, client_id, keywords, cursor=None):
    """"""
    cid = db_utils.ClientIDToInt(client_id)
    keywords = set(keywords)
    args = [(cid, mysql_utils.Hash(kw), kw) for kw in keywords]
    args = list(collection.Flatten(args))

    query = """
        INSERT INTO client_keywords (client_id, keyword_hash, keyword)
        VALUES {}
        ON DUPLICATE KEY UPDATE timestamp = NOW(6)
            """.format(", ".join(["(%s, %s, %s)"] * len(keywords)))
    try:
      cursor.execute(query, args)
    except MySQLdb.IntegrityError as e:
      raise db.UnknownClientError(client_id, cause=e)
270971
def tick_clients(self):
        """"""
        if not self._ticker:
            self._create_ticker()

        for client in self.clients.values():
            self._ticker.tick(client)
553653
def list_(profile="splunk"):
    '''
    
    '''
    client = _get_splunk(profile)
    searches = [x['name'] for x in client.saved_searches]
    return searches
488804
def list(context, resource, **kwargs):
    """"""
    data = utils.sanitize_kwargs(**kwargs)
    id = data.pop('id', None)
    subresource = data.pop('subresource', None)

    if subresource:
        uri = '%s/%s/%s/%s' % (context.dci_cs_api, resource, id, subresource)
    else:
        uri = '%s/%s' % (context.dci_cs_api, resource)

    return context.session.get(uri, timeout=HTTP_TIMEOUT, params=data)
186522
def list_service(ctx, name):
    """"""
    swag = create_swag_from_ctx(ctx)
    accounts = swag.get_service_enabled(name)

    _table = [[result['name'], result.get('id')] for result in accounts]
    click.echo(
        tabulate(_table, headers=["Account Name", "Account Number"])
    )
781935
def get_clients_per_page(self, per_page=1000, page=1, params=None):
        
        return self._get_resource_per_page(resource=CLIENTS, per_page=per_page, page=page, params=params)
347424
def index():
    """"""
    page = request.values.get('page', 1, type=int)
    size = request.values.get('size', 2, type=int)
    search = ExampleSearch()[(page - 1) * size:page * size]
    if 'q' in request.values:
        search = search.query(QueryString(query=request.values.get('q')))

    search = search.sort(
        request.values.get('sort', 'title')
    )
    search = ExampleSearch.faceted_search(search=search)
    results = search.execute().to_dict()
    return jsonify({'hits': results.get('hits')})
1014210
def keywords(soup):
    
    if not raw_parser.author_keywords(soup):
        return []
    return list(map(node_text, raw_parser.author_keywords(soup)))
393886
def MultiReadClientLabels(self, client_ids):
    """"""
    res = {}
    for client_id in client_ids:
      res[client_id] = []
      owner_dict = self.labels.get(client_id, {})
      for owner, labels in iteritems(owner_dict):
        for l in labels:
          res[client_id].append(rdf_objects.ClientLabel(owner=owner, name=l))
      res[client_id].sort(key=lambda label: (label.owner, label.name))
    return res
1018480
async def list(self, *args, **kwargs):
        '''
        
        '''
        limit = int(kwargs.pop('limit', self.limit))
        limit = 1000 if limit == 0 else limit  # lets not go crazy here
        offset = int(kwargs.pop('offset', self.offset))
        projection = None
        # perform full text search or standard filtering
        if self._meta.fts_operator in kwargs.keys():
            filters = {
                '$text': {'$search': kwargs[self._meta.fts_operator]}
            }
            projection = {'score': {'$meta': 'textScore'}}
            sort = [('score', {'$meta': 'textScore'}, )]
        else:
            # build filters from query parameters
            filters = self.build_filters(**kwargs)
            # add custom query defined in resource meta, if exists
            if isinstance(self._meta.query, dict):
                filters.update(self._meta.query)
            # build sorts from query parameters
            sort = self.build_sort(**kwargs)
            if isinstance(self._meta.sort, list):
                sort.extend(self._meta.sort)
        cursor = self._meta.object_class.get_cursor(db=self.db, query=filters, projection=projection, sort=sort)
        cursor.skip(offset)
        cursor.limit(limit)
        total_count = await self._meta.object_class.count(db=self.db, filters=filters)
        object_list = await self._meta.object_class.find(cursor)
        # serialize results
        serialized_objects = await asyncio.gather(*[obj.serialize() for obj in object_list])
        # signal post list
        asyncio.ensure_future(resource_post_list.send(
            sender=self._meta.object_class,
            db=self.db,
            instances=object_list)
        )
        return {
            'meta': {
                'total_count': total_count,
                'limit': limit,
                'offset': offset
            },
            'objects': serialized_objects
        }
837567
def list_websites(self):
        
        self.connect()
        results = self.server.list_websites(self.session_id)

        return results
243759
def MultiReadClientLabels(self, client_ids, cursor=None):
    """"""

    int_ids = [db_utils.ClientIDToInt(cid) for cid in client_ids]
    query = ("SELECT client_id, owner_username, label "
             "FROM client_labels "
             "WHERE client_id IN ({})").format(", ".join(["%s"] *
                                                         len(client_ids)))

    ret = {client_id: [] for client_id in client_ids}
    cursor.execute(query, int_ids)
    for client_id, owner, label in cursor.fetchall():
      ret[db_utils.IntToClientID(client_id)].append(
          rdf_objects.ClientLabel(name=label, owner=owner))

    for r in itervalues(ret):
      r.sort(key=lambda label: (label.owner, label.name))
    return ret
1211936
def list(self):
        
        parent_url = self.client.get_url(self.parent_object._manager._URL_KEY, 'GET', 'single', {'id': self.parent_object.id})
        target_url = parent_url + self.client.get_url_path(self._URL_KEY, 'GET', 'multi')
        return base.Query(self, target_url)
657268
def clients(self):
        ''''''
        clients_response = self.get_request('clients/')
        return [Client(self, cjson['client']) for cjson in clients_response]