{ "info": { "author": "Huan Di", "author_email": "hd@iamhd.com", "bugtrack_url": null, "classifiers": [ "License :: OSI Approved :: MIT License", "Programming Language :: Python", "Programming Language :: Python :: 3", "Programming Language :: Python :: 3.5", "Programming Language :: Python :: 3.6", "Programming Language :: Python :: 3.7", "Programming Language :: Python :: Implementation :: CPython", "Programming Language :: Python :: Implementation :: PyPy" ], "description": "# restful-client-lite [![Build Status](https://travis-ci.com/huandzh/restful-client-lite.svg?branch=master)](https://travis-ci.com/huandzh/restful-client-lite)\n\nA lite client for RESTFul APIs with limited features.\n\nIt provides:\n\n* `restful_client_lite.APIClient`: client for [eve](https://docs.python-eve.org) token-auth apps\n* `restful_client_lite.contrib.AliyunApiGatewayClient`: client for apis generated by [aliyun DataService](https://help.aliyun.com/document_detail/73295.html?spm=a2c4g.11186623.6.838.74b233b40qZs2W) (only `GET` is supported)\n\nWIP.(not stable before v0.1.0)\n\n## Installation\n\n### Lastest release ![PyPI](https://img.shields.io/pypi/v/restful_client_lite) \n\npipenv:\n\n```shell\npipenv install restful_client_lite\n```\n\npip:\n\n```shell\npip install restful_client_lite\n```\n### Dev\n\npipenv:\n\n```shell\npipenv install -e git+https://github.com/huandzh/restful-client-lite#egg=restful-client-lite\n```\n\npip:\n\n```shell\npip install -e git+https://github.com/huandzh/restful-client-lite#egg=restful-client-lite\n```\n\n## Usage\n\nAssume that we have a restful api requiring `Authorization:` in the header and using etag to control writes.\n\nCreate an API client:\n\n```python\nfrom restful_client_lite import APIClient\napi = APIClient(\"\", {\"token\": \"\"})\n```\n\nGet from url:\n\n```python\nres_get = api.get(\"\")\n```\n\nPost to url:\n\n```python\nres_post = api.post(\"\", data={\"\": \"\"})\n```\n\nPatch url:\n\n```python\nres_patch = api.patch(\"\", \"\", data={\"\": \"\"})\n```\n\nPatch url (fetch etag automatically in advance):\n\n```python\nres_patch = api.patch_auto_etag(\"\", data={\"\": \"\"})\n```\n\nDelete url:\n\n```python\nres_delete = api.delete(\"\", \"\")\n```\n\nDelete url (fetch etag automatically in advance):\n\n```python\nres_delete = api.delete_auto_etag(\"\")\n```\n\nSubclass `APIClient` to create custom api client:\n\n```python\ndef sign(url):\n \"\"\"some function return signature\"\"\"\n ...\n return \n\nclass CustomAPIClient(APIClient):\n \"\"\"custom api client\"\"\"\n\n def auth_headers(self, f: Callable) -> Callable:\n \"\"\"custom auth headers\"\"\"\n @wraps(f)\n def wrapper(*args, **kwargs):\n headers = kwargs.get(\"headers\", {}).copy()\n url = args[0]\n headers.update({\"Signature\": sign(url)})\n kwargs[\"headers\"] = headers\n return f(*args, **kwargs)\n```\n\n## 3rd-party APIs\n\n### aliyun api gateway\n\n`AliyunApiGatewayClient` :\n\n* support `GET` from aliyun-api-gateway apis (apis may generated by DataService)\n* handle authorization headers\n* **doesn't** sort url params\n\n```python\nfrom restful_client_lite.contrib.aliyun import AliyunApiGatewayClient\napi = AliyunApiGatewayClient(\n '',\n {\"app_id\": '',\n \"app_secret\": ''})\n# make sure params in are sorted\nres = api.get('')\n```", "description_content_type": "text/markdown", "docs_url": null, "download_url": "", "downloads": { "last_day": -1, "last_month": -1, "last_week": -1 }, "home_page": "https://github.com/huandzh/restful-client-lite", "keywords": "", "license": "MIT", "maintainer": "", "maintainer_email": "", "name": "restful-client-lite", "package_url": "https://pypi.org/project/restful-client-lite/", "platform": "", "project_url": "https://pypi.org/project/restful-client-lite/", "project_urls": { "Homepage": "https://github.com/huandzh/restful-client-lite" }, "release_url": "https://pypi.org/project/restful-client-lite/0.0.2/", "requires_dist": null, "requires_python": ">=3.5.0", "summary": "A lite client for restful APIs.", "version": "0.0.2" }, "last_serial": 5696349, "releases": { "0.0.1": [ { "comment_text": "", "digests": { "md5": "99a1cda63e73af5868975f1f9157a31f", "sha256": "a9debdbb5a909e4faecd9fa3dee12a246e40f4a32cff77ff4175ad14aa2a8e1b" }, "downloads": -1, "filename": "restful-client-lite-0.0.1.tar.gz", "has_sig": false, "md5_digest": "99a1cda63e73af5868975f1f9157a31f", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.0", "size": 3941, "upload_time": "2019-08-13T08:16:35", "url": "https://files.pythonhosted.org/packages/b3/f6/3143c0bdb8b10737171f28426a3f80d0e26e5b3ca592c07246684e923af3/restful-client-lite-0.0.1.tar.gz" } ], "0.0.2": [ { "comment_text": "", "digests": { "md5": "a492e1ae7026b3c33716ed81391c1581", "sha256": "ee232be0b9004eabaa798d4e8cc9c420a056b1ed43e29283adf15539ca9e96aa" }, "downloads": -1, "filename": "restful-client-lite-0.0.2.tar.gz", "has_sig": false, "md5_digest": "a492e1ae7026b3c33716ed81391c1581", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.0", "size": 5965, "upload_time": "2019-08-19T01:57:27", "url": "https://files.pythonhosted.org/packages/db/51/871203d662d97d2e0f381a5b5fd675ecb33c457508b07647823484a339b1/restful-client-lite-0.0.2.tar.gz" } ] }, "urls": [ { "comment_text": "", "digests": { "md5": "a492e1ae7026b3c33716ed81391c1581", "sha256": "ee232be0b9004eabaa798d4e8cc9c420a056b1ed43e29283adf15539ca9e96aa" }, "downloads": -1, "filename": "restful-client-lite-0.0.2.tar.gz", "has_sig": false, "md5_digest": "a492e1ae7026b3c33716ed81391c1581", "packagetype": "sdist", "python_version": "source", "requires_python": ">=3.5.0", "size": 5965, "upload_time": "2019-08-19T01:57:27", "url": "https://files.pythonhosted.org/packages/db/51/871203d662d97d2e0f381a5b5fd675ecb33c457508b07647823484a339b1/restful-client-lite-0.0.2.tar.gz" } ] }