wellapi 0.3.7__tar.gz → 0.3.8__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.
- {wellapi-0.3.7 → wellapi-0.3.8}/PKG-INFO +1 -1
- {wellapi-0.3.7 → wellapi-0.3.8}/pyproject.toml +1 -1
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/build/cdk.py +27 -2
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/openapi/utils.py +7 -2
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/utils.py +1 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/uv.lock +1 -1
- {wellapi-0.3.7 → wellapi-0.3.8}/.github/workflows/build.pipeline.yml +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/.gitignore +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/.python-version +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/README.md +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/__init__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/__main__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/applications.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/build/__init__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/build/packager.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/cli/__init__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/cli/main.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/convertors.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/datastructures.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/dependencies/__init__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/dependencies/models.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/dependencies/utils.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/exceptions.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/local/__init__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/local/reloader.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/local/router.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/local/server.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/middleware/__init__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/middleware/base.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/middleware/error.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/middleware/exceptions.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/middleware/main.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/models.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/openapi/__init__.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/openapi/docs.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/openapi/models.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/params.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/routing.py +0 -0
- {wellapi-0.3.7 → wellapi-0.3.8}/src/wellapi/security.py +0 -0
|
@@ -52,7 +52,20 @@ class WellApiCDK(Construct):
|
|
|
52
52
|
self.app_srt = app_srt
|
|
53
53
|
self.handlers_dir = os.path.abspath(handlers_dir)
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
api_role = iam.Role(
|
|
56
|
+
self,
|
|
57
|
+
"ApiRole",
|
|
58
|
+
assumed_by=iam.ServicePrincipal("apigateway.amazonaws.com"),
|
|
59
|
+
role_name="ApiRole",
|
|
60
|
+
)
|
|
61
|
+
api_role.add_to_policy(
|
|
62
|
+
iam.PolicyStatement(
|
|
63
|
+
actions=["lambda:InvokeFunction"],
|
|
64
|
+
resources=["*"],
|
|
65
|
+
)
|
|
66
|
+
)
|
|
67
|
+
|
|
68
|
+
wellapi_app: WellApi = self._package_app(cors=cors, api_role_arn=api_role.role_arn)
|
|
56
69
|
|
|
57
70
|
self._create_api(wellapi_app, cache_enable=cache_enable, log_enable=log_enable)
|
|
58
71
|
|
|
@@ -70,6 +83,16 @@ class WellApiCDK(Construct):
|
|
|
70
83
|
]
|
|
71
84
|
code_layer = _lambda.Code.from_asset(APP_LAYOUT_FILE)
|
|
72
85
|
|
|
86
|
+
lambda_role = iam.Role(
|
|
87
|
+
self,
|
|
88
|
+
"LambdaRole",
|
|
89
|
+
assumed_by=iam.ServicePrincipal("lambda.amazonaws.com"),
|
|
90
|
+
managed_policies=[
|
|
91
|
+
iam.ManagedPolicy.from_aws_managed_policy_name("service-role/AWSLambdaBasicExecutionRole"),
|
|
92
|
+
iam.ManagedPolicy.from_aws_managed_policy_name("service-role/AWSLambdaVPCAccessExecutionRole"),
|
|
93
|
+
],
|
|
94
|
+
)
|
|
95
|
+
|
|
73
96
|
lmbd: Lambda
|
|
74
97
|
for lmbd in wellapi_app.lambdas:
|
|
75
98
|
lambda_function = _lambda.Function(
|
|
@@ -86,6 +109,7 @@ class WellApiCDK(Construct):
|
|
|
86
109
|
vpc_subnets=vpc_subnets,
|
|
87
110
|
security_groups=sg,
|
|
88
111
|
environment=environment,
|
|
112
|
+
role=lambda_role
|
|
89
113
|
)
|
|
90
114
|
|
|
91
115
|
if lmbd.type_ == "endpoint":
|
|
@@ -218,7 +242,7 @@ class WellApiCDK(Construct):
|
|
|
218
242
|
)
|
|
219
243
|
self.usage_plan.add_api_key(self.api_key)
|
|
220
244
|
|
|
221
|
-
def _package_app(self, cors: bool = False) -> WellApi:
|
|
245
|
+
def _package_app(self, cors: bool = False, api_role_arn: str | None = None) -> WellApi:
|
|
222
246
|
wellapi_app = import_app(self.app_srt)
|
|
223
247
|
load_handlers(self.handlers_dir)
|
|
224
248
|
|
|
@@ -231,6 +255,7 @@ class WellApiCDK(Construct):
|
|
|
231
255
|
tags=wellapi_app.openapi_tags,
|
|
232
256
|
servers=wellapi_app.servers,
|
|
233
257
|
cors=cors,
|
|
258
|
+
api_role_arn=api_role_arn,
|
|
234
259
|
)
|
|
235
260
|
with open(OPENAPI_FILE, "w") as f:
|
|
236
261
|
json.dump(resp, f)
|
|
@@ -146,6 +146,7 @@ def get_openapi(
|
|
|
146
146
|
license_info: dict[str, str | Any] | None = None,
|
|
147
147
|
separate_input_output_schemas: bool = True,
|
|
148
148
|
cors: bool = False,
|
|
149
|
+
api_role_arn: str | None = None
|
|
149
150
|
) -> dict[str, Any]:
|
|
150
151
|
info: dict[str, Any] = {"title": title, "version": version}
|
|
151
152
|
if description:
|
|
@@ -184,6 +185,7 @@ def get_openapi(
|
|
|
184
185
|
field_mapping=field_mapping,
|
|
185
186
|
separate_input_output_schemas=separate_input_output_schemas,
|
|
186
187
|
cors=cors,
|
|
188
|
+
api_role_arn=api_role_arn,
|
|
187
189
|
)
|
|
188
190
|
if result:
|
|
189
191
|
path, security_schemes, path_definitions = result
|
|
@@ -266,6 +268,7 @@ def get_openapi_path(
|
|
|
266
268
|
],
|
|
267
269
|
separate_input_output_schemas: bool = True,
|
|
268
270
|
cors: bool = False,
|
|
271
|
+
api_role_arn: str | None = None
|
|
269
272
|
) -> tuple[dict[str, Any], dict[str, Any], dict[str, Any]]:
|
|
270
273
|
path = {}
|
|
271
274
|
security_schemes: dict[str, Any] = {}
|
|
@@ -276,7 +279,7 @@ def get_openapi_path(
|
|
|
276
279
|
current_response_class = route.response_class
|
|
277
280
|
assert current_response_class, "A response class is needed to generate OpenAPI"
|
|
278
281
|
route_response_media_type = "application/json"
|
|
279
|
-
operation = get_openapi_operation_metadata(route=route, operation_ids=operation_ids)
|
|
282
|
+
operation = get_openapi_operation_metadata(route=route, operation_ids=operation_ids, api_role_arn=api_role_arn)
|
|
280
283
|
parameters: list[dict[str, Any]] = []
|
|
281
284
|
flat_dependant = get_flat_dependant(route.dependant, skip_repeats=True)
|
|
282
285
|
security_definitions, operation_security = get_openapi_security_definitions(
|
|
@@ -441,7 +444,7 @@ def get_openapi_path(
|
|
|
441
444
|
|
|
442
445
|
|
|
443
446
|
def get_openapi_operation_metadata(
|
|
444
|
-
*, route: Lambda, operation_ids: set[str]
|
|
447
|
+
*, route: Lambda, operation_ids: set[str], api_role_arn: str | None = None
|
|
445
448
|
) -> dict[str, Any]:
|
|
446
449
|
operation: dict[str, Any] = {}
|
|
447
450
|
if route.tags:
|
|
@@ -468,8 +471,10 @@ def get_openapi_operation_metadata(
|
|
|
468
471
|
"uri": {
|
|
469
472
|
"Fn::Sub": f"arn:aws:apigateway:${{AWS::Region}}:lambda:path/2015-03-31/functions/${{{route.arn}Function.Arn}}/invocations"
|
|
470
473
|
},
|
|
474
|
+
"passthroughBehavior": "when_no_match",
|
|
471
475
|
"httpMethod": "POST",
|
|
472
476
|
"type": "aws_proxy",
|
|
477
|
+
"credentials": api_role_arn,
|
|
473
478
|
}
|
|
474
479
|
|
|
475
480
|
return operation
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|