lambda-api-decorators 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 Lambda API Decorators
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: lambda-api-decorators
3
+ Version: 0.1.0
4
+ Summary: Python decorators for defining AWS Lambda API routes and configuration.
5
+ Author: Mateo Marcos, Emanuel Arguinarena, Lucas Picchi
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Lambda API Decorators
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/lambda-api-decorators/lambda-api-decorators
29
+ Project-URL: Repository, https://github.com/lambda-api-decorators/lambda-api-decorators
30
+ Project-URL: Bug Reports, https://github.com/lambda-api-decorators/lambda-api-decorators/issues
31
+ Keywords: cdk,lambda,aws,api gateway,ast,decorators
32
+ Classifier: Development Status :: 2 - Pre-Alpha
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: Framework :: AWS CDK :: 2
35
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
36
+ Classifier: Topic :: Software Development :: Build Tools
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Programming Language :: Python :: 3.9
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Requires-Python: >=3.9
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Dynamic: license-file
46
+
47
+ # Lambda API Decorators
48
+
49
+ **Define AWS Lambda API routes and configuration directly in your Python code using decorators.**
50
+
51
+ Lambda API Decorators provides Python decorators for defining API routes and AWS Lambda configuration alongside your Lambda handlers.
52
+
53
+ Instead of maintaining route and function configuration separately from your application code, you can declare HTTP methods, paths, runtimes, timeouts, memory, environment variables, layers, networking, and other Lambda settings directly on the handler.
54
+
55
+ Combined with **Lambda API Decorators CDK**, these definitions are used to automatically generate the corresponding AWS Lambda and Amazon API Gateway infrastructure with AWS CDK.
56
+
57
+ ```python
58
+ from lambda_api_decorators import GET, runtime, name, memory_size
59
+ import json
60
+
61
+
62
+ @GET("/dogs")
63
+ @runtime("python3.11")
64
+ @name("LBD-DOGS-GET")
65
+ @memory_size(256)
66
+ def lambda_handler(event, context):
67
+ return {
68
+ "statusCode": 200,
69
+ "body": json.dumps({
70
+ "message": "Hello World from /dogs!"
71
+ })
72
+ }
73
+ ```
74
+
75
+ ## Installation
76
+
77
+ Install Lambda API Decorators from PyPI:
78
+
79
+ ```bash
80
+ pip install lambda-api-decorators
81
+ ```
82
+
83
+ To generate AWS infrastructure from the decorated Lambda handlers, install the CDK integration:
84
+
85
+ ```bash
86
+ pip install lambda-api-decorators-cdk
87
+ ```
88
+
89
+ ## Available Decorators
90
+
91
+ ### API Routes
92
+
93
+ Every Lambda API handler must define an HTTP method and endpoint path.
94
+
95
+ Available route decorators:
96
+
97
+ * `GET`
98
+ * `POST`
99
+ * `PUT`
100
+ * `DELETE`
101
+ * `ANY`
102
+
103
+ For example:
104
+
105
+ ```python
106
+ @GET("/dogs")
107
+ def lambda_handler(event, context):
108
+ ...
109
+ ```
110
+
111
+ The route definition is used by the CDK integration to configure the corresponding Amazon API Gateway endpoint and Lambda integration.
112
+
113
+ ### Lambda Configuration
114
+
115
+ Lambda API Decorators also allows Lambda configuration to be declared directly on the handler.
116
+
117
+ #### `timeout`
118
+
119
+ Defines the Lambda function timeout in seconds.
120
+
121
+ ```python
122
+ @timeout(30)
123
+ ```
124
+
125
+ #### `memory_size`
126
+
127
+ Defines the amount of memory allocated to the Lambda function.
128
+
129
+ ```python
130
+ @memory_size(512)
131
+ ```
132
+
133
+ #### `name`
134
+
135
+ Defines a custom name for the Lambda function.
136
+
137
+ ```python
138
+ @name("LBD-DOGS-GET")
139
+ ```
140
+
141
+ #### `description`
142
+
143
+ Defines the Lambda function description.
144
+
145
+ ```python
146
+ @description("Returns the list of dogs")
147
+ ```
148
+
149
+ #### `runtime`
150
+
151
+ References a runtime configuration defined by Lambda API Decorators CDK.
152
+
153
+ ```python
154
+ @runtime("python3.11")
155
+ ```
156
+
157
+ #### `role`
158
+
159
+ References an IAM role defined by Lambda API Decorators CDK.
160
+
161
+ ```python
162
+ @role("api-role")
163
+ ```
164
+
165
+ #### `vpc`
166
+
167
+ References a VPC configuration defined by Lambda API Decorators CDK.
168
+
169
+ ```python
170
+ @vpc("application-vpc")
171
+ ```
172
+
173
+ #### `environment`
174
+
175
+ Associates one or more environment configurations with the Lambda function.
176
+
177
+ ```python
178
+ @environment("database", "application")
179
+ ```
180
+
181
+ #### `layer`
182
+
183
+ Associates one or more Lambda Layers with the function.
184
+
185
+ ```python
186
+ @layer("common-dependencies")
187
+ ```
188
+
189
+ #### `security_group`
190
+
191
+ Associates one or more security group configurations with the Lambda function.
192
+
193
+ ```python
194
+ @security_group("lambda-security-group")
195
+ ```
196
+
197
+ The referenced runtimes, IAM roles, VPCs, environment configurations, layers, and security groups are defined in the AWS CDK application using **Lambda API Decorators CDK**.
198
+
199
+ ## How It Works
200
+
201
+ Lambda API Decorators keeps API and Lambda configuration close to the application code:
202
+
203
+ ```text
204
+ Python Lambda handlers
205
+
206
+ │ @GET, @POST, @runtime,
207
+ │ @timeout, @memory_size, ...
208
+
209
+ Lambda API Decorators
210
+
211
+
212
+ Lambda API Decorators CDK
213
+
214
+
215
+ AWS CDK
216
+
217
+ ├── AWS Lambda
218
+ ├── Amazon API Gateway
219
+ ├── IAM
220
+ ├── VPC configuration
221
+ └── other AWS resources
222
+ ```
223
+
224
+ This allows your Lambda handlers to become the source of the API definition while AWS CDK remains responsible for generating and deploying the infrastructure.
225
+
226
+ ## Related Projects
227
+
228
+ * **Lambda API Decorators CDK** — AWS CDK integration that generates Lambda and API Gateway infrastructure from decorated Python handlers.
229
+ * **Lambda API Decorators Examples** — Example applications demonstrating how to use Lambda API Decorators.
230
+
231
+ ## License
232
+
233
+ See the repository license for details.
@@ -0,0 +1,187 @@
1
+ # Lambda API Decorators
2
+
3
+ **Define AWS Lambda API routes and configuration directly in your Python code using decorators.**
4
+
5
+ Lambda API Decorators provides Python decorators for defining API routes and AWS Lambda configuration alongside your Lambda handlers.
6
+
7
+ Instead of maintaining route and function configuration separately from your application code, you can declare HTTP methods, paths, runtimes, timeouts, memory, environment variables, layers, networking, and other Lambda settings directly on the handler.
8
+
9
+ Combined with **Lambda API Decorators CDK**, these definitions are used to automatically generate the corresponding AWS Lambda and Amazon API Gateway infrastructure with AWS CDK.
10
+
11
+ ```python
12
+ from lambda_api_decorators import GET, runtime, name, memory_size
13
+ import json
14
+
15
+
16
+ @GET("/dogs")
17
+ @runtime("python3.11")
18
+ @name("LBD-DOGS-GET")
19
+ @memory_size(256)
20
+ def lambda_handler(event, context):
21
+ return {
22
+ "statusCode": 200,
23
+ "body": json.dumps({
24
+ "message": "Hello World from /dogs!"
25
+ })
26
+ }
27
+ ```
28
+
29
+ ## Installation
30
+
31
+ Install Lambda API Decorators from PyPI:
32
+
33
+ ```bash
34
+ pip install lambda-api-decorators
35
+ ```
36
+
37
+ To generate AWS infrastructure from the decorated Lambda handlers, install the CDK integration:
38
+
39
+ ```bash
40
+ pip install lambda-api-decorators-cdk
41
+ ```
42
+
43
+ ## Available Decorators
44
+
45
+ ### API Routes
46
+
47
+ Every Lambda API handler must define an HTTP method and endpoint path.
48
+
49
+ Available route decorators:
50
+
51
+ * `GET`
52
+ * `POST`
53
+ * `PUT`
54
+ * `DELETE`
55
+ * `ANY`
56
+
57
+ For example:
58
+
59
+ ```python
60
+ @GET("/dogs")
61
+ def lambda_handler(event, context):
62
+ ...
63
+ ```
64
+
65
+ The route definition is used by the CDK integration to configure the corresponding Amazon API Gateway endpoint and Lambda integration.
66
+
67
+ ### Lambda Configuration
68
+
69
+ Lambda API Decorators also allows Lambda configuration to be declared directly on the handler.
70
+
71
+ #### `timeout`
72
+
73
+ Defines the Lambda function timeout in seconds.
74
+
75
+ ```python
76
+ @timeout(30)
77
+ ```
78
+
79
+ #### `memory_size`
80
+
81
+ Defines the amount of memory allocated to the Lambda function.
82
+
83
+ ```python
84
+ @memory_size(512)
85
+ ```
86
+
87
+ #### `name`
88
+
89
+ Defines a custom name for the Lambda function.
90
+
91
+ ```python
92
+ @name("LBD-DOGS-GET")
93
+ ```
94
+
95
+ #### `description`
96
+
97
+ Defines the Lambda function description.
98
+
99
+ ```python
100
+ @description("Returns the list of dogs")
101
+ ```
102
+
103
+ #### `runtime`
104
+
105
+ References a runtime configuration defined by Lambda API Decorators CDK.
106
+
107
+ ```python
108
+ @runtime("python3.11")
109
+ ```
110
+
111
+ #### `role`
112
+
113
+ References an IAM role defined by Lambda API Decorators CDK.
114
+
115
+ ```python
116
+ @role("api-role")
117
+ ```
118
+
119
+ #### `vpc`
120
+
121
+ References a VPC configuration defined by Lambda API Decorators CDK.
122
+
123
+ ```python
124
+ @vpc("application-vpc")
125
+ ```
126
+
127
+ #### `environment`
128
+
129
+ Associates one or more environment configurations with the Lambda function.
130
+
131
+ ```python
132
+ @environment("database", "application")
133
+ ```
134
+
135
+ #### `layer`
136
+
137
+ Associates one or more Lambda Layers with the function.
138
+
139
+ ```python
140
+ @layer("common-dependencies")
141
+ ```
142
+
143
+ #### `security_group`
144
+
145
+ Associates one or more security group configurations with the Lambda function.
146
+
147
+ ```python
148
+ @security_group("lambda-security-group")
149
+ ```
150
+
151
+ The referenced runtimes, IAM roles, VPCs, environment configurations, layers, and security groups are defined in the AWS CDK application using **Lambda API Decorators CDK**.
152
+
153
+ ## How It Works
154
+
155
+ Lambda API Decorators keeps API and Lambda configuration close to the application code:
156
+
157
+ ```text
158
+ Python Lambda handlers
159
+
160
+ │ @GET, @POST, @runtime,
161
+ │ @timeout, @memory_size, ...
162
+
163
+ Lambda API Decorators
164
+
165
+
166
+ Lambda API Decorators CDK
167
+
168
+
169
+ AWS CDK
170
+
171
+ ├── AWS Lambda
172
+ ├── Amazon API Gateway
173
+ ├── IAM
174
+ ├── VPC configuration
175
+ └── other AWS resources
176
+ ```
177
+
178
+ This allows your Lambda handlers to become the source of the API definition while AWS CDK remains responsible for generating and deploying the infrastructure.
179
+
180
+ ## Related Projects
181
+
182
+ * **Lambda API Decorators CDK** — AWS CDK integration that generates Lambda and API Gateway infrastructure from decorated Python handlers.
183
+ * **Lambda API Decorators Examples** — Example applications demonstrating how to use Lambda API Decorators.
184
+
185
+ ## License
186
+
187
+ See the repository license for details.
@@ -0,0 +1,97 @@
1
+ # Guide (user-friendly):
2
+ # https://packaging.python.org/en/latest/guides/writing-pyproject-toml/
3
+
4
+ # Specification (technical, formal):
5
+ # https://packaging.python.org/en/latest/specifications/pyproject-toml/
6
+
7
+
8
+ # Choosing a build backend:
9
+ # https://packaging.python.org/en/latest/tutorials/packaging-projects/#choosing-a-build-backend
10
+ [build-system]
11
+ # A list of packages that are needed to build your package:
12
+ requires = ["setuptools"] # REQUIRED if [build-system] table is used
13
+ # The name of the Python object that frontends will use to perform the build:
14
+ build-backend = "setuptools.build_meta" # If not defined, then legacy behavior can happen.
15
+
16
+
17
+ [project]
18
+ # https://packaging.python.org/specifications/core-metadata/#name
19
+ name = "lambda-api-decorators"
20
+ # https://packaging.python.org/guides/single-sourcing-package-version/
21
+ version = "0.1.0"
22
+
23
+ # https://packaging.python.org/specifications/core-metadata/#summary
24
+ description = "Python decorators for defining AWS Lambda API routes and configuration."
25
+
26
+ # https://packaging.python.org/specifications/core-metadata/#description-optional
27
+ readme = "README.md"
28
+
29
+ # https://packaging.python.org/guides/distributing-packages-using-setuptools/#python-requires
30
+ requires-python = ">=3.9"
31
+
32
+
33
+ # https://packaging.python.org/en/latest/specifications/core-metadata/#license
34
+ license = {file = "LICENSE"}
35
+
36
+ keywords = ["cdk", "lambda", "aws", "api gateway", "ast", "decorators"]
37
+
38
+ authors = [
39
+ {name = "Mateo Marcos"},
40
+ {name = "Emanuel Arguinarena"},
41
+ {name = "Lucas Picchi"}
42
+ ]
43
+
44
+ #maintainers = [
45
+ # {name = "A. Great Maintainer", email = "maintainer@example.com" }
46
+ #]
47
+
48
+
49
+ # For a list of valid classifiers, see https://pypi.org/classifiers/
50
+ classifiers = [
51
+ 'Development Status :: 2 - Pre-Alpha',
52
+ 'Intended Audience :: Developers',
53
+ 'Framework :: AWS CDK :: 2',
54
+ 'Topic :: Software Development :: Libraries :: Python Modules',
55
+ 'Topic :: Software Development :: Build Tools',
56
+ 'License :: OSI Approved :: MIT License',
57
+ 'Programming Language :: Python :: 3.9',
58
+ 'Programming Language :: Python :: 3.10',
59
+ 'Programming Language :: Python :: 3.11',
60
+ 'Programming Language :: Python :: 3.12'
61
+ ]
62
+
63
+ # For an analysis of this field vs pip's requirements files see:
64
+ # https://packaging.python.org/discussions/install-requires-vs-requirements/
65
+ dependencies = [
66
+ ]
67
+
68
+
69
+ # https://packaging.python.org/en/latest/specifications/dependency-specifiers/#extras
70
+ #[project.optional-dependencies]
71
+ #dev = ["check-manifest"]
72
+ #test = ["coverage"]
73
+
74
+ # List URLs that are relevant to your project
75
+ #
76
+ # This field corresponds to the "Project-URL" and "Home-Page" metadata fields:
77
+ # https://packaging.python.org/specifications/core-metadata/#project-url-multiple-use
78
+ # https://packaging.python.org/specifications/core-metadata/#home-page-optional
79
+ #
80
+ # Examples listed include a pattern for specifying where the package tracks
81
+ # issues, where the source is hosted, where to say thanks to the package
82
+ # maintainers, and where to support the project financially. The key is
83
+ # what's used to render the link text on PyPI.
84
+ [project.urls]
85
+ Homepage = "https://github.com/lambda-api-decorators/lambda-api-decorators"
86
+ Repository = "https://github.com/lambda-api-decorators/lambda-api-decorators"
87
+ "Bug Reports" = "https://github.com/lambda-api-decorators/lambda-api-decorators/issues"
88
+
89
+ # The following would provide a command line executable called `sample`
90
+ # which executes the function `main` from this package when invoked.
91
+ #[project.scripts]
92
+ #sample = "sample:main"
93
+
94
+
95
+ # This is configuration specific to the `setuptools` build backend.
96
+ # If you are using a different build backend, you will need to change this.
97
+ [tool.setuptools]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1 @@
1
+ from .decorators import *
@@ -0,0 +1,119 @@
1
+ def GET(path):
2
+ def decorator(fun):
3
+ def wrapper(*args, **kwargs):
4
+ result = fun(*args, **kwargs)
5
+ return result
6
+ return wrapper
7
+ return decorator
8
+
9
+ def PUT(path):
10
+ def decorator(fun):
11
+ def wrapper(*args, **kwargs):
12
+ result = fun(*args, **kwargs)
13
+ return result
14
+ return wrapper
15
+ return decorator
16
+
17
+ def POST(path):
18
+ def decorator(fun):
19
+ def wrapper(*args, **kwargs):
20
+ result = fun(*args, **kwargs)
21
+ return result
22
+ return wrapper
23
+ return decorator
24
+
25
+ def DELETE(path):
26
+ def decorator(fun):
27
+ def wrapper(*args, **kwargs):
28
+ result = fun(*args, **kwargs)
29
+ return result
30
+ return wrapper
31
+ return decorator
32
+
33
+ def ANY(path):
34
+ def decorator(fun):
35
+ def wrapper(*args, **kwargs):
36
+ result = fun(*args, **kwargs)
37
+ return result
38
+ return wrapper
39
+ return decorator
40
+
41
+ def memory_size(arg):
42
+ def decorator(fun):
43
+ def wrapper(*args, **kwargs):
44
+ result = fun(*args, **kwargs)
45
+ return result
46
+ return wrapper
47
+ return decorator
48
+
49
+ def timeout(arg):
50
+ def decorator(fun):
51
+ def wrapper(*args, **kwargs):
52
+ result = fun(*args, **kwargs)
53
+ return result
54
+ return wrapper
55
+ return decorator
56
+
57
+ def environment(*eargs, **kwargs):
58
+ def decorator(fun):
59
+ def wrapper(*args, **kwargs):
60
+ result = fun(*args, **kwargs)
61
+ return result
62
+ return wrapper
63
+ return decorator
64
+
65
+ def layer(*largs, **kwargs):
66
+ def decorator(fun):
67
+ def wrapper(*args, **kwargs):
68
+ result = fun(*args, **kwargs)
69
+ return result
70
+ return wrapper
71
+ return decorator
72
+
73
+ def runtime(arg):
74
+ def decorator(fun):
75
+ def wrapper(*args, **kwargs):
76
+ result = fun(*args, **kwargs)
77
+ return result
78
+ return wrapper
79
+ return decorator
80
+
81
+ def security_group(*sgargs):
82
+ def decorator(fun):
83
+ def wrapper(*wargs, **kwargs):
84
+ result = fun(*wargs, **kwargs)
85
+ return result
86
+ return wrapper
87
+ return decorator
88
+
89
+ def vpc(arg):
90
+ def decorator(fun):
91
+ def wrapper(*args, **kwargs):
92
+ result = fun(*args, **kwargs)
93
+ return result
94
+ return wrapper
95
+ return decorator
96
+
97
+ def role(arg):
98
+ def decorator(fun):
99
+ def wrapper(*args, **kwargs):
100
+ result = fun(*args, **kwargs)
101
+ return result
102
+ return wrapper
103
+ return decorator
104
+
105
+ def description(arg):
106
+ def decorator(fun):
107
+ def wrapper(*args, **kwargs):
108
+ result = fun(*args, **kwargs)
109
+ return result
110
+ return wrapper
111
+ return decorator
112
+
113
+ def name(arg):
114
+ def decorator(fun):
115
+ def wrapper(*args, **kwargs):
116
+ result = fun(*args, **kwargs)
117
+ return result
118
+ return wrapper
119
+ return decorator
@@ -0,0 +1,233 @@
1
+ Metadata-Version: 2.4
2
+ Name: lambda-api-decorators
3
+ Version: 0.1.0
4
+ Summary: Python decorators for defining AWS Lambda API routes and configuration.
5
+ Author: Mateo Marcos, Emanuel Arguinarena, Lucas Picchi
6
+ License: MIT License
7
+
8
+ Copyright (c) 2024 Lambda API Decorators
9
+
10
+ Permission is hereby granted, free of charge, to any person obtaining a copy
11
+ of this software and associated documentation files (the "Software"), to deal
12
+ in the Software without restriction, including without limitation the rights
13
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
14
+ copies of the Software, and to permit persons to whom the Software is
15
+ furnished to do so, subject to the following conditions:
16
+
17
+ The above copyright notice and this permission notice shall be included in all
18
+ copies or substantial portions of the Software.
19
+
20
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
21
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
22
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
23
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
24
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
25
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
+ SOFTWARE.
27
+
28
+ Project-URL: Homepage, https://github.com/lambda-api-decorators/lambda-api-decorators
29
+ Project-URL: Repository, https://github.com/lambda-api-decorators/lambda-api-decorators
30
+ Project-URL: Bug Reports, https://github.com/lambda-api-decorators/lambda-api-decorators/issues
31
+ Keywords: cdk,lambda,aws,api gateway,ast,decorators
32
+ Classifier: Development Status :: 2 - Pre-Alpha
33
+ Classifier: Intended Audience :: Developers
34
+ Classifier: Framework :: AWS CDK :: 2
35
+ Classifier: Topic :: Software Development :: Libraries :: Python Modules
36
+ Classifier: Topic :: Software Development :: Build Tools
37
+ Classifier: License :: OSI Approved :: MIT License
38
+ Classifier: Programming Language :: Python :: 3.9
39
+ Classifier: Programming Language :: Python :: 3.10
40
+ Classifier: Programming Language :: Python :: 3.11
41
+ Classifier: Programming Language :: Python :: 3.12
42
+ Requires-Python: >=3.9
43
+ Description-Content-Type: text/markdown
44
+ License-File: LICENSE
45
+ Dynamic: license-file
46
+
47
+ # Lambda API Decorators
48
+
49
+ **Define AWS Lambda API routes and configuration directly in your Python code using decorators.**
50
+
51
+ Lambda API Decorators provides Python decorators for defining API routes and AWS Lambda configuration alongside your Lambda handlers.
52
+
53
+ Instead of maintaining route and function configuration separately from your application code, you can declare HTTP methods, paths, runtimes, timeouts, memory, environment variables, layers, networking, and other Lambda settings directly on the handler.
54
+
55
+ Combined with **Lambda API Decorators CDK**, these definitions are used to automatically generate the corresponding AWS Lambda and Amazon API Gateway infrastructure with AWS CDK.
56
+
57
+ ```python
58
+ from lambda_api_decorators import GET, runtime, name, memory_size
59
+ import json
60
+
61
+
62
+ @GET("/dogs")
63
+ @runtime("python3.11")
64
+ @name("LBD-DOGS-GET")
65
+ @memory_size(256)
66
+ def lambda_handler(event, context):
67
+ return {
68
+ "statusCode": 200,
69
+ "body": json.dumps({
70
+ "message": "Hello World from /dogs!"
71
+ })
72
+ }
73
+ ```
74
+
75
+ ## Installation
76
+
77
+ Install Lambda API Decorators from PyPI:
78
+
79
+ ```bash
80
+ pip install lambda-api-decorators
81
+ ```
82
+
83
+ To generate AWS infrastructure from the decorated Lambda handlers, install the CDK integration:
84
+
85
+ ```bash
86
+ pip install lambda-api-decorators-cdk
87
+ ```
88
+
89
+ ## Available Decorators
90
+
91
+ ### API Routes
92
+
93
+ Every Lambda API handler must define an HTTP method and endpoint path.
94
+
95
+ Available route decorators:
96
+
97
+ * `GET`
98
+ * `POST`
99
+ * `PUT`
100
+ * `DELETE`
101
+ * `ANY`
102
+
103
+ For example:
104
+
105
+ ```python
106
+ @GET("/dogs")
107
+ def lambda_handler(event, context):
108
+ ...
109
+ ```
110
+
111
+ The route definition is used by the CDK integration to configure the corresponding Amazon API Gateway endpoint and Lambda integration.
112
+
113
+ ### Lambda Configuration
114
+
115
+ Lambda API Decorators also allows Lambda configuration to be declared directly on the handler.
116
+
117
+ #### `timeout`
118
+
119
+ Defines the Lambda function timeout in seconds.
120
+
121
+ ```python
122
+ @timeout(30)
123
+ ```
124
+
125
+ #### `memory_size`
126
+
127
+ Defines the amount of memory allocated to the Lambda function.
128
+
129
+ ```python
130
+ @memory_size(512)
131
+ ```
132
+
133
+ #### `name`
134
+
135
+ Defines a custom name for the Lambda function.
136
+
137
+ ```python
138
+ @name("LBD-DOGS-GET")
139
+ ```
140
+
141
+ #### `description`
142
+
143
+ Defines the Lambda function description.
144
+
145
+ ```python
146
+ @description("Returns the list of dogs")
147
+ ```
148
+
149
+ #### `runtime`
150
+
151
+ References a runtime configuration defined by Lambda API Decorators CDK.
152
+
153
+ ```python
154
+ @runtime("python3.11")
155
+ ```
156
+
157
+ #### `role`
158
+
159
+ References an IAM role defined by Lambda API Decorators CDK.
160
+
161
+ ```python
162
+ @role("api-role")
163
+ ```
164
+
165
+ #### `vpc`
166
+
167
+ References a VPC configuration defined by Lambda API Decorators CDK.
168
+
169
+ ```python
170
+ @vpc("application-vpc")
171
+ ```
172
+
173
+ #### `environment`
174
+
175
+ Associates one or more environment configurations with the Lambda function.
176
+
177
+ ```python
178
+ @environment("database", "application")
179
+ ```
180
+
181
+ #### `layer`
182
+
183
+ Associates one or more Lambda Layers with the function.
184
+
185
+ ```python
186
+ @layer("common-dependencies")
187
+ ```
188
+
189
+ #### `security_group`
190
+
191
+ Associates one or more security group configurations with the Lambda function.
192
+
193
+ ```python
194
+ @security_group("lambda-security-group")
195
+ ```
196
+
197
+ The referenced runtimes, IAM roles, VPCs, environment configurations, layers, and security groups are defined in the AWS CDK application using **Lambda API Decorators CDK**.
198
+
199
+ ## How It Works
200
+
201
+ Lambda API Decorators keeps API and Lambda configuration close to the application code:
202
+
203
+ ```text
204
+ Python Lambda handlers
205
+
206
+ │ @GET, @POST, @runtime,
207
+ │ @timeout, @memory_size, ...
208
+
209
+ Lambda API Decorators
210
+
211
+
212
+ Lambda API Decorators CDK
213
+
214
+
215
+ AWS CDK
216
+
217
+ ├── AWS Lambda
218
+ ├── Amazon API Gateway
219
+ ├── IAM
220
+ ├── VPC configuration
221
+ └── other AWS resources
222
+ ```
223
+
224
+ This allows your Lambda handlers to become the source of the API definition while AWS CDK remains responsible for generating and deploying the infrastructure.
225
+
226
+ ## Related Projects
227
+
228
+ * **Lambda API Decorators CDK** — AWS CDK integration that generates Lambda and API Gateway infrastructure from decorated Python handlers.
229
+ * **Lambda API Decorators Examples** — Example applications demonstrating how to use Lambda API Decorators.
230
+
231
+ ## License
232
+
233
+ See the repository license for details.
@@ -0,0 +1,9 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ src/lambda_api_decorators/__init__.py
5
+ src/lambda_api_decorators/decorators.py
6
+ src/lambda_api_decorators.egg-info/PKG-INFO
7
+ src/lambda_api_decorators.egg-info/SOURCES.txt
8
+ src/lambda_api_decorators.egg-info/dependency_links.txt
9
+ src/lambda_api_decorators.egg-info/top_level.txt