{ "info": { "author": "Li Jiale", "author_email": "lijiale@wilddog.com", "bugtrack_url": null, "classifiers": [ "Development Status :: 5 - Production/Stable", "Environment :: Console", "Intended Audience :: Developers", "License :: OSI Approved :: MIT License", "Natural Language :: English", "Operating System :: OS Independent", "Programming Language :: Python :: 2.6", "Programming Language :: Python :: 2.7", "Programming Language :: Python :: 3.2" ], "description": "Wilddog Python\n=================\n\nPython interface to the Wilddog's REST API\n\n\nInstallation\n-----------------\n\nwilddog-python highly makes use of the **requests** library so before you begin, you need to have that package installed.\n\n.. code-block:: bash\n\n $ sudo pip install requests==1.1.0\n $ sudo pip install wilddog-python\n\nGetting Started\n------------------\n\nYou can fetch any of your data in JSON format by appending '.json' to the end of the URL in which your data resides and, then send an HTTPS request through your browser. Like all other REST specific APIs, Wilddog offers a client to update(PATCH, PUT), create(POST), or remove(DELETE) his stored data along with just to fetch it.\n\nThe library provides all the correspoding methods for those actions in both synchoronous and asynchronous manner. You can just start an asynchronous GET request with your callback function, and the method\n\n\nTo fetch all the users in your storage simply do the following:\n\n.. code-block:: python\n\n from wilddog import wilddog\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', None)\n result = wilddog.get('/users', None)\n print result\n {'1': 'John Doe', '2': 'Jane Doe'}\n\nThe second argument of **get** method is the name of the snapshot. Thus, if you leave it NULL, you get the data in the URL **/users.json**. Besides, if you set it to **1**, you get the data in the url **/users/1.json**. In other words, you get the user whose ID equals to 1.\n\n.. code-block:: python\n\n from wilddog import wilddog\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', None)\n result = wilddog.get('/users', '1')\n print result\n {'1': 'John Doe'}\n\nYou can also provide extra query parameters that will be appended to the url or extra key-value pairs sent in the HTTP header.\n\n.. code-block:: python\n\n from wilddog import wilddog\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', None)\n result = wilddog.get('/users/2', None, {'print': 'pretty'}, {'X_FANCY_HEADER': 'VERY FANCY'})\n print result\n {'2': 'Jane Doe'}\n\nCreating new data requires a POST or PUT request. Assuming you don't append **print=silent** to the url, if you use POST the returning value becomes the name of the snapshot, if PUT you get the data you just sent. If print=silent is provided, you get just NULL because the backend never sends an output.\n\n.. code-block:: python\n\n from wilddog import wilddog\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', None)\n new_user = 'Ozgur Vatansever'\n\n result = wilddog.post('/users', new_user, {'print': 'pretty'}, {'X_FANCY_HEADER': 'VERY FANCY'})\n print result\n {u'name': u'-Io26123nDHkfybDIGl7'}\n\n result = wilddog.post('/users', new_user, {'print': 'silent'}, {'X_FANCY_HEADER': 'VERY FANCY'})\n print result == None\n True\n\nDeleting data is relatively easy compared to other actions. You just set the url and that's all. Backend sends no output as a result of a delete operation.\n\n.. code-block:: python\n\n from wilddog import wilddog\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', None)\n wilddog.delete('/users', '1')\n # John Doe goes away.\n\nAuthentication\n------------------\n\nAuthentication in Wilddog is nothing but to simply creating a token that conforms to the JWT standarts and, putting it into the querystring with the name **auth**. The library creates that token for you so you never end up struggling with constructing a valid token on your own. If the data has been protected against write/read operations with some security rules, the backend sends an appropriate error message back to the client with the status code **403 Forbidden**.\n\n.. code-block:: python\n\n from wilddog import wilddog\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', authentication=None)\n result = wilddog.get('/users', None, {'print': 'pretty'})\n print result\n {'error': 'Permission denied.'}\n\n authentication = wilddog.WilddogAuthentication('THIS_IS_MY_SECRET', 'ozgurvt@gmail.com', extra={'id': 123})\n wilddog.authentication = authentication\n print authentication.extra\n {'admin': False, 'debug': False, 'email': 'ozgurvt@gmail.com', 'id': 123, 'provider': 'password'}\n\n user = authentication.get_user()\n print user.wilddog_auth_token\n \"eyJhbGciOiAiSFMyNTYiLCAidHlwIjogIkpXVCJ9.eyJhZG1pbiI6IGZhbHNlLCAiZGVidWciOiBmYWxzZSwgIml\n hdCI6IDEzNjE5NTAxNzQsICJkIjogeyJkZWJ1ZyI6IGZhbHNlLCAiYWRtaW4iOiBmYWxzZSwgInByb3ZpZGVyIjog\n InBhc3N3b3JkIiwgImlkIjogNSwgImVtYWlsIjogIm96Z3VydnRAZ21haWwuY29tIn0sICJ2IjogMH0.lq4IRVfvE\n GQklslOlS4uIBLSSJj88YNrloWXvisRgfQ\"\n\n result = wilddog.get('/users', None, {'print': 'pretty'})\n print result\n {'1': 'John Doe', '2': 'Jane Doe'}\n\nYou can use set_token instead:\n\n.. code-block:: python\n\n from wilddog import wilddog\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', authentication=None)\n result = wilddog.get('/users', None, {'print': 'pretty'})\n print result\n {'error': 'Permission denied.'}\n\n wilddog.set_token(YOUR_GENERATED_TOKEN)\n result = wilddog.get('/users', None, {'print': 'pretty'})\n print result\n {'1': 'John Doe', '2': 'Jane Doe'}\n\nConcurrency\n------------------\n\nThe interface heavily depends on the standart **multiprocessing** library when concurrency comes in. While creating an asynchronous call, an on-demand process pool is created and, the async method is executed by one of the idle process inside the pool. The pool remains alive until the main process dies. So every time you trigger an async call, you always use the same pool. When the method returns, the pool process ships the returning value back to the main process within the callback function provided.\n\n.. code-block:: python\n\n import json\n from wilddog import wilddog\n from wilddog import jsonutil\n\n wilddog = wilddog.WilddogApplication('https://your_storage.wilddogio.com', authentication=None)\n\n def log_user(response):\n with open('/tmp/users/%s.json' % response.keys()[0], 'w') as users_file:\n users_file.write(json.dumps(response, cls=jsonutil.JSONEncoder))\n\n wilddog.get_async('/users', None, {'print': 'pretty'}, callback=log_user)", "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/WildDogTeam/wilddog-python", "keywords": "wilddog python", "license": "MIT", "maintainer": null, "maintainer_email": null, "name": "wilddog-python", "package_url": "https://pypi.org/project/wilddog-python/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/wilddog-python/", "project_urls": { "Download": "UNKNOWN", "Homepage": "http://github.com/WildDogTeam/wilddog-python" }, "release_url": "https://pypi.org/project/wilddog-python/1.0.1/", "requires_dist": null, "requires_python": null, "summary": "Python interface to the Wilddog's REST API.", "version": "1.0.1" }, "last_serial": 1828862, "releases": { "1.0": [ { "comment_text": "", "digests": { "md5": "4c561a8cd3a83e011d46bcbb29e2612f", "sha256": "6d2fd4741f3024c579b4f63dd85ba57a7dd3854311c1d7d867b74847876e96f8" }, "downloads": -1, "filename": "wilddog-python-1.0.tar.gz", "has_sig": false, "md5_digest": "4c561a8cd3a83e011d46bcbb29e2612f", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12967, "upload_time": "2015-11-10T08:10:35", "url": "https://files.pythonhosted.org/packages/67/62/787cce821e451a99c46fa35d8592ae655e4a645c740ef442a516816e9713/wilddog-python-1.0.tar.gz" } ], "1.0.1": [ { "comment_text": "", "digests": { "md5": "1c91e5877bd22b5f39a78ae540198c6c", "sha256": "220ff0ee90dc34d83f4d33d8c7612d9b383c2fa41cba4f64e976ad95e7569dae" }, "downloads": -1, "filename": "wilddog-python-1.0.1.tar.gz", "has_sig": false, "md5_digest": "1c91e5877bd22b5f39a78ae540198c6c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12985, "upload_time": "2015-11-23T05:51:55", "url": "https://files.pythonhosted.org/packages/43/ba/eeaec69e61d712b448e67c0b42a3e484fc3c90a3fa40c07ab97105f484bb/wilddog-python-1.0.1.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "1c91e5877bd22b5f39a78ae540198c6c", "sha256": "220ff0ee90dc34d83f4d33d8c7612d9b383c2fa41cba4f64e976ad95e7569dae" }, "downloads": -1, "filename": "wilddog-python-1.0.1.tar.gz", "has_sig": false, "md5_digest": "1c91e5877bd22b5f39a78ae540198c6c", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 12985, "upload_time": "2015-11-23T05:51:55", "url": "https://files.pythonhosted.org/packages/43/ba/eeaec69e61d712b448e67c0b42a3e484fc3c90a3fa40c07ab97105f484bb/wilddog-python-1.0.1.tar.gz" } ] }