{ "info": { "author": "Will Wheatley", "author_email": "will.wheatley@lonelyplanet.com.au", "bugtrack_url": null, "classifiers": [ "Intended Audience :: Developers", "License :: OSI Approved :: Apache Software License", "Programming Language :: Python", "Topic :: Internet :: WWW/HTTP", "Topic :: Internet :: WWW/HTTP :: Dynamic Content", "Topic :: Software Development :: Libraries" ], "description": "Siren Client for Python\n=======================\n\n\nA generic client for consuming Hypermedia API's which utilise\n[Siren](https://github.com/kevinswiber/siren) for the entity schema.\n\nThe client consumes the Siren and creates objects which represent the various\nSiren Objects. This library does not provide a transport mechanism to access the\nAPI but is designed to work with a\n[requests](http://docs.python-requests.org/en/latest/) session.\n\nAuthentication is managed by the session manager provided to the the Siren\nclient. Usage patterns below.\n\n\n## Installing\n\nThe library is available to install using pip:\n\n $ pip install siren-client\n\nAlternatively, you can clone this package and install it yourself.\n\n\n## Getting Started\n\nThe client is designed to allow you to traverse the data in the API, without\nhaving to worry about requests or URL construction. You simply need to provide\nthe first object with a url:\n\n```python\nimport siren_client\n\nentity = siren_client.get('http://some.siren-api.com/')\n```\n\nEach Siren Entity provided some introspection so that you can quickly see what\nthe entity is.\n\n```python\nprint entity\n```\n\nAll of siren concepts are available as Python constructs.\n\n### Basic Siren Attributes\n\n```python\nprint entity.uri\nprint entity.class_\nprint entity.rel # Generally only if it is a sub-entity\n```\n\n### Siren Properties are available on the entity\n\n```python\nprint entity['Name']\n```\n\n### An Entity can be 'refreshed' from the server\n\n```python\nentity.refresh()\n```\n\n### Following Siren links\n\n```python\nprint entity.links\nsecond_entity = entity.links['some-link']\n```\n\n### Using Siren Actions\n\n```python\nprint entity.actions\nprint entity.actions['next']\n\ncollection = entity.actions['next']()\n\n# You can pass any parameters to an action\n\ncollection = entity.actions['next'](skip=3)\n\n# You can seed an action with the properties of some other entity\n\nnew_entity_action = entity.actions['new-entity']\nnew_entity_action.populate(entity)\nnew_entity_action() # This will call the action with the data set from `entity`\nnew_entity_action(Name='Another Name') # This will call the action as above\n # but override (or set) the name to be\n # 'Another Name'\n\n```\n\n## Config\n\nConfiguration can be provided to the `get` function earlier.\n\n```python\nimport siren_client\nentity siren_client.get('http://my_url/', rel_base='https://my_api.com/rels/')\n```\n\n - `rel_base` If set to a value, and this value is at the start of any rel\n that rel will have that value removed:\n\n Example:\n setting the rel_base to 'http://my.company/schema/' will convert any\n rel from the API (such as 'http://my.company/schema/my_link') to a\n shortened version (in this example: `my_link`)\n\n - `dumps` Provide your own function for serialising any requests. By default\n Siren Client will inspect the content type and automatically\n serialise into JSON as needed. The function will receive two\n parameters, the requested content type, and the data to serialise.\n\n ```python\n def my_dumps(content_type, data):\n # Convert data here\n return converted_data\n ```\n\n - `loads` Provide your own function for de-serialising any requests. By default\n Siren Client will inspect the content type and automatically\n de-serialise from JSON as needed. The function will receive two\n parameters, the requested content type, and the content to\n de-serialise.\n\n ```python\n def my_loads(content_type, data):\n # Convert data here\n return converted_data\n ```\n\n - `self_rel` By default the Siren Client will calculate the canonical 'URI' of\n an entity from the link containing a rel called `self`. This\n parameter lets you change the rel that the library will use to\n determine the canonical 'URI'.\n\n\n## Authentication Setup\n\nThe library expects a *requests* session (or similar) to manage the connection\nto the server. Whatever methods of authentication requests supports, the\nsiren-client also supports. Any other transport configuration required (such as\nkeep-alive, headers etc) can be utilised by configuring the Session or\nsub-classing the Session.\n\n### Example Basic Authentication\n\n```python\nimport siren_client\nfrom requests import Session\nfrom requests.auth import HTTPBasicAuth\n\nsession = Session()\nsession.auth = HTTPBasicAuth('my_username', 'my_password')\nentity = siren_client.get('http://my.url.com/', session=session)\n```\n\n### Example Session Hook\n\n```python\ndef mutate_response_somehow(req, *args, **kwargs):\n # do something\n print r.url\n\nsession = Session()\nsession.hooks['response'] = mutate_response_somehow\nentity = siren_client.get('http://my.url.com/', session=session)\n```\n\n### Example Custom Header\n\n```python\nsession = Session()\nsession.headers['X-Pizza'] = 'pepperoni'\nentity = siren_client.get('http://my.url.com/', session=session)\n```\n\n### Other plugins for Requests Session\n\n - https://github.com/requests/requests-oauthlib\n\n## Replace Requests Session with your own transport\n\nThe session simply provides a transport mechanism for the client. It could be\ncompletely replaced with an arbitrary object doing arbitrary things (such as\ncommunicating in some way other than HTTP). The only methods that are called on\nthe Session object are the HTTP verbs, with the `get` being used for following\nlinks, etc. If your siren API provided a method of 'hyperspace' in an action\ndefinition, then the library would attempt to call the `hyperspace` method on\nthe session transport.\n\nRegardless of which method is used to get the data from the server, the response\nis then required to have two attributes and one method:\n\n - `content` This can be whatever you want. By default it attempt to be\n de-serialized as JSON\n - `headers` A dictionary\n - `raise_for_status()` This allows the response to throw an exception if there\n is something wrong.\n\n\n## Maintainers\n\nLonely Planet maintains this code as a library that it actively uses.\nContributions are welcome in the form of bug reports and pull requests.\n\n\n\n1.0.0.dev1\n---\n\n- Initial version for develoment use.", "description_content_type": null, "docs_url": null, "download_url": "UNKNOWN", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/lonelyplanet/siren-client-python", "keywords": "siren hypermedia json", "license": "Apache 2.0", "maintainer": null, "maintainer_email": null, "name": "siren-client", "package_url": "https://pypi.org/project/siren-client/", "platform": "UNKNOWN", "project_url": "https://pypi.org/project/siren-client/", "project_urls": { "Download": "UNKNOWN", "Homepage": "https://github.com/lonelyplanet/siren-client-python" }, "release_url": "https://pypi.org/project/siren-client/1.0.2/", "requires_dist": null, "requires_python": null, "summary": "Client for a Siren based Hypermedia API", "version": "1.0.2" }, "last_serial": 1426131, "releases": { "1.0.0.dev1": [ { "comment_text": "", "digests": { "md5": "0328159178bc120cb688bc7f12d9d274", "sha256": "5529e528c5c78858b90dd6d7fe748e3258e31a1f3d45f474638ba47b0e8da51e" }, "downloads": -1, "filename": "siren_client-1.0.0.dev1-py2.py3-none-any.whl", "has_sig": false, "md5_digest": "0328159178bc120cb688bc7f12d9d274", "packagetype": "bdist_wheel", "python_version": "2.7", "requires_python": null, "size": 10024, "upload_time": "2015-01-15T23:27:00", "url": "https://files.pythonhosted.org/packages/a3/99/fe5b196fe4cdb053560e9c7d4fe93d66a0a695c22eb958166ce5511bc852/siren_client-1.0.0.dev1-py2.py3-none-any.whl" }, { "comment_text": "", "digests": { "md5": "38021c5a7fc26ed8c7398e1f00f2a0fa", "sha256": "942a299ecb89e2ffa95a085a6ef17cc7996b3fb8e186d2c990d1a85ab3ca845a" }, "downloads": -1, "filename": "siren-client-1.0.0.dev1.tar.gz", "has_sig": false, "md5_digest": "38021c5a7fc26ed8c7398e1f00f2a0fa", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6585, "upload_time": "2015-01-15T23:25:36", "url": "https://files.pythonhosted.org/packages/e1/9a/72588846f8b86e84d1dc1e03394bedabbc7ab76f16ab8ad67e71f031f76f/siren-client-1.0.0.dev1.tar.gz" } ], "1.0.1": [ { "comment_text": "built for Linux-3.18.3-201.fc21.x86_64-x86_64-with-glibc2.2.5", "digests": { "md5": "4aee171b2a9bc9d89415d86a15d3434c", "sha256": "281e062ee27a176c7939ffcf3995f4450c44745966533050ebebdc66f91c8205" }, "downloads": -1, "filename": "siren-client-1.0.1.linux-x86_64.tar.gz", "has_sig": false, "md5_digest": "4aee171b2a9bc9d89415d86a15d3434c", "packagetype": "bdist_dumb", "python_version": "any", "requires_python": null, "size": 9851, "upload_time": "2015-02-08T15:40:22", "url": "https://files.pythonhosted.org/packages/c9/9b/0b5efd69bff8522f37eb62a2e4030d5825cb022928b8ba43f2cf58a32f7e/siren-client-1.0.1.linux-x86_64.tar.gz" }, { "comment_text": "", "digests": { "md5": "3f9f397c3a3bc02093e75578c0575d05", "sha256": "d721e00f5b0bbd32f61bc5dfec1a444c102f802e4839cb0f9a6b92302dbd4a13" }, "downloads": -1, "filename": "siren_client-1.0.1-py2.7.egg", "has_sig": false, "md5_digest": "3f9f397c3a3bc02093e75578c0575d05", "packagetype": "bdist_egg", "python_version": "2.7", "requires_python": null, "size": 11704, "upload_time": "2015-02-08T15:40:24", "url": "https://files.pythonhosted.org/packages/44/de/6695c366de0ea9b4fdf8a034a406393d012dcb36dbda5a9baa577747081f/siren_client-1.0.1-py2.7.egg" }, { "comment_text": "", "digests": { "md5": "3ff6a9f8421a618d3ddee94982e057f6", "sha256": "105b8b1509d2dfb20bd7967fa75d0cd39cab605bc44e2651ae94128b6922ff7d" }, "downloads": -1, "filename": "siren-client-1.0.1.tar.gz", "has_sig": false, "md5_digest": "3ff6a9f8421a618d3ddee94982e057f6", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 6762, "upload_time": "2015-02-08T15:40:27", "url": "https://files.pythonhosted.org/packages/41/b5/ff282221fcc82914a3cf4358f6a8654e0f25550edcc167f101f6530bb855/siren-client-1.0.1.tar.gz" } ], "1.0.2": [ { "comment_text": "", "digests": { "md5": "94a07afdfa7f036672b054ce4b8aba75", "sha256": "c58d7041c34c3896bc63f248544bdf901abce9e8b10eaa7733730f401ebd90d5" }, "downloads": -1, "filename": "siren-client-1.0.2.tar.gz", "has_sig": false, "md5_digest": "94a07afdfa7f036672b054ce4b8aba75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9168, "upload_time": "2015-02-16T23:08:56", "url": "https://files.pythonhosted.org/packages/e0/8b/f0b50af7c87df204f9ddeabe99417daf108e09f7a35bd4453b9cf12fb9b8/siren-client-1.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "94a07afdfa7f036672b054ce4b8aba75", "sha256": "c58d7041c34c3896bc63f248544bdf901abce9e8b10eaa7733730f401ebd90d5" }, "downloads": -1, "filename": "siren-client-1.0.2.tar.gz", "has_sig": false, "md5_digest": "94a07afdfa7f036672b054ce4b8aba75", "packagetype": "sdist", "python_version": "source", "requires_python": null, "size": 9168, "upload_time": "2015-02-16T23:08:56", "url": "https://files.pythonhosted.org/packages/e0/8b/f0b50af7c87df204f9ddeabe99417daf108e09f7a35bd4453b9cf12fb9b8/siren-client-1.0.2.tar.gz" } ] }