def list_active_computers(): """ Query the inventory client for active records with a given projection. :return: List of inventory objects. """ projection = get_projection_from_qsa() page_info = get_paging_info_from_qsa() if not projection: projection = {'mercury_id': 1} data = inventory_client.query( { 'active': { '$ne': None } }, projection=projection, limit=page_info['limit'], sort=page_info['sort'], sort_direction=page_info['sort_direction'], offset_id=page_info['offset_id'] ) return jsonify(data)
def list_inventory(): """ Query the inventory client for device records with a given projection or get one by mercury_id. :return: List of inventory objects. """ projection = get_projection_from_qsa() paging_info = get_paging_info_from_qsa() data = inventory_client.query({}, projection=projection, limit=paging_info['limit'], sort=paging_info['sort'], sort_direction=paging_info['sort_direction'], offset_id=paging_info['offset_id']) return jsonify(data)
def query_inventory_devices(): """ Query inventory devices with a given projection. :return: List of inventory objects. """ query = request.json.get('query') projection = get_projection_from_qsa() page_info = get_paging_info_from_qsa() log.debug('QUERY: {}'.format(query)) data = inventory_client.query(query, projection=projection, limit=page_info['limit'], sort=page_info['sort'], sort_direction=page_info['sort_direction'], offset_id=page_info['offset_id']) return jsonify(data)
def query_active_computers(): """ Query the active inventory with a given projection. :return: List of inventory objects. """ query = request.json.get('query') # Make sure we get only active devices query.update({'active': {'$ne': None}}) projection = get_projection_from_qsa() page_info = get_paging_info_from_qsa() data = inventory_client.query(query, projection=projection, limit=page_info['limit'], sort=page_info['sort'], sort_direction=page_info['sort_direction'], offset_id=page_info['offset_id']) return jsonify(data)