def fame_manage(request):
    """HTTP Google cloud function. Adds/Removes/Lists repos."""
    try:
        data = request.get_json()
        error_if_false(data, 'No payload')

        print('i %s' % str(data))

        command = data.get('command', None)
        error_if_false(Manage.is_valid(command),
                       'Invalid command %s' % command)

        user = data.get('user', None)
        error_if_false(user, 'User is required')

        configure_storage()
        topic = get_fame_pubsub_topic()  # Let it fail early.

        if command in [Manage.ADD, Manage.REMOVE]:
            owner = data.get('owner', None)
            error_if_false(owner, 'Repo owner is required')

            repo = data.get('repo', None)
            error_if_false(repo, 'Repo is required')

        tracker = RepoTracker()
        result = {'status': 'ok'}

        if command == Manage.ADD:
            tracker.configure(user, owner, repo)
            tracker.add()
            client = pubsub.PublisherClient()
            client.publish(topic, b'', command=Refresh.REFRESH,
                           user=user, owner=owner, repo=repo)
        elif command == Manage.REMOVE:
            tracker.configure(user, owner, repo)
            tracker.remove()
        elif command == Manage.LIST:
            directory = []
            for item in RepoTracker.list(user):
                modified = item.last_modified.strftime('%Y-%m-%dT%H:%M:%SZ')
                directory.append({
                    'user': item.user,
                    'owner': item.owner,
                    'repo': item.repo,
                    'status': item.status,
                    'last_modified': modified,
                    'message': item.error_message})
            result['data'] = directory

        return flask.jsonify(result)

    except Exception as e:
        print('e %s' % str(e))
        return make_error_response(400, str(e))
HTTP Google cloud function. Adds/Removes/Lists repos.
main.py