Skip to content

Commit bbed56c

Browse files
committed
small fixes
1 parent 75774da commit bbed56c

File tree

6 files changed

+10
-14
lines changed

6 files changed

+10
-14
lines changed

localstack-core/localstack/services/apigateway/models.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,10 @@ class ApiGatewayStore(BaseStore):
8686
# maps resource ARN to tags
8787
TAGS: Dict[str, Dict[str, str]] = CrossRegionAttribute(default=dict)
8888

89-
# internal deployments, represents a frozen REST API for a deployment
90-
internal_deployments: dict[str, RestApiDeployment] = LocalAttribute(default=dict)
89+
# internal deployments, represents a frozen REST API for a deployment, used in our router
90+
# TODO: make sure API ID are unique across all accounts
91+
# maps ApiID + deploymentId to a RestApiDeployment, an executable/snapshot of a REST API
92+
internal_deployments: dict[(str, str), RestApiDeployment] = CrossAccountAttribute(default=dict)
9193

9294
# active deployments, mapping API ID + Stage to deployment ID
9395
# TODO: make sure API ID are unique across all accounts

localstack-core/localstack/services/apigateway/next_gen/execute_api/gateway.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66

77

88
class RestApiGateway(Gateway):
9-
# TODO: not sure we need to extend it, might remove if not needed
109
def __init__(self):
1110
super().__init__(context_class=RestApiInvocationContext)
1211
self.request_handlers.extend(

localstack-core/localstack/services/apigateway/next_gen/execute_api/router.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ def populate_rest_api_invocation_context(
4848
):
4949
try:
5050
deployment_id = self._global_store.active_deployments[(api_id, stage)]
51-
frozen_deployment = self._global_store.internal_deployments[deployment_id]
51+
frozen_deployment = self._global_store.internal_deployments[(api_id, deployment_id)]
5252

5353
except KeyError:
5454
# TODO: find proper error when trying to hit an API with no deployment/stage linked

localstack-core/localstack/services/apigateway/next_gen/provider.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,7 @@ def create_deployment(
106106
moto_rest_api=moto_rest_api,
107107
localstack_rest_api=rest_api_container,
108108
)
109-
store.internal_deployments[deployment["id"]] = frozen_deployment
109+
store.internal_deployments[(rest_api_id, deployment["id"])] = frozen_deployment
110110

111111
if stage_name:
112112
store.active_deployments[(rest_api_id, stage_name)] = deployment["id"]
@@ -118,4 +118,4 @@ def delete_deployment(
118118
) -> None:
119119
call_moto(context)
120120
store = get_apigateway_store(context=context)
121-
store.internal_deployments.pop(deployment_id, None)
121+
store.internal_deployments.pop((rest_api_id, deployment_id), None)

localstack-core/localstack/services/apigateway/provider.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -970,24 +970,20 @@ def update_method_response(
970970
@handler("CreateStage", expand=False)
971971
def create_stage(self, context: RequestContext, request: CreateStageRequest) -> Stage:
972972
call_moto(context)
973-
rest_api_id = request["restApiId"]
974-
stage_name = request["stageName"]
975-
moto_api = get_moto_rest_api(context, rest_api_id=rest_api_id)
976-
stage = moto_api.stages.get(stage_name)
973+
moto_api = get_moto_rest_api(context, rest_api_id=request["restApiId"])
974+
stage = moto_api.stages.get(request["stageName"])
977975
if not stage:
978976
raise NotFoundException("Invalid Stage identifier specified")
979977

980978
if not hasattr(stage, "documentation_version"):
981979
stage.documentation_version = request.get("documentationVersion")
982980

983981
# make sure we update the stage_name on the deployment entity in moto
984-
deployment_id = request["deploymentId"]
985-
deployment = moto_api.deployments.get(deployment_id)
982+
deployment = moto_api.deployments.get(request["deploymentId"])
986983
deployment.stage_name = stage.name
987984

988985
response = stage.to_json()
989986
self._patch_stage_response(response)
990-
991987
return response
992988

993989
def get_stage(

tests/aws/services/apigateway/test_apigateway_basic.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -309,7 +309,6 @@ def test_api_gateway_lambda_integration_aws_type(
309309

310310
url = api_invoke_url(api_id, stage=stage, path="/test")
311311
response = requests.post(url, json={"test": "test"})
312-
print(response.content)
313312

314313
assert response.headers["Content-Type"] == "text/html"
315314
assert response.headers["Access-Control-Allow-Origin"] == "*"

0 commit comments

Comments
 (0)