diff options
author | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:08:40 +0000 |
---|---|---|
committer | CoprDistGit <infra@openeuler.org> | 2023-05-05 07:08:40 +0000 |
commit | 72eea12abf5feba971472da863d0a2ff11968df5 (patch) | |
tree | 8d412f8de5619742f23fff01a2c5988ff366eb28 | |
parent | 80a7ff74d0be61890868bcf92342fe850ddb026c (diff) |
automatic import of python-spine-aws-commonopeneuler20.03
-rw-r--r-- | .gitignore | 1 | ||||
-rw-r--r-- | python-spine-aws-common.spec | 371 | ||||
-rw-r--r-- | sources | 1 |
3 files changed, 373 insertions, 0 deletions
@@ -0,0 +1 @@ +/spine_aws_common-0.2.12.tar.gz diff --git a/python-spine-aws-common.spec b/python-spine-aws-common.spec new file mode 100644 index 0000000..92604ab --- /dev/null +++ b/python-spine-aws-common.spec @@ -0,0 +1,371 @@ +%global _empty_manifest_terminate_build 0 +Name: python-spine-aws-common +Version: 0.2.12 +Release: 1 +Summary: NHS Digital Spine Core common AWS code +License: MIT License +URL: https://github.com/NHSDigital/spine-core-aws-common +Source0: https://mirrors.nju.edu.cn/pypi/web/packages/0b/d7/cdbcd22ebb0934919428d4e1bd7519aa79c3ac78c6906fc39643bf2ba564/spine_aws_common-0.2.12.tar.gz +BuildArch: noarch + +Requires: python3-six +Requires: python3-aws-lambda-powertools + +%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 + +```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) +``` + + +%package -n python3-spine-aws-common +Summary: NHS Digital Spine Core common AWS code +Provides: python-spine-aws-common +BuildRequires: python3-devel +BuildRequires: python3-setuptools +BuildRequires: python3-pip +%description -n python3-spine-aws-common +# 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) +``` + + +%package help +Summary: Development documents and examples for spine-aws-common +Provides: python3-spine-aws-common-doc +%description help +# 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) +``` + + +%prep +%autosetup -n spine-aws-common-0.2.12 + +%build +%py3_build + +%install +%py3_install +install -d -m755 %{buildroot}/%{_pkgdocdir} +if [ -d doc ]; then cp -arf doc %{buildroot}/%{_pkgdocdir}; fi +if [ -d docs ]; then cp -arf docs %{buildroot}/%{_pkgdocdir}; fi +if [ -d example ]; then cp -arf example %{buildroot}/%{_pkgdocdir}; fi +if [ -d examples ]; then cp -arf examples %{buildroot}/%{_pkgdocdir}; fi +pushd %{buildroot} +if [ -d usr/lib ]; then + find usr/lib -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/lib64 ]; then + find usr/lib64 -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/bin ]; then + find usr/bin -type f -printf "/%h/%f\n" >> filelist.lst +fi +if [ -d usr/sbin ]; then + find usr/sbin -type f -printf "/%h/%f\n" >> filelist.lst +fi +touch doclist.lst +if [ -d usr/share/man ]; then + find usr/share/man -type f -printf "/%h/%f.gz\n" >> doclist.lst +fi +popd +mv %{buildroot}/filelist.lst . +mv %{buildroot}/doclist.lst . + +%files -n python3-spine-aws-common -f filelist.lst +%dir %{python3_sitelib}/* + +%files help -f doclist.lst +%{_docdir}/* + +%changelog +* Fri May 05 2023 Python_Bot <Python_Bot@openeuler.org> - 0.2.12-1 +- Package Spec generated @@ -0,0 +1 @@ +78b36cb2ed7fd083f4afb206f40c4cd8 spine_aws_common-0.2.12.tar.gz |