{ "info": { "author": "vitormazzi", "author_email": "vitormazzi@gmail.com", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Operating System :: OS Independent", "Topic :: Software Development" ], "description": "Python-API-toolkit\n==================\nPython-API-toolkit is a module that focuses on dealing with REST APIs in a simple way. The API will need to follow some simple rules to be supported.\n\n\nDemonstration\n-------------\nFor example, using [Charging](https://github.com/myfreecomm/charging) with Python-API-toolkit.\n\n```python\n >>> from api_toolkit import Resource\n >>> print Resource.url_attribute_name\n 'url'\n >>> Resource.url_attribute_name = 'uri'\n >>> entrypoint = Resource.load(\n ... 'http://sandbox.charging.financeconnect.com.br/domain/',\n ... user='', password='1+OC7QHjQG6H9ITrLQ7CWw=='\n ... )\n >>> entrypoint.resource_data\n {u'address': u'Address',\n u'city_state': u'Niteroi/Rj',\n u'description': None,\n u'etag': u'da39a3ee5e6b4b0d3255bfef95601890afd80709',\n u'supplier_name': u'Gerardo Soares',\n u'token': u'9kpJCaG/Qsui+G3s+0QcKA==',\n u'uri': u'http://sandbox.charging.financeconnect.com.br/account/domains/513e8442-0a4e-404c-b405-8681ca7e58b1/',\n u'uuid': u'513e8442-0a4e-404c-b405-8681ca7e58b1',\n u'zipcode': u'24020040'}\n >>> # You can, then, acess any keys from resource_data as attributes and treat the resource as an object.\n >>> entrypoint.address = u'New Address'\n >>> entrypoint.save()\n >>> list(entrypoint.charge_accounts.all())\n [, ]\n```\n\nAnd every other Resource object operates the same way as the first:\n```python\n >>> for res in entrypoint.charge_accounts.all():\n ... res.delete()\n```\n\nRequirements (for APIs)\n-----------------------\nIf you want to support Python-API-toolkit in your API you'll have to follow three rules:\n\n1. Your API should be RESTful.\n2. You should implement the header Link.\n3. Your API should accept JSON.\n\n\nGithub uses the header Link for its [API's pagination](http://developer.github.com/v3/#pagination). All we need is to extend that a bit. For instance: At [Charging](https://github.com/myfreecomm/charging) the [/domain/](http://sandbox.charging.financeconnect.com.br/domain/) has the following Link header:\n\n Link: ; rel=\"charge_accounts\"\n\n\nAt pages where the pagination is present, like [/charge-accounts/](http://sandbox.charging.financeconnect.com.br/charge-accounts/), the Link header is presented like this:\n\n Link: ; rel=\"banks\",\n ; rel=\"currencies\",\n ; rel=\"next\"\n\n\nRequirements (for Clients)\n--------------------------\nPython-API-toolkit uses ```requests``` instead of the common ```HttpLib2```.\n\n\nInstall\n-------\nYou can install Python-API-toolkit via ``pip`` or ``easy_install``. This project isn't on PyPi yet.\n\n``$ pip install -e git+git@github.com:myfreecomm/python-api-toolkit#egg=python-api-toolkit``\n\n\nDocumentation\n-------------\nPython-API-toolkit uses two classes to expose the API in a friendly way, Resource and Collection.\nThe Resources are the API's objects and entrypoints, they are the entities you'll manipulate.\nThe Collections are just collections of the same Resource.\nPython-API-toolkit defines GET and DELETE HTTP verbs to both, PUT to the Resource and POST to the Collection, right now all verbs will be allowed to each Resource or Collection, even if the API doens't.\nFuturely the verbs will be limited to those the API responds via OPTIONS.\n\n### Resource\nResources are the API's objects and entrypoints.\n\nResources are loaded initially, so you won't neet to GET the resources, most of the time. But you can always ``reload()`` them to Sync them up with the API server.\nFor example:\n```python\n >>> from api_toolkit import Resource\n >>> res = Resource.load('http://example.com/api/user/', user='test', password='pass')\n >>> res.url\n 'http://example.com/api/user/'\n >>> # The resource is loaded initially.\n >>> res.url = 'Nope!'\n >>> res.reload()\n >>> res.url\n 'http://example.com/api/user/'\n >>> # The resource is synced up with the server.\n```\n\nBut what if you want to PUT something at the API server's resource? All you have to do is treat the Resource as an object and call ``save()`` when you're done. Much like Django ORM's Models.\nFor instance:\n```python\n >>> # We're reusing the resource loaded previously.\n >>> res.name = 'Test User'\n >>> res.save()\n >>> # The server accepted our changes.\n >>> res.reload()\n >>> res.name\n 'Test User'\n```\nNote: If you try to change an attribute that can't be changed, the object will accept it just fine, but ``save()`` will raise an exception.\n```python\n >>> res.url = 'http://example.com/submarine/'\n >>> res.save()\n HTTPError: 400 Client Error: Bad Request\n```\n\nAnd if you want to DELETE the resource, all you have to do is call ``delete()``.\n```python\n >>> res.delete()\n >>> res.reload()\n HTTPError: 404 Client Error: Not Found\n```\nNote: The local instance won't be deleted as well. If the API accepts PUT as create all you have to do is call ``save()`` after you deleted the object.\n```python\n >>> res.url\n 'http://example.com/api/user/'\n >>> res.save()\n >>> res.reload()\n```\n\nLoaded resources also have their collections instantiated as attributes. To get the Tasks Collection related to this user, all you have to do is:\n```python\n >>> res.tasks\n \n```\n\n### Collection\nCollections are the Resource managers. At collections you can list all Resources from that type, get a specific Resource from that type, create a new Resource or maybe delete all Resources from that type.\n\nYou can use ``all()`` to get all resources from the same type. For instance:\n```python\n >>> # We're still utilizing the resource we defined earlier.\n >>> res.tasks\n \n >>> list(res.tasks.all())\n [, ]\n >>> # Note that all() returns a generator.\n >>> for resource in res.tasks.all()\n ... print resource.url\n 'http://example.com/api/users/tasks/1/'\n 'http://example.com/api/users/tasks/2/'\n```\n\nTo get a specific resource you can use ``get()``. ``get()`` takes the resource identifier as an argument (In 'http://example.com/api/users/tasks/1/' the identifier is '1'.\n```python\n >>> first_resource = res.tasks.get('1')\n >>> first_resource.url\n 'http://example.com/api/users/tasks/1/'\n```\n\nTo create a new resource all you have to do is provide enough arguments to ``create()``. For example:\n```python\n >>> new_resource = res.tasks.create(\n ... description = 'Test task to be created.',\n ... due_date = '07/10',\n ... name = 'Task#01'\n ... )\n```\n\nAnd now, if we want to delete everything from the collection, we just call ``delete()``. TO BE IMPLEMENTED\n```python\n >>> res.tasks.delete()\n >>> list(res.tasks.all())\n []\n >>> # Everything gone! Let's just save that resource we just created again...\n >>> new_resource.save()\n >>> list(res.tasks.all())\n []\n```", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "http://github.com/myfreecomm/python-api-toolkit", "keywords": "python rest webservices", "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "api_toolkit", "package_url": "https://pypi.org/project/api_toolkit/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/api_toolkit/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/myfreecomm/python-api-toolkit" }, "release_url": "https://pypi.org/project/api_toolkit/0.3.11/", "requires_dist": null, "requires_python": null, "summary": "A library which simplifies the creation of clients for REST webservices.", "version": "0.3.11" }, "last_serial": 1304437, "releases": { "0.1": [ { "comment_text": "", "digests": { "md5": "ad0f57e0da70ba8a0480578d3be923b9", "sha256": "08c6b7172f59e3b8e4b5d0fd7b7fce9bdf3f0d50360919103872ac4a73aec7f7" }, "downloads": -1, "filename": "api_toolkit-0.1.tar.gz", "has_sig": false, "md5_digest": "ad0f57e0da70ba8a0480578d3be923b9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 1806, "upload_time": "2013-12-27T18:45:15", "url": "https://files.pythonhosted.org/packages/d3/7f/d0b366352fed837119e3548dbc59b9d35055547a2a21cca8cb6d627b181f/api_toolkit-0.1.tar.gz" } ], "0.2": [ { "comment_text": "", "digests": { "md5": "17776b8b4f0a4581abeed30de8b7b588", "sha256": "b981579ef790561a399ed42a1873ed0529e0dec8f4a7bb85bfdc9174d17eb7dc" }, "downloads": -1, "filename": "api_toolkit-0.2.tar.gz", "has_sig": false, "md5_digest": "17776b8b4f0a4581abeed30de8b7b588", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 2092, "upload_time": "2013-12-27T22:06:20", "url": "https://files.pythonhosted.org/packages/f5/87/f4be5b411b5a9738c59e9601383762161b595476c491792bd599f6073251/api_toolkit-0.2.tar.gz" } ], "0.3": [ { "comment_text": "", "digests": { "md5": "b6a74aaae5b0d23b5d0556b2c2e4e03a", "sha256": "4550522676728f60edaecb757c85bad73d7012768a46b375cb6e53677b1563c5" }, "downloads": -1, "filename": "api_toolkit-0.3.tar.gz", "has_sig": false, "md5_digest": "b6a74aaae5b0d23b5d0556b2c2e4e03a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14375, "upload_time": "2014-01-06T22:07:39", "url": "https://files.pythonhosted.org/packages/f9/84/85d54045f13a3134a18f96ac01e5b3e88d0d7431b938ad1b3852ff13bc65/api_toolkit-0.3.tar.gz" } ], "0.3.1": [ { "comment_text": "", "digests": { "md5": "15f68827d5555a4065eb082c8d9c56c8", "sha256": "0796ca0e15b1eed0660f823514e6f318bea2597830f1ceda92d69a58366e312a" }, "downloads": -1, "filename": "api_toolkit-0.3.1.tar.gz", "has_sig": false, "md5_digest": "15f68827d5555a4065eb082c8d9c56c8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14459, "upload_time": "2014-01-09T00:10:18", "url": "https://files.pythonhosted.org/packages/96/ac/ff23011c69c7ca617d708f04df9afee0ebba03588528580d08efb2f00ed1/api_toolkit-0.3.1.tar.gz" } ], "0.3.10": [ { "comment_text": "", "digests": { "md5": "320686fbb60535c0d13e4e28bcb13d3a", "sha256": "9e5ae98f2e19f2d36282e69a2eeb9d6ff4c582cd938d275ccea6c68749add2b7" }, "downloads": -1, "filename": "api_toolkit-0.3.10.tar.gz", "has_sig": false, "md5_digest": "320686fbb60535c0d13e4e28bcb13d3a", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16913, "upload_time": "2014-09-25T20:21:13", "url": "https://files.pythonhosted.org/packages/7b/35/9f6cc6619d11dabb7a67dea7dc74823b773da23bb7c63e4f7bcd6ff1af02/api_toolkit-0.3.10.tar.gz" } ], "0.3.11": [ { "comment_text": "", "digests": { "md5": "9daa299a10dfbc68a7171fb9ef2cf520", "sha256": "1254634b11ce93ea17f4fa883654b299600ee0a7fc87ae8867cd69e41eb65318" }, "downloads": -1, "filename": "api_toolkit-0.3.11.tar.gz", "has_sig": false, "md5_digest": "9daa299a10dfbc68a7171fb9ef2cf520", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17122, "upload_time": "2014-11-12T19:00:25", "url": "https://files.pythonhosted.org/packages/b5/dd/aa36ca8172408a0471109c796685b97edfb096f158d8f7830021fda87c12/api_toolkit-0.3.11.tar.gz" } ], "0.3.2": [ { "comment_text": "", "digests": { "md5": "531a0f535c985472ef1de81a648263de", "sha256": "90713ac360da11cb70a1c3ec6f29eaa8aa857ed659f87547e937c8b2c34beac0" }, "downloads": -1, "filename": "api_toolkit-0.3.2.tar.gz", "has_sig": false, "md5_digest": "531a0f535c985472ef1de81a648263de", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14354, "upload_time": "2014-01-09T20:31:00", "url": "https://files.pythonhosted.org/packages/dc/cc/cf8d6e9eb2c277e37add7fef8bd3462709690245a777bdbf78fa881dfcd9/api_toolkit-0.3.2.tar.gz" } ], "0.3.3": [ { "comment_text": "", "digests": { "md5": "6d74df85e5ea7a4c34015ea3e2a059e9", "sha256": "3792b5baa0880f241d0e3b36c8c1a26ff7f333ae600ba5a6e68feb65bc983e31" }, "downloads": -1, "filename": "api_toolkit-0.3.3.tar.gz", "has_sig": false, "md5_digest": "6d74df85e5ea7a4c34015ea3e2a059e9", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14382, "upload_time": "2014-01-09T22:24:05", "url": "https://files.pythonhosted.org/packages/f3/2a/94545c58c6333bc21c09dd7221ecbf1d8bba489c89c0dae14da9af413633/api_toolkit-0.3.3.tar.gz" } ], "0.3.4": [ { "comment_text": "", "digests": { "md5": "3e07d870e40cfbdcc36e86e7746d82ed", "sha256": "ec65f249a224d7da591a3d148c50a68f51d634599d35581e14e8653950b41d96" }, "downloads": -1, "filename": "api_toolkit-0.3.4.tar.gz", "has_sig": false, "md5_digest": "3e07d870e40cfbdcc36e86e7746d82ed", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14378, "upload_time": "2014-01-09T22:46:14", "url": "https://files.pythonhosted.org/packages/c6/31/f71323550f530121265ba449002cd87990fc0a4089a61ef4fdd9c407f2cd/api_toolkit-0.3.4.tar.gz" } ], "0.3.5": [ { "comment_text": "", "digests": { "md5": "cd794eaaeb55bfee81d6ded85fe54184", "sha256": "82200da5e3bc857402419f20baee740c121f52c96b59dd0b8b2af0726415dae8" }, "downloads": -1, "filename": "api_toolkit-0.3.5.tar.gz", "has_sig": false, "md5_digest": "cd794eaaeb55bfee81d6ded85fe54184", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 14411, "upload_time": "2014-01-15T18:30:07", "url": "https://files.pythonhosted.org/packages/d7/b8/fb73e5a88c387c5f84fd85b4128f157b42e4d1122e0c01566b76c33a2740/api_toolkit-0.3.5.tar.gz" } ], "0.3.6": [ { "comment_text": "", "digests": { "md5": "9a16944c1c2587b111ee9c6f7638e7e8", "sha256": "29d3014e6a5b77db447e226878ba32b12de48b1c102c3b4e6555a6fc261187df" }, "downloads": -1, "filename": "api_toolkit-0.3.6.tar.gz", "has_sig": false, "md5_digest": "9a16944c1c2587b111ee9c6f7638e7e8", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17202, "upload_time": "2014-09-22T16:28:24", "url": "https://files.pythonhosted.org/packages/3e/37/6d6fed70e1f1104247131d1a7364cd0147806340b407eaa6bcf84541ce34/api_toolkit-0.3.6.tar.gz" } ], "0.3.7": [ { "comment_text": "", "digests": { "md5": "09c22488db613b661bd8d44486957d2c", "sha256": "4e64681fbc0eea5167b8fd2a4281037098e9a9d4429062bb530f29bc05d273a4" }, "downloads": -1, "filename": "api_toolkit-0.3.7.tar.gz", "has_sig": false, "md5_digest": "09c22488db613b661bd8d44486957d2c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16859, "upload_time": "2014-09-24T20:41:31", "url": "https://files.pythonhosted.org/packages/e2/7c/782303ea40505cdabd74b809687003b619834c6aab7cd8c5de8422b0064c/api_toolkit-0.3.7.tar.gz" } ], "0.3.8": [ { "comment_text": "", "digests": { "md5": "e6210e80c7f6e826b2b3a242b65b6331", "sha256": "14e41e2a2d7d56f5eac3006498775190f013398600b1dbf39625fe7e1fd01208" }, "downloads": -1, "filename": "api_toolkit-0.3.8.tar.gz", "has_sig": false, "md5_digest": "e6210e80c7f6e826b2b3a242b65b6331", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16882, "upload_time": "2014-09-24T23:02:24", "url": "https://files.pythonhosted.org/packages/2b/68/2a951b60ed4a7078a4e482638aba8a61eb4386012dfcae68d33b5d59bd2c/api_toolkit-0.3.8.tar.gz" } ], "0.3.9": [ { "comment_text": "", "digests": { "md5": "c99aa2bc38c5500861611a223a3ae979", "sha256": "146ec3516963e766338fc12b6d8a8cdc6f41b78990ceb10019033aee783979a5" }, "downloads": -1, "filename": "api_toolkit-0.3.9.tar.gz", "has_sig": false, "md5_digest": "c99aa2bc38c5500861611a223a3ae979", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 16912, "upload_time": "2014-09-25T18:25:29", "url": "https://files.pythonhosted.org/packages/60/3a/95489b1f95b930b32681b2a725b7aafd0553e50b6560087b92c1fbd0c3a2/api_toolkit-0.3.9.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "9daa299a10dfbc68a7171fb9ef2cf520", "sha256": "1254634b11ce93ea17f4fa883654b299600ee0a7fc87ae8867cd69e41eb65318" }, "downloads": -1, "filename": "api_toolkit-0.3.11.tar.gz", "has_sig": false, "md5_digest": "9daa299a10dfbc68a7171fb9ef2cf520", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 17122, "upload_time": "2014-11-12T19:00:25", "url": "https://files.pythonhosted.org/packages/b5/dd/aa36ca8172408a0471109c796685b97edfb096f158d8f7830021fda87c12/api_toolkit-0.3.11.tar.gz" } ] }