From c68d065981bbb54aa00fdc2f34529c6976a634a3 Mon Sep 17 00:00:00 2001 From: Olivier Demah Date: Sat, 16 Apr 2016 16:05:15 +0200 Subject: [PATCH] API for Wallabag v2 ready --- README.rst | 21 ++------ requirements-dev.txt | 2 - wallabag_api/wallabag.py | 2 + wallabag_mock.py | 106 --------------------------------------- 4 files changed, 5 insertions(+), 126 deletions(-) delete mode 100644 requirements-dev.txt delete mode 100644 wallabag_mock.py diff --git a/README.rst b/README.rst index 14ace7c..eaeeb92 100644 --- a/README.rst +++ b/README.rst @@ -2,7 +2,7 @@ Wallabag API ============ -Python API for Wallabag +Python API for Wallabag v2 Requirements : ============== @@ -20,24 +20,9 @@ to get the project, from your virtualenv, do : Testing : ========= -If you plan to run python wallabag_test.py, then first of all you will need to do -.. code:: python - - pip install Flask +Install Wallabag V2 on your own host like explain here http://doc.wallabag.org/en/v2/user/installation.html -then - -.. code:: python - - python wallabag_mock.py - -to start a Flask environment which will respond to all the request of the test you will start with python wallabag_test.py +Then create a client API like explain here http://doc.wallabag.org/en/v2/developer/api.html -TODO : -====== - -Wait the final release of http://v2.wallabag.org to be able to use the REST API (http://v2.wallabag.org/api/doc/) completly -this final release should be able to provide a token - diff --git a/requirements-dev.txt b/requirements-dev.txt deleted file mode 100644 index 7e64a7d..0000000 --- a/requirements-dev.txt +++ /dev/null @@ -1,2 +0,0 @@ --r requirements.txt -Flask==0.10.1 diff --git a/wallabag_api/wallabag.py b/wallabag_api/wallabag.py index b30a2e8..e431b97 100644 --- a/wallabag_api/wallabag.py +++ b/wallabag_api/wallabag.py @@ -22,6 +22,8 @@ class Wallabag(object): client_secret = '' user_agent = '' format = '' + username = '' + password = '' def __init__(self, host='', diff --git a/wallabag_mock.py b/wallabag_mock.py deleted file mode 100644 index 0b9936f..0000000 --- a/wallabag_mock.py +++ /dev/null @@ -1,106 +0,0 @@ -# -*- coding: utf-8 -*- -__author__ = 'foxmask' -import json -from flask import Flask - -""" - The main purpose of this script is to replace v2.wallabag.org itself - just run : - python wallabag_mock.py & - and then you can launch - python wallabag_test.py - -""" - -app = Flask(__name__) - - -@app.route('/api/entries.json', methods=['GET']) -def get_entries(): - my_data = dict() - my_data['entry'] = 'first content' - my_data['entry'] = 'second content' - return json.dumps(my_data, encoding='utf-8') - - -@app.route('/api/entries.json', methods=['POST']) -def post_entries(): - url = '' - title = '' - tags = [] - return json.dumps(True) - - -@app.route('/api/entries/.json', methods=['GET']) -def get_entry(entry): - my_data = dict() - if entry == 1: - my_data['entry'] = 'third content' - return json.dumps(my_data, encoding='utf-8') - - -@app.route('/api/entries/.json', methods=['PATCH']) -def patch_entries(entry, **params): - entry = 1 - params = {'title': '', - 'archive': 0, - 'tags': [], - 'star': 0, - 'delete': 0} - - if entry == 1 and len(params) > 0: - return json.dumps(True) - else: - return json.dumps(False) - - -@app.route('/api/entries/.json', methods=['DELETE']) -def delete_entries(entry): - if entry == 1: - return json.dumps(True) - else: - return json.dumps(False) - - -@app.route('/api/entries//tags.json', methods=['GET']) -def get_entry_tags(entry): - my_data = dict() - if entry == 1: - my_data = ['tag1', 'tag2', 'tag3'] - return json.dumps(my_data, encoding='utf-8') - - -@app.route('/api/entries//tags.json', methods=['POST']) -def post_entry_tags(entry, **params): - my_data = dict() - if entry == 1: - my_data = ['tag1', 'tag2', 'tag3'] - return json.dumps(my_data, encoding='utf-8') - - -@app.route('/api/entries//tags/.json', methods=['DELETE']) -def delete_entry_tag(entry, tag): - return json.dumps(entry, tag, encoding='utf-8') - - -@app.route('/api/tags.json', methods=['GET']) -def get_tags(): - my_data = ['tag1', 'tag2', 'tag3'] - return json.dumps(my_data, encoding='utf-8') - - -@app.route('/api/tags/.json', methods=['GET']) -def get_tag(tag): - my_data = 'tag1' - return json.dumps(my_data, encoding='utf-8') - - -@app.route('/api/tags/.json', methods=['DELETE']) -def delete_tag(tag): - my_data = 'tag1' - return json.dumps(my_data, encoding='utf-8') - - -if __name__ == '__main__': - app.run(debug=True) -