NHS Digital Spine Core common AWS code
Project description
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
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
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)
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file spine_aws_common-0.2.14.tar.gz.
File metadata
- Download URL: spine_aws_common-0.2.14.tar.gz
- Upload date:
- Size: 31.0 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
91babe73cf82e8122cb7d86952c9ae76039e3073dee0a65b04c664808f975956
|
|
| MD5 |
0839408a75db15ea11952340bd2760c2
|
|
| BLAKE2b-256 |
5f5b50d67113beb0119c72883d37690cd4c64eb2be8da5e6a7cdf22631580d06
|
File details
Details for the file spine_aws_common-0.2.14-py3-none-any.whl.
File metadata
- Download URL: spine_aws_common-0.2.14-py3-none-any.whl
- Upload date:
- Size: 44.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/4.0.2 CPython/3.9.18
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8f983766484c802583a0b39017cee75b11f0c0396dd3fa56ddd800fbf22261a8
|
|
| MD5 |
3dccffdfd12a25bd353edc72e37eaf37
|
|
| BLAKE2b-256 |
9a06dd9feaa89ce1ce6fcd603a83ed2eb69ca496de6bc0855ad24ad2846fc02f
|