aidbox-python-sdk


Nameaidbox-python-sdk JSON
Version 0.1.7 PyPI version JSON
download
home_page
SummaryAidbox SDK for python
upload_time2023-08-12 15:21:14
maintainer
docs_urlNone
author
requires_python>=3.8
licenseMIT License Copyright (c) 2019 Ilya Beda Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
keywords fhir
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![build status](https://github.com/Aidbox/aidbox-python-sdk/actions/workflows/build.yaml/badge.svg)](https://github.com/Aidbox/aidbox-python-sdk/actions/workflows/build.yaml)
[![pypi](https://img.shields.io/pypi/v/aidbox-python-sdk.svg)](https://pypi.org/project/aidbox-python-sdk/)
[![Supported Python version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)

# aidbox-python-sdk

1. Create a python 3.8+ environment `pyenv `
2. Set env variables and activate virtual environment `source activate_settings.sh`
2. Install the required packages with `pipenv install --dev`
3. Make sure the app's settings are configured correctly (see `activate_settings.sh` and `aidbox_python_sdk/settings.py`). You can also
 use environment variables to define sensitive settings, eg. DB connection variables (see example `.env-ptl`)
4. You can then run example with `python example.py`.

Add `APP_FAST_START_MODE=TRUE` to env_tests for fast start mode.

# Getting started
## Minimal application
```Python
from aidbox_python_sdk.main import create_app as _create_app
from aidbox_python_sdk.settings import Settings
from aidbox_python_sdk.sdk import SDK

settings = Settings(**{})
sdk = SDK(settings, resources=resources, seeds=seeds)

async def create_app():
    return await _create_app(sdk)

```

## Register handler for operation
```Python
import logging
from aiohttp import web

from yourappfolder import sdk 


@sdk.operation(
    methods=["POST", "PATCH"],
    path=["signup", "register", {"name": "date"}, {"name": "test"}],
    timeout=60000  ## Optional parameter to set a custom timeout for operation in milliseconds
)
def signup_register_op(operation, request):
    """
    POST /signup/register/21.02.19/testvalue
    PATCH /signup/register/22.02.19/patchtestvalue
    """
    logging.debug("`signup_register_op` operation handler")
    logging.debug("Operation data: %s", operation)
    logging.debug("Request: %s", request)
    return web.json_response({"success": "Ok", "request": request["route-params"]})

```

## Validate request
```Python
schema = {
    "required": ["params", "resource"],
    "properties": {
        "params": {
            "type": "object",
            "required": ["abc", "location"],
            "properties": {"abc": {"type": "string"}, "location": {"type": "string"}},
            "additionalProperties": False,
        },
        "resource": {
            "type": "object",
            "required": ["organizationType", "employeesCount"],
            "properties": {
                "organizationType": {"type": "string", "enum": ["profit", "non-profit"]},
                "employeesCount": {"type": "number"},
            },
            "additionalProperties": False,
        },
    },
}


@sdk.operation(["POST"], ["Organization", {"name": "id"}, "$update"], request_schema=schema)
async def update_organization_handler(operation, request):
    location = request["params"]["location"]
    return web.json_response({"location": location})
```
### Valid request example
```shell
POST /Organization/org-1/$update?abc=xyz&location=us

organizationType: non-profit
employeesCount: 10
```

            

Raw data

            {
    "_id": null,
    "home_page": "",
    "name": "aidbox-python-sdk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": "",
    "keywords": "fhir",
    "author": "",
    "author_email": "\"beda.software\" <aidbox-python-sdk@beda.software>",
    "download_url": "https://files.pythonhosted.org/packages/e7/da/cb3c8ae72cde2f449d7201027795699dd1ed2e6f3e9bcbdbfcef98130d96/aidbox-python-sdk-0.1.7.tar.gz",
    "platform": null,
    "description": "[![build status](https://github.com/Aidbox/aidbox-python-sdk/actions/workflows/build.yaml/badge.svg)](https://github.com/Aidbox/aidbox-python-sdk/actions/workflows/build.yaml)\n[![pypi](https://img.shields.io/pypi/v/aidbox-python-sdk.svg)](https://pypi.org/project/aidbox-python-sdk/)\n[![Supported Python version](https://img.shields.io/badge/python-3.8+-blue.svg)](https://www.python.org/downloads/release/python-380/)\n\n# aidbox-python-sdk\n\n1. Create a python 3.8+ environment `pyenv `\n2. Set env variables and activate virtual environment `source activate_settings.sh`\n2. Install the required packages with `pipenv install --dev`\n3. Make sure the app's settings are configured correctly (see `activate_settings.sh` and `aidbox_python_sdk/settings.py`). You can also\n use environment variables to define sensitive settings, eg. DB connection variables (see example `.env-ptl`)\n4. You can then run example with `python example.py`.\n\nAdd `APP_FAST_START_MODE=TRUE` to env_tests for fast start mode.\n\n# Getting started\n## Minimal application\n```Python\nfrom aidbox_python_sdk.main import create_app as _create_app\nfrom aidbox_python_sdk.settings import Settings\nfrom aidbox_python_sdk.sdk import SDK\n\nsettings = Settings(**{})\nsdk = SDK(settings, resources=resources, seeds=seeds)\n\nasync def create_app():\n    return await _create_app(sdk)\n\n```\n\n## Register handler for operation\n```Python\nimport logging\nfrom aiohttp import web\n\nfrom yourappfolder import sdk \n\n\n@sdk.operation(\n    methods=[\"POST\", \"PATCH\"],\n    path=[\"signup\", \"register\", {\"name\": \"date\"}, {\"name\": \"test\"}],\n    timeout=60000  ## Optional parameter to set a custom timeout for operation in milliseconds\n)\ndef signup_register_op(operation, request):\n    \"\"\"\n    POST /signup/register/21.02.19/testvalue\n    PATCH /signup/register/22.02.19/patchtestvalue\n    \"\"\"\n    logging.debug(\"`signup_register_op` operation handler\")\n    logging.debug(\"Operation data: %s\", operation)\n    logging.debug(\"Request: %s\", request)\n    return web.json_response({\"success\": \"Ok\", \"request\": request[\"route-params\"]})\n\n```\n\n## Validate request\n```Python\nschema = {\n    \"required\": [\"params\", \"resource\"],\n    \"properties\": {\n        \"params\": {\n            \"type\": \"object\",\n            \"required\": [\"abc\", \"location\"],\n            \"properties\": {\"abc\": {\"type\": \"string\"}, \"location\": {\"type\": \"string\"}},\n            \"additionalProperties\": False,\n        },\n        \"resource\": {\n            \"type\": \"object\",\n            \"required\": [\"organizationType\", \"employeesCount\"],\n            \"properties\": {\n                \"organizationType\": {\"type\": \"string\", \"enum\": [\"profit\", \"non-profit\"]},\n                \"employeesCount\": {\"type\": \"number\"},\n            },\n            \"additionalProperties\": False,\n        },\n    },\n}\n\n\n@sdk.operation([\"POST\"], [\"Organization\", {\"name\": \"id\"}, \"$update\"], request_schema=schema)\nasync def update_organization_handler(operation, request):\n    location = request[\"params\"][\"location\"]\n    return web.json_response({\"location\": location})\n```\n### Valid request example\n```shell\nPOST /Organization/org-1/$update?abc=xyz&location=us\n\norganizationType: non-profit\nemployeesCount: 10\n```\n",
    "bugtrack_url": null,
    "license": "MIT License  Copyright (c) 2019 Ilya Beda  Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the \"Software\"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:  The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.  THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ",
    "summary": "Aidbox SDK for python",
    "version": "0.1.7",
    "project_urls": {
        "documentation": "https://github.com/Aidbox/aidbox-python-sdk#readme",
        "homepage": "https://github.com/Aidbox/aidbox-python-sdk",
        "repository": "https://github.com/Aidbox/aidbox-python-sdk.git"
    },
    "split_keywords": [
        "fhir"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "678bcca0656bc09501f0a5e3a0844c478e0c5556d15b45ec8cc28c6ed281f374",
                "md5": "07303dfefcc43ec213721b1189aed542",
                "sha256": "72c8b2d0fa87fefad1a03875ea39670aeedec5acec8d6c5d54f1b00a63a59416"
            },
            "downloads": -1,
            "filename": "aidbox_python_sdk-0.1.7-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "07303dfefcc43ec213721b1189aed542",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 16328,
            "upload_time": "2023-08-12T15:21:12",
            "upload_time_iso_8601": "2023-08-12T15:21:12.785900Z",
            "url": "https://files.pythonhosted.org/packages/67/8b/cca0656bc09501f0a5e3a0844c478e0c5556d15b45ec8cc28c6ed281f374/aidbox_python_sdk-0.1.7-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "e7dacb3c8ae72cde2f449d7201027795699dd1ed2e6f3e9bcbdbfcef98130d96",
                "md5": "541b92f85aa8534db99d0e827c8c6cef",
                "sha256": "06de1ff38f73651eb4ca3b8329e982dca7c4bfccff3318c2e0d77ae4628a8cd7"
            },
            "downloads": -1,
            "filename": "aidbox-python-sdk-0.1.7.tar.gz",
            "has_sig": false,
            "md5_digest": "541b92f85aa8534db99d0e827c8c6cef",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 15842,
            "upload_time": "2023-08-12T15:21:14",
            "upload_time_iso_8601": "2023-08-12T15:21:14.319665Z",
            "url": "https://files.pythonhosted.org/packages/e7/da/cb3c8ae72cde2f449d7201027795699dd1ed2e6f3e9bcbdbfcef98130d96/aidbox-python-sdk-0.1.7.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-12 15:21:14",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Aidbox",
    "github_project": "aidbox-python-sdk#readme",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "aidbox-python-sdk"
}
        
Elapsed time: 0.10183s