Ejemplo n.º 1
0
def get_top_story(event, context):
    """retrieve the top story from HackerNews
    https://github.com/HackerNews/API
    """
    LOGGER.debug('get_top_story - ENTRY')
    top_stories = requests.get(
        'https://hacker-news.firebaseio.com/v0/topstories.json')
    assert top_stories.status_code == 200, 'Failed to get top stories [{}]'.format(
        top_stories.status_code)
    top_story_id = top_stories.json()[0]
    LOGGER.info('get_top_story - top_story_id={}'.format(top_story_id))
    top_story = requests.get(
        'https://hacker-news.firebaseio.com/v0/item/{}.json'.format(
            top_story_id))
    assert top_story.status_code == 200, 'Failed to get the top story [{}]'.format(
        top_stories.status_code)
    story = top_story.json()
    LOGGER.debug('get_top_story - EXIT')
    return {
        'statusCode':
        200,
        'body':
        '"{}" by {} on {}'.format(story.get('title'), story.get('by'),
                                  story.get('url')),
        'headers': {
            'content-type': 'text/plain'
        }
    }
Ejemplo n.º 2
0
def notify_reviewer(event, context):
    """notify reviewer function"""
    LOGGER.info('Notify reviewer')
    LOGGER.info(event.get('body'))
    return {'statusCode': 200}
Ejemplo n.º 3
0
def delete_document(event, context):
    """delete document function"""
    LOGGER.info('Delete document')
    LOGGER.info(event.get('body'))
    return {'statusCode': 200}
Ejemplo n.º 4
0
def archive_document(event, context):
    """archive original document function"""
    LOGGER.info('Archive original document')
    LOGGER.info(event.get('body'))
    return {'statusCode': 200}
Ejemplo n.º 5
0
def summarize_document(event, context):
    """summarize document function"""
    LOGGER.info('Summarize document')
    LOGGER.info(event.get('body'))
    return {'statusCode': 200}