sdlv-api-client


Namesdlv-api-client JSON
Version 1.1.1 PyPI version JSON
download
home_page
SummaryAPI Client Base class
upload_time2024-03-10 16:10:00
maintainer
docs_urlNone
author
requires_python~=3.10
license
keywords api client api-client
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Example code
```python
# client.py
from api_client import BaseAPIClient


class LocalClient(BaseAPIClient):
    name = "local"
    _base_url = "https://obligari.serveo.net/ping/local"

    def __init__(self, nonce=None):
        super().__init__(nonce)
        self._session.headers.update(
            {"User-Agent": "Mozilla/5.0 (Windows NT 10.0; rv:123.0) Gecko/20100101 Firefox/123.0"}
        )

    def send_post_ping(self, var1: str, var2: int) -> bool:
        res = self.post("/some-post", json={"variable_one": var1, "second_variable": var2})
        return res.json().get("status")

    def send_put_ping(self, var1: str, var2: int) -> bool:
        res = self.put("/some-put", data={"variable_one": var1, "second_variable": var2})
        return res.json().get("status")

    def send_get_ping(self, var1: str, var2: int) -> bool:
        res = self.get("/some-get", params={"variable_one": var1, "second_variable": var2})
        return res.json().get("status")

    def send_patch_ping(self, var1: str, var2: int) -> bool:
        res = self.put("/some-patch", data=(("variable_one", var1), ("variable_one", var2)))
        return res.json().get("status")

    def send_trace_ping(self, var1: str, var2: int) -> bool:
        res = self.trace("/some-trace", params=(("variable_one", var1), ("variable_one", var2)))
        return res.json().get("status")

    
```

```python
# main.py
from .client import LocalClient


client = LocalClient()
client.send_post_ping("asd", 123)
client.send_put_ping("asd", 123)
client.send_get_ping("asd", 123)
client.send_patch_ping("asd", 123)
client.send_trace_ping("asd", 123)
```

## Log output
### Simple
```text
[14d709e02c0c] Preparing POST request to "https://obligari.serveo.net/ping/local/some-post"
[14d709e02c0c] Sending request with payload=b'{"variable_one": "asd", "second_variable": 123}'
[14d709e02c0c] Response response.status_code=200 str_repr_content='{"status":true,"request_id":62}'
[14d709e02c0c] Preparing GET request to "https://obligari.serveo.net/ping/local/some-get"
[14d709e02c0c] Sending request with payload=None
[14d709e02c0c] Response response.status_code=200 str_repr_content='{"status":true,"request_id":63}'
```
### Structured
```json
{"app": "dev", "level": "DEBUG", "name": "APIClient", "date_time": "2024-03-09 22:59:24", "location": "api_client/client.py:_request:71", "message": "[cfbdadc56f53] Preparing POST request to \"https://obligari.serveo.net/ping/local/some-post\"", "extra_data": {"hooks": {"response": []}, "method": "POST", "url": "https://obligari.serveo.net/ping/local/some-post", "headers": {}, "files": [], "data": [], "json": {"variable_one": "asd", "second_variable": 123}, "params": {}, "auth": null, "cookies": null}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:24", "location": "api_client/client.py:_request:74", "message": "[cfbdadc56f53] Sending request with payload=b'{\"variable_one\": \"asd\", \"second_variable\": 123}'", "extra_data": {"payload": "{\"variable_one\": \"asd\", \"second_variable\": 123}"}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:81", "message": "[cfbdadc56f53] Response response.status_code=200 str_repr_content='{\"status\":true,\"request_id\":72}'", "extra_data": {"status_code": 200, "content": "{\"status\":true,\"request_id\":72}"}}
{"app": "dev", "level": "DEBUG", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:71", "message": "[cfbdadc56f53] Preparing GET request to \"https://obligari.serveo.net/ping/local/some-get\"", "extra_data": {"hooks": {"response": []}, "method": "GET", "url": "https://obligari.serveo.net/ping/local/some-get", "headers": {}, "files": [], "data": [], "json": null, "params": {"variable_one": "asd", "second_variable": 123}, "auth": null, "cookies": null}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:74", "message": "[cfbdadc56f53] Sending request with payload=None", "extra_data": {"payload": "{}"}}
{"app": "dev", "level": "INFO", "name": "APIClient", "date_time": "2024-03-09 22:59:25", "location": "api_client/client.py:_request:81", "message": "[cfbdadc56f53] Response response.status_code=200 str_repr_content='{\"status\":true,\"request_id\":74}'", "extra_data": {"status_code": 200, "content": "{\"status\":true,\"request_id\":73}"}}
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "sdlv-api-client",
    "maintainer": "",
    "docs_url": null,
    "requires_python": "~=3.10",
    "maintainer_email": "",
    "keywords": "api,client,api-client",
    "author": "",
    "author_email": "Eriks Karls <git@72.lv>",
    "download_url": "https://files.pythonhosted.org/packages/00/36/7a05a536cb05a7875b7a821937b84270cde43c748faa42202454df154d13/sdlv_api_client-1.1.1.tar.gz",
    "platform": null,
    "description": "# Example code\n```python\n# client.py\nfrom api_client import BaseAPIClient\n\n\nclass LocalClient(BaseAPIClient):\n    name = \"local\"\n    _base_url = \"https://obligari.serveo.net/ping/local\"\n\n    def __init__(self, nonce=None):\n        super().__init__(nonce)\n        self._session.headers.update(\n            {\"User-Agent\": \"Mozilla/5.0 (Windows NT 10.0; rv:123.0) Gecko/20100101 Firefox/123.0\"}\n        )\n\n    def send_post_ping(self, var1: str, var2: int) -> bool:\n        res = self.post(\"/some-post\", json={\"variable_one\": var1, \"second_variable\": var2})\n        return res.json().get(\"status\")\n\n    def send_put_ping(self, var1: str, var2: int) -> bool:\n        res = self.put(\"/some-put\", data={\"variable_one\": var1, \"second_variable\": var2})\n        return res.json().get(\"status\")\n\n    def send_get_ping(self, var1: str, var2: int) -> bool:\n        res = self.get(\"/some-get\", params={\"variable_one\": var1, \"second_variable\": var2})\n        return res.json().get(\"status\")\n\n    def send_patch_ping(self, var1: str, var2: int) -> bool:\n        res = self.put(\"/some-patch\", data=((\"variable_one\", var1), (\"variable_one\", var2)))\n        return res.json().get(\"status\")\n\n    def send_trace_ping(self, var1: str, var2: int) -> bool:\n        res = self.trace(\"/some-trace\", params=((\"variable_one\", var1), (\"variable_one\", var2)))\n        return res.json().get(\"status\")\n\n    \n```\n\n```python\n# main.py\nfrom .client import LocalClient\n\n\nclient = LocalClient()\nclient.send_post_ping(\"asd\", 123)\nclient.send_put_ping(\"asd\", 123)\nclient.send_get_ping(\"asd\", 123)\nclient.send_patch_ping(\"asd\", 123)\nclient.send_trace_ping(\"asd\", 123)\n```\n\n## Log output\n### Simple\n```text\n[14d709e02c0c] Preparing POST request to \"https://obligari.serveo.net/ping/local/some-post\"\n[14d709e02c0c] Sending request with payload=b'{\"variable_one\": \"asd\", \"second_variable\": 123}'\n[14d709e02c0c] Response response.status_code=200 str_repr_content='{\"status\":true,\"request_id\":62}'\n[14d709e02c0c] Preparing GET request to \"https://obligari.serveo.net/ping/local/some-get\"\n[14d709e02c0c] Sending request with payload=None\n[14d709e02c0c] Response response.status_code=200 str_repr_content='{\"status\":true,\"request_id\":63}'\n```\n### Structured\n```json\n{\"app\": \"dev\", \"level\": \"DEBUG\", \"name\": \"APIClient\", \"date_time\": \"2024-03-09 22:59:24\", \"location\": \"api_client/client.py:_request:71\", \"message\": \"[cfbdadc56f53] Preparing POST request to \\\"https://obligari.serveo.net/ping/local/some-post\\\"\", \"extra_data\": {\"hooks\": {\"response\": []}, \"method\": \"POST\", \"url\": \"https://obligari.serveo.net/ping/local/some-post\", \"headers\": {}, \"files\": [], \"data\": [], \"json\": {\"variable_one\": \"asd\", \"second_variable\": 123}, \"params\": {}, \"auth\": null, \"cookies\": null}}\n{\"app\": \"dev\", \"level\": \"INFO\", \"name\": \"APIClient\", \"date_time\": \"2024-03-09 22:59:24\", \"location\": \"api_client/client.py:_request:74\", \"message\": \"[cfbdadc56f53] Sending request with payload=b'{\\\"variable_one\\\": \\\"asd\\\", \\\"second_variable\\\": 123}'\", \"extra_data\": {\"payload\": \"{\\\"variable_one\\\": \\\"asd\\\", \\\"second_variable\\\": 123}\"}}\n{\"app\": \"dev\", \"level\": \"INFO\", \"name\": \"APIClient\", \"date_time\": \"2024-03-09 22:59:25\", \"location\": \"api_client/client.py:_request:81\", \"message\": \"[cfbdadc56f53] Response response.status_code=200 str_repr_content='{\\\"status\\\":true,\\\"request_id\\\":72}'\", \"extra_data\": {\"status_code\": 200, \"content\": \"{\\\"status\\\":true,\\\"request_id\\\":72}\"}}\n{\"app\": \"dev\", \"level\": \"DEBUG\", \"name\": \"APIClient\", \"date_time\": \"2024-03-09 22:59:25\", \"location\": \"api_client/client.py:_request:71\", \"message\": \"[cfbdadc56f53] Preparing GET request to \\\"https://obligari.serveo.net/ping/local/some-get\\\"\", \"extra_data\": {\"hooks\": {\"response\": []}, \"method\": \"GET\", \"url\": \"https://obligari.serveo.net/ping/local/some-get\", \"headers\": {}, \"files\": [], \"data\": [], \"json\": null, \"params\": {\"variable_one\": \"asd\", \"second_variable\": 123}, \"auth\": null, \"cookies\": null}}\n{\"app\": \"dev\", \"level\": \"INFO\", \"name\": \"APIClient\", \"date_time\": \"2024-03-09 22:59:25\", \"location\": \"api_client/client.py:_request:74\", \"message\": \"[cfbdadc56f53] Sending request with payload=None\", \"extra_data\": {\"payload\": \"{}\"}}\n{\"app\": \"dev\", \"level\": \"INFO\", \"name\": \"APIClient\", \"date_time\": \"2024-03-09 22:59:25\", \"location\": \"api_client/client.py:_request:81\", \"message\": \"[cfbdadc56f53] Response response.status_code=200 str_repr_content='{\\\"status\\\":true,\\\"request_id\\\":74}'\", \"extra_data\": {\"status_code\": 200, \"content\": \"{\\\"status\\\":true,\\\"request_id\\\":73}\"}}\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "API Client Base class",
    "version": "1.1.1",
    "project_urls": {
        "Bug Reports": "https://git.72.lv/eriks/api_client/issues",
        "Funding": "https://donate.pypi.org",
        "Homepage": "https://pypi.org/project/sdlv-api-client/",
        "Source": "https://git.72.lv/eriks/api_client"
    },
    "split_keywords": [
        "api",
        "client",
        "api-client"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "bfc3e2b1e1c25650bd84bff711c638188c62a07872add356b1ba3254568b7cc8",
                "md5": "272dc8d06ac0fedcee56111a72364b26",
                "sha256": "4a8061ccc8dfe54b7ce2bfe22e9890502f23e23ca36bb935901e7b51fd72e37d"
            },
            "downloads": -1,
            "filename": "sdlv_api_client-1.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "272dc8d06ac0fedcee56111a72364b26",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "~=3.10",
            "size": 7993,
            "upload_time": "2024-03-10T16:09:58",
            "upload_time_iso_8601": "2024-03-10T16:09:58.712204Z",
            "url": "https://files.pythonhosted.org/packages/bf/c3/e2b1e1c25650bd84bff711c638188c62a07872add356b1ba3254568b7cc8/sdlv_api_client-1.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "00367a05a536cb05a7875b7a821937b84270cde43c748faa42202454df154d13",
                "md5": "a50c65947178cec98b2bf7ef950b507c",
                "sha256": "1da453b8280e778bf8d21ef0e5273ac5f64adbd717056919aad1bce4092bc939"
            },
            "downloads": -1,
            "filename": "sdlv_api_client-1.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "a50c65947178cec98b2bf7ef950b507c",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "~=3.10",
            "size": 7872,
            "upload_time": "2024-03-10T16:10:00",
            "upload_time_iso_8601": "2024-03-10T16:10:00.505709Z",
            "url": "https://files.pythonhosted.org/packages/00/36/7a05a536cb05a7875b7a821937b84270cde43c748faa42202454df154d13/sdlv_api_client-1.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-03-10 16:10:00",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "sdlv-api-client"
}
        
Elapsed time: 3.17716s