{ "info": { "author": "Openlabs Technologies and Consulting (P) Ltd.", "author_email": "info@openlabs.co.in", "bugtrack_url": null, "classifiers": [ "Development Status :: 4 - Beta", "Environment :: Plugins", "Framework :: Tryton", "Intended Audience :: Developers", "License :: OSI Approved :: GNU General Public License v3 (GPLv3)", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python", "Topic :: Office/Business" ], "description": "Tryton Restful\n==============\n\nA REST API for Tryton Models\n\nInstallation\n------------\n\nInstall from python package index::\n\n pip install tryton-restful\n\nUsage\n-----\n\nOn installation you should be able to use the `tryton_restful` script which\nruns a local development server.\n\n.. code:: shell\n\n tryton_restful --help\n\n Usage: tryton_restful [OPTIONS] HOST PORT\n\n Runs the application on a local development server.\n\n Options:\n -c, --config TEXT Path to tryton configuration file\n --debug\n --threaded / --not-threaded should the process handle each request in a\n separate thread?\n --help Show this message and exit.\n\nYou can run the server by::\n\n tryton_restful -c /path/to/tryton/config\n\n\n.. tip::\n\n You can also specify the config file using environment variables.\n\n export TRYTON-CONFIG=/path/to/tryton/config\n\n\nRest API Endpoints:\n-------------------\n\n//login\n````````````````\n===== ========================================================================\nPOST Expects `login` and `password` as form data and returns a JSON of\n user ID and session to be used for subsequent requests\n===== ========================================================================\n\n.. code:: python\n\n import requests\n import json\n \n DATABASE_NAME = 'rest'\n BASE_PATH = 'http://localhost:9000/' + DATABASE_NAME\n \n login_result = requests.post(BASE_PATH + '/login', data={'login': 'admin', 'password': 'admin'})\n tryton_session = login_result.json()\n print tryton_session\n\n.. parsed-literal::\n\n {u'session': u'966689963c0a4a939cb326c1451b0fe9', u'id': 1}\n\n\n//model/\n````````````````````````````````\n\n======== =====================================================================\nGET Return a list of records (Just the ID and rec_name)\n\n Params:\n\n * domain: JSON serialised domain expression\n example: `[['name', 'ilike', 'openlabs']]`\n * page: Integer number of the page\n * per_page: The number of records to be returned per page\n * order: JSON serialised order expression in which the records\n should be sorted. Ex: `[('name', 'ASC'), ('date', 'DESC')]`\n======== =====================================================================\n\n.. code:: python\n\n s = requests.Session()\n s.auth = (tryton_session['id'], tryton_session['session'])\n \n # Use the session and get the list of users\n print s.get(BASE_PATH + '/model/res.user').json()\n\n.. parsed-literal::\n\n {u'items': [{u'rec_name': u'Administrator', u'id': 1}]}\n\n\n======== =====================================================================\nPOST Creates one or more records in the given model\n======== =====================================================================\n\n.. code:: python\n\n # Create a new user\n headers = {'content-type': 'application/json'}\n values = [\n {'name': 'Thomas', 'login': 'thomas', 'password': 'password'},\n {'name': 'Alfred', 'login': 'alfred', 'password': 'somethingelse'},\n ]\n users = s.post(BASE_PATH + '/model/res.user', data=json.dumps(values), headers=headers).json()\n print users\n\n.. parsed-literal::\n\n {u'items': [{u'rec_name': u'Thomas', u'id': 3}, {u'rec_name': u'Alfred', u'id': 4}]}\n\n\n\n======== =====================================================================\nDELETE Delete **all** records in the given model\n======== =====================================================================\n\n\n//model//\n``````````````````````````````````\n\n======== =====================================================================\nGET Return the details of the given record\n\n Params:\n\n * fields_names: specify the list of fields to be returned.\n Default behavior is to return as much data as possible\n======== =====================================================================\n\n.. code:: python\n\n # Get full details of the first user\n print s.get(BASE_PATH + '/model/res.user/1').json()\n\n.. parsed-literal::\n\n {u'create_date': u'Sat, 10 May 2014 08:51:16 GMT', ....}\n\n\n.. code:: python\n\n # Get only a limited set of fields\n user_url = BASE_PATH + '/model/res.user/1'\n print s.get(user_url + '?fields_names=name&fields_names=email').json()\n\n.. parsed-literal::\n\n {u'email': None, u'name': u'Administrator', u'id': 1}\n\n======== =====================================================================\nPUT Update the given resource\n======== =====================================================================\n\n.. code:: python\n\n # Change the email of the user\n headers = {'content-type': 'application/json'}\n user_data = s.put(user_url, data=json.dumps({'email': 'admin@example.com'}), headers=headers).json()\n print user_data['email']\n\n.. parsed-literal::\n\n admin@example.com\n\n======== =====================================================================\nDELETE Delete the given record\n======== =====================================================================\n\n.. code:: python\n\n # get a new list of all users\n print s.get(BASE_PATH + '/model/res.user').json()\n\n.. parsed-literal::\n\n {u'items': [{u'rec_name': u'Administrator', u'id': 1}, {u'rec_name': u'Thomas', u'id': 3}, {u'rec_name': u'Alfred', u'id': 4}]}\n\n\n.. code:: python\n\n # delete user Alfred with ID 4\n print s.delete(BASE_PATH + '/model/res.user/4')\n\n.. parsed-literal::\n\n \n\n\n.. code:: python\n\n # get a new list of all users\n print s.get(BASE_PATH + '/model/res.user').json()\n\n.. parsed-literal::\n\n {u'items': [{u'rec_name': u'Administrator', u'id': 1}, {u'rec_name': u'Thomas', u'id': 3}]}", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://www.openlabs.co.in/", "keywords": null, "license": "GPL-3", "maintainer": null, "maintainer_email": null, "name": "tryton-restful", "package_url": "https://pypi.org/project/tryton-restful/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/tryton-restful/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://www.openlabs.co.in/" }, "release_url": "https://pypi.org/project/tryton-restful/0.1/", "requires_dist": null, "requires_python": null, "summary": "REST API to access Tryton modules", "version": "0.1" }, "last_serial": 1087883, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "574f5cf924683969aee6c8df74599585", "sha256": "30dae8d6fc282b070b9a4d1c9f7e1c1d7510b6f98c2350cfbe1021dc78ce5325" }, "downloads": -1, "filename": "tryton-restful-0.1.tar.gz", "has_sig": false, "md5_digest": "574f5cf924683969aee6c8df74599585", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6875, "upload_time": "2014-05-10T13:17:12", "url": "https://files.pythonhosted.org/packages/9f/3e/dd488f655489e2b935485f53b16aa491342072ae091bff13935c6ebbde32/tryton-restful-0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "574f5cf924683969aee6c8df74599585", "sha256": "30dae8d6fc282b070b9a4d1c9f7e1c1d7510b6f98c2350cfbe1021dc78ce5325" }, "downloads": -1, "filename": "tryton-restful-0.1.tar.gz", "has_sig": false, "md5_digest": "574f5cf924683969aee6c8df74599585", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6875, "upload_time": "2014-05-10T13:17:12", "url": "https://files.pythonhosted.org/packages/9f/3e/dd488f655489e2b935485f53b16aa491342072ae091bff13935c6ebbde32/tryton-restful-0.1.tar.gz" } ] }