spine-aws-common


Namespine-aws-common JSON
Version 0.2.14 PyPI version JSON
download
home_pagehttps://github.com/NHSDigital/spine-core-aws-common
SummaryNHS Digital Spine Core common AWS code
upload_time2023-09-11 09:56:36
maintainer
docs_urlNone
authorNHS Digital
requires_python>=3.6
license
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # spine-core-aws-common

Common code used across Spine projects in AWS

## Installation

Simply add the pre-built package to your python environment.

The latest version can be obtained with the following curl command if your system has it present:

```
package_version=$(curl -SL https://github.com/NHSDigital/spine-core-aws-common/releases/latest | grep -Po 'Release v\K(\d+.\d+.\d+)' | head -n1)
```

Or you can set a specific version:

```
package_version="0.2.3"
```

Alternatively the main page of this repo will display the latest version i.e. 0.2.3, and previous versions can be searched, which you can substitute in place of `${package_version}` in the below commands.

### PIP

```
pip install https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl
```

### requirements.txt

```
https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl
```

### Poetry

```
poetry add https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl
```

## Usage

TBC

Quick example

```python
from spine_aws_common import LambdaApplication

class MyApp(LambdaApplication):
    def initialise(self):
        # initialise
        return

    def start(self):
        # do actual work
        # to set response for the lambda
        self.response = '{"my new response":true}'
        return

# create instance of class in global space
# this ensures initial setup of logging/config is only done on cold start
app = MyApp(additional_log_config='/path/to/mylogconfig.cfg')

def lambda_handler(event, context):
    return app.main(event, context)
```

API Gateway example

```python
from spine_aws_common import APIGatewayApplication
from aws_lambda_powertools.event_handler.api_gateway import Response

class MyApp(APIGatewayApplication):
    def get_hello(self):
        return Response(
            status_code=200, content_type="application/json", body='{"hello":"world"}'
        )

    def get_id(self, _id):
        response_dict = {"id": _id}
        return Response(
            status_code=200,
            content_type="application/json",
            body=json.dumps(response_dict),
        )

    def configure_routes(self):
        self._add_route(self.get_hello, "/hello")
        self._add_route(self.get_id, "/id/<_id>")

# create instance of class in global space
# this ensures initial setup of logging/config is only done on cold start
app = MyApp(additional_log_config='/path/to/mylogconfig.cfg')

def lambda_handler(event, context):
    return app.main(event, context)
```

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/NHSDigital/spine-core-aws-common",
    "name": "spine-aws-common",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.6",
    "maintainer_email": "",
    "keywords": "",
    "author": "NHS Digital",
    "author_email": "devops.core@nhs.net",
    "download_url": "https://files.pythonhosted.org/packages/5f/5b/50d67113beb0119c72883d37690cd4c64eb2be8da5e6a7cdf22631580d06/spine_aws_common-0.2.14.tar.gz",
    "platform": null,
    "description": "# spine-core-aws-common\n\nCommon code used across Spine projects in AWS\n\n## Installation\n\nSimply add the pre-built package to your python environment.\n\nThe latest version can be obtained with the following curl command if your system has it present:\n\n```\npackage_version=$(curl -SL https://github.com/NHSDigital/spine-core-aws-common/releases/latest | grep -Po 'Release v\\K(\\d+.\\d+.\\d+)' | head -n1)\n```\n\nOr you can set a specific version:\n\n```\npackage_version=\"0.2.3\"\n```\n\nAlternatively the main page of this repo will display the latest version i.e. 0.2.3, and previous versions can be searched, which you can substitute in place of `${package_version}` in the below commands.\n\n### PIP\n\n```\npip install https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl\n```\n\n### requirements.txt\n\n```\nhttps://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl\n```\n\n### Poetry\n\n```\npoetry add https://github.com/NHSDigital/spine-core-aws-common/releases/download/v${package_version}/spine_aws_common-${package_version}-py3-none-any.whl\n```\n\n## Usage\n\nTBC\n\nQuick example\n\n```python\nfrom spine_aws_common import LambdaApplication\n\nclass MyApp(LambdaApplication):\n    def initialise(self):\n        # initialise\n        return\n\n    def start(self):\n        # do actual work\n        # to set response for the lambda\n        self.response = '{\"my new response\":true}'\n        return\n\n# create instance of class in global space\n# this ensures initial setup of logging/config is only done on cold start\napp = MyApp(additional_log_config='/path/to/mylogconfig.cfg')\n\ndef lambda_handler(event, context):\n    return app.main(event, context)\n```\n\nAPI Gateway example\n\n```python\nfrom spine_aws_common import APIGatewayApplication\nfrom aws_lambda_powertools.event_handler.api_gateway import Response\n\nclass MyApp(APIGatewayApplication):\n    def get_hello(self):\n        return Response(\n            status_code=200, content_type=\"application/json\", body='{\"hello\":\"world\"}'\n        )\n\n    def get_id(self, _id):\n        response_dict = {\"id\": _id}\n        return Response(\n            status_code=200,\n            content_type=\"application/json\",\n            body=json.dumps(response_dict),\n        )\n\n    def configure_routes(self):\n        self._add_route(self.get_hello, \"/hello\")\n        self._add_route(self.get_id, \"/id/<_id>\")\n\n# create instance of class in global space\n# this ensures initial setup of logging/config is only done on cold start\napp = MyApp(additional_log_config='/path/to/mylogconfig.cfg')\n\ndef lambda_handler(event, context):\n    return app.main(event, context)\n```\n",
    "bugtrack_url": null,
    "license": "",
    "summary": "NHS Digital Spine Core common AWS code",
    "version": "0.2.14",
    "project_urls": {
        "Bug Tracker": "https://github.com/NHSDigital/spine-core-aws-common/issues",
        "Homepage": "https://github.com/NHSDigital/spine-core-aws-common"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "9a06dd9feaa89ce1ce6fcd603a83ed2eb69ca496de6bc0855ad24ad2846fc02f",
                "md5": "3dccffdfd12a25bd353edc72e37eaf37",
                "sha256": "8f983766484c802583a0b39017cee75b11f0c0396dd3fa56ddd800fbf22261a8"
            },
            "downloads": -1,
            "filename": "spine_aws_common-0.2.14-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "3dccffdfd12a25bd353edc72e37eaf37",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.6",
            "size": 44723,
            "upload_time": "2023-09-11T09:56:35",
            "upload_time_iso_8601": "2023-09-11T09:56:35.766093Z",
            "url": "https://files.pythonhosted.org/packages/9a/06/dd9feaa89ce1ce6fcd603a83ed2eb69ca496de6bc0855ad24ad2846fc02f/spine_aws_common-0.2.14-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5f5b50d67113beb0119c72883d37690cd4c64eb2be8da5e6a7cdf22631580d06",
                "md5": "0839408a75db15ea11952340bd2760c2",
                "sha256": "91babe73cf82e8122cb7d86952c9ae76039e3073dee0a65b04c664808f975956"
            },
            "downloads": -1,
            "filename": "spine_aws_common-0.2.14.tar.gz",
            "has_sig": false,
            "md5_digest": "0839408a75db15ea11952340bd2760c2",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.6",
            "size": 31044,
            "upload_time": "2023-09-11T09:56:36",
            "upload_time_iso_8601": "2023-09-11T09:56:36.844524Z",
            "url": "https://files.pythonhosted.org/packages/5f/5b/50d67113beb0119c72883d37690cd4c64eb2be8da5e6a7cdf22631580d06/spine_aws_common-0.2.14.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-09-11 09:56:36",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "NHSDigital",
    "github_project": "spine-core-aws-common",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "tox": true,
    "lcname": "spine-aws-common"
}
        
Elapsed time: 0.12337s