Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
48 changes: 24 additions & 24 deletions samtranslator/model/api/api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _set_condition(self, condition, template_conditions): # type: ignore[no-unt

if self.conditions:
self.conditions.add(condition)
or_condition = make_or_condition(self.conditions) # type: ignore[no-untyped-call]
or_condition = make_or_condition(self.conditions)
template_conditions[SharedApiUsagePlan.SHARED_USAGE_PLAN_CONDITION_NAME] = or_condition
else:
self.conditions.add(condition)
Expand Down Expand Up @@ -396,7 +396,7 @@ def _construct_stage(self, deployment, swagger, redeploy_restapi_parameters): #
generator = LogicalIdGenerator(self.logical_id + "Stage", stage_name_prefix) # type: ignore[no-untyped-call]
stage_logical_id = generator.gen() # type: ignore[no-untyped-call]
stage = ApiGatewayStage(stage_logical_id, attributes=self.passthrough_resource_attributes) # type: ignore[no-untyped-call]
stage.RestApiId = ref(self.logical_id) # type: ignore[no-untyped-call]
stage.RestApiId = ref(self.logical_id)
stage.update_deployment_ref(deployment.logical_id) # type: ignore[no-untyped-call]
stage.StageName = self.stage_name
stage.CacheClusterEnabled = self.cache_cluster_enabled
Expand Down Expand Up @@ -503,9 +503,9 @@ def _construct_api_domain(self, rest_api, route53_record_set_groups): # type: i
basepath_mapping = ApiGatewayBasePathMapping( # type: ignore[no-untyped-call]
self.logical_id + "BasePathMapping", attributes=self.passthrough_resource_attributes
)
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName")) # type: ignore[no-untyped-call]
basepath_mapping.RestApiId = ref(rest_api.logical_id) # type: ignore[no-untyped-call]
basepath_mapping.Stage = ref(rest_api.logical_id + ".Stage") # type: ignore[no-untyped-call]
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName"))
basepath_mapping.RestApiId = ref(rest_api.logical_id)
basepath_mapping.Stage = ref(rest_api.logical_id + ".Stage")
basepath_resource_list.extend([basepath_mapping])
else:
for path in basepaths:
Expand All @@ -514,9 +514,9 @@ def _construct_api_domain(self, rest_api, route53_record_set_groups): # type: i
basepath_mapping = ApiGatewayBasePathMapping( # type: ignore[no-untyped-call]
logical_id, attributes=self.passthrough_resource_attributes
)
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName")) # type: ignore[no-untyped-call]
basepath_mapping.RestApiId = ref(rest_api.logical_id) # type: ignore[no-untyped-call]
basepath_mapping.Stage = ref(rest_api.logical_id + ".Stage") # type: ignore[no-untyped-call]
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName"))
basepath_mapping.RestApiId = ref(rest_api.logical_id)
basepath_mapping.Stage = ref(rest_api.logical_id + ".Stage")
basepath_mapping.BasePath = path
basepath_resource_list.extend([basepath_mapping])

Expand Down Expand Up @@ -583,11 +583,11 @@ def _construct_alias_target(self, domain): # type: ignore[no-untyped-def]
if target_health is not None:
alias_target["EvaluateTargetHealth"] = target_health
if domain.get("EndpointConfiguration") == "REGIONAL":
alias_target["HostedZoneId"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalHostedZoneId") # type: ignore[no-untyped-call]
alias_target["DNSName"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalDomainName") # type: ignore[no-untyped-call]
alias_target["HostedZoneId"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalHostedZoneId")
alias_target["DNSName"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalDomainName")
else:
if route53.get("DistributionDomainName") is None:
route53["DistributionDomainName"] = fnGetAtt(self.domain.get("ApiDomainName"), "DistributionDomainName") # type: ignore[no-untyped-call]
route53["DistributionDomainName"] = fnGetAtt(self.domain.get("ApiDomainName"), "DistributionDomainName")
alias_target["HostedZoneId"] = "Z2FDTNDATAQYW2"
alias_target["DNSName"] = route53.get("DistributionDomainName")
return alias_target
Expand Down Expand Up @@ -630,7 +630,7 @@ def _add_cors(self): # type: ignore[no-untyped-def]
self.logical_id, "Cors works only with inline Swagger specified in 'DefinitionBody' property."
)

if isinstance(self.cors, str) or is_intrinsic(self.cors): # type: ignore[no-untyped-call]
if isinstance(self.cors, str) or is_intrinsic(self.cors):
# Just set Origin property. Others will be defaults
properties = CorsProperties(AllowOrigin=self.cors) # type: ignore[call-arg]
elif isinstance(self.cors, dict):
Expand Down Expand Up @@ -793,8 +793,8 @@ def _construct_usage_plan(self, rest_api_stage=None): # type: ignore[no-untyped
)
api_stages = []
api_stage = {}
api_stage["ApiId"] = ref(self.logical_id) # type: ignore[no-untyped-call]
api_stage["Stage"] = ref(rest_api_stage.logical_id) # type: ignore[no-untyped-call]
api_stage["ApiId"] = ref(self.logical_id)
api_stage["Stage"] = ref(rest_api_stage.logical_id)
api_stages.append(api_stage)
usage_plan.ApiStages = api_stages

Expand All @@ -815,8 +815,8 @@ def _construct_usage_plan(self, rest_api_stage=None): # type: ignore[no-untyped
),
)
api_stage = {}
api_stage["ApiId"] = ref(self.logical_id) # type: ignore[no-untyped-call]
api_stage["Stage"] = ref(rest_api_stage.logical_id) # type: ignore[no-untyped-call]
api_stage["ApiId"] = ref(self.logical_id)
api_stage["Stage"] = ref(rest_api_stage.logical_id)
if api_stage not in self.shared_api_usage_plan.api_stages_shared:
self.shared_api_usage_plan.api_stages_shared.append(api_stage)
usage_plan.ApiStages = self.shared_api_usage_plan.api_stages_shared
Expand Down Expand Up @@ -856,8 +856,8 @@ def _construct_api_key(self, usage_plan_logical_id, create_usage_plan, rest_api_
)
api_key.Enabled = True
stage_key = {}
stage_key["RestApiId"] = ref(self.logical_id) # type: ignore[no-untyped-call]
stage_key["StageName"] = ref(rest_api_stage.logical_id) # type: ignore[no-untyped-call]
stage_key["RestApiId"] = ref(self.logical_id)
stage_key["StageName"] = ref(rest_api_stage.logical_id)
if stage_key not in self.shared_api_usage_plan.stage_keys_shared:
self.shared_api_usage_plan.stage_keys_shared.append(stage_key)
api_key.StageKeys = self.shared_api_usage_plan.stage_keys_shared
Expand All @@ -873,8 +873,8 @@ def _construct_api_key(self, usage_plan_logical_id, create_usage_plan, rest_api_
api_key.Enabled = True
stage_keys = []
stage_key = {}
stage_key["RestApiId"] = ref(self.logical_id) # type: ignore[no-untyped-call]
stage_key["StageName"] = ref(rest_api_stage.logical_id) # type: ignore[no-untyped-call]
stage_key["RestApiId"] = ref(self.logical_id)
stage_key["StageName"] = ref(rest_api_stage.logical_id)
stage_keys.append(stage_key)
api_key.StageKeys = stage_keys
return api_key
Expand Down Expand Up @@ -903,9 +903,9 @@ def _construct_usage_plan_key(self, usage_plan_logical_id, create_usage_plan, ap
depends_on=[api_key.logical_id],
attributes=resource_attributes,
)
usage_plan_key.KeyId = ref(api_key.logical_id) # type: ignore[no-untyped-call]
usage_plan_key.KeyId = ref(api_key.logical_id)
usage_plan_key.KeyType = "API_KEY"
usage_plan_key.UsagePlanId = ref(usage_plan_logical_id) # type: ignore[no-untyped-call]
usage_plan_key.UsagePlanId = ref(usage_plan_logical_id)

return usage_plan_key

Expand All @@ -925,7 +925,7 @@ def _add_gateway_responses(self): # type: ignore[no-untyped-def]

# Make sure keys in the dict are recognized
for responses_key, responses_value in self.gateway_responses.items():
if is_intrinsic(responses_value): # type: ignore[no-untyped-call]
if is_intrinsic(responses_value):
# TODO: Add intrinsic support for this field.
raise InvalidResourceException( # type: ignore[no-untyped-call]
self.logical_id,
Expand Down Expand Up @@ -1108,7 +1108,7 @@ def _get_permission(self, authorizer_name, authorizer_lambda_function_arn): # t

partition = ArnGenerator.get_partition_name() # type: ignore[no-untyped-call]
resource = "${__ApiId__}/authorizers/*"
source_arn = fnSub( # type: ignore[no-untyped-call]
source_arn = fnSub(
ArnGenerator.generate_arn(partition=partition, service="execute-api", resource=resource), # type: ignore[no-untyped-call]
{"__ApiId__": api_id},
)
Expand Down
24 changes: 12 additions & 12 deletions samtranslator/model/api/http_api_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def _add_cors(self): # type: ignore[no-untyped-def]
# if cors config is true add Origins as "'*'"
properties = CorsProperties(AllowOrigins=[_CORS_WILDCARD]) # type: ignore[call-arg]

elif is_intrinsic(self.cors_configuration): # type: ignore[no-untyped-call]
elif is_intrinsic(self.cors_configuration):
# Just set Origin property. Intrinsics will be handledOthers will be defaults
properties = CorsProperties(AllowOrigins=self.cors_configuration) # type: ignore[call-arg]

Expand Down Expand Up @@ -344,9 +344,9 @@ def _construct_basepath_mappings(self, basepaths, http_api): # type: ignore[no-
basepath_mapping = ApiGatewayV2ApiMapping( # type: ignore[no-untyped-call]
self.logical_id + "ApiMapping", attributes=self.passthrough_resource_attributes
)
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName")) # type: ignore[no-untyped-call]
basepath_mapping.ApiId = ref(http_api.logical_id) # type: ignore[no-untyped-call]
basepath_mapping.Stage = ref(http_api.logical_id + ".Stage") # type: ignore[no-untyped-call]
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName"))
basepath_mapping.ApiId = ref(http_api.logical_id)
basepath_mapping.Stage = ref(http_api.logical_id + ".Stage")
basepath_resource_list.extend([basepath_mapping])
else:
for path in basepaths:
Expand All @@ -364,9 +364,9 @@ def _construct_basepath_mappings(self, basepaths, http_api): # type: ignore[no-

logical_id = "{}{}{}".format(self.logical_id, re.sub(r"[\-_/]+", "", path), "ApiMapping")
basepath_mapping = ApiGatewayV2ApiMapping(logical_id, attributes=self.passthrough_resource_attributes) # type: ignore[no-untyped-call]
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName")) # type: ignore[no-untyped-call]
basepath_mapping.ApiId = ref(http_api.logical_id) # type: ignore[no-untyped-call]
basepath_mapping.Stage = ref(http_api.logical_id + ".Stage") # type: ignore[no-untyped-call]
basepath_mapping.DomainName = ref(self.domain.get("ApiDomainName"))
basepath_mapping.ApiId = ref(http_api.logical_id)
basepath_mapping.Stage = ref(http_api.logical_id + ".Stage")
basepath_mapping.ApiMappingKey = path
basepath_resource_list.extend([basepath_mapping])
return basepath_resource_list
Expand Down Expand Up @@ -398,8 +398,8 @@ def _construct_alias_target(self, domain): # type: ignore[no-untyped-def]
if target_health is not None:
alias_target["EvaluateTargetHealth"] = target_health
if domain.get("EndpointConfiguration") == "REGIONAL":
alias_target["HostedZoneId"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalHostedZoneId") # type: ignore[no-untyped-call]
alias_target["DNSName"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalDomainName") # type: ignore[no-untyped-call]
alias_target["HostedZoneId"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalHostedZoneId")
alias_target["DNSName"] = fnGetAtt(self.domain.get("ApiDomainName"), "RegionalDomainName")
else:
raise InvalidResourceException( # type: ignore[no-untyped-call]
self.logical_id,
Expand Down Expand Up @@ -480,10 +480,10 @@ def _set_default_authorizer(self, open_api_editor, authorizers, default_authoriz
if not default_authorizer:
return

if is_intrinsic_no_value(default_authorizer): # type: ignore[no-untyped-call]
if is_intrinsic_no_value(default_authorizer):
return

if is_intrinsic(default_authorizer): # type: ignore[no-untyped-call]
if is_intrinsic(default_authorizer):
raise InvalidResourceException( # type: ignore[no-untyped-call]
self.logical_id,
"Unable to set DefaultAuthorizer because intrinsic functions are not supported for this field.",
Expand Down Expand Up @@ -603,7 +603,7 @@ def _construct_stage(self): # type: ignore[no-untyped-def]
generator = LogicalIdGenerator(self.logical_id + "Stage", stage_name_prefix) # type: ignore[no-untyped-call]
stage_logical_id = generator.gen() # type: ignore[no-untyped-call]
stage = ApiGatewayV2Stage(stage_logical_id, attributes=self.passthrough_resource_attributes) # type: ignore[no-untyped-call]
stage.ApiId = ref(self.logical_id) # type: ignore[no-untyped-call]
stage.ApiId = ref(self.logical_id)
stage.StageName = self.stage_name
stage.StageVariables = self.stage_variables
stage.AccessLogSettings = self.access_log_settings
Expand Down
14 changes: 7 additions & 7 deletions samtranslator/model/apigateway.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ class ApiGatewayRestApi(Resource):
"ApiKeySourceType": PropertyType(False, is_str()),
}

runtime_attrs = {"rest_api_id": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"rest_api_id": lambda self: ref(self.logical_id)}


class ApiGatewayStage(Resource):
Expand All @@ -48,10 +48,10 @@ class ApiGatewayStage(Resource):
"MethodSettings": PropertyType(False, is_type(list)),
}

runtime_attrs = {"stage_name": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"stage_name": lambda self: ref(self.logical_id)}

def update_deployment_ref(self, deployment_logical_id): # type: ignore[no-untyped-def]
self.DeploymentId = ref(deployment_logical_id) # type: ignore[no-untyped-call]
self.DeploymentId = ref(deployment_logical_id)


class ApiGatewayAccount(Resource):
Expand All @@ -70,7 +70,7 @@ class ApiGatewayDeployment(Resource):
"StageName": PropertyType(False, is_str()),
}

runtime_attrs = {"deployment_id": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"deployment_id": lambda self: ref(self.logical_id)}

def make_auto_deployable( # type: ignore[no-untyped-def]
self, stage, openapi_version=None, swagger=None, domain=None, redeploy_restapi_parameters=None
Expand Down Expand Up @@ -201,7 +201,7 @@ class ApiGatewayUsagePlan(Resource):
"Throttle": PropertyType(False, is_type(dict)),
"UsagePlanName": PropertyType(False, is_str()),
}
runtime_attrs = {"usage_plan_id": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"usage_plan_id": lambda self: ref(self.logical_id)}


class ApiGatewayUsagePlanKey(Resource):
Expand All @@ -225,7 +225,7 @@ class ApiGatewayApiKey(Resource):
"Value": PropertyType(False, is_str()),
}

runtime_attrs = {"api_key_id": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"api_key_id": lambda self: ref(self.logical_id)}


class ApiGatewayAuthorizer(object):
Expand Down Expand Up @@ -312,7 +312,7 @@ def generate_swagger(self): # type: ignore[no-untyped-def]
swagger[APIGATEWAY_AUTHORIZER_KEY] = Py27Dict({"type": self._get_swagger_authorizer_type()}) # type: ignore[no-untyped-call, no-untyped-call]
partition = ArnGenerator.get_partition_name() # type: ignore[no-untyped-call]
resource = "lambda:path/2015-03-31/functions/${__FunctionArn__}/invocations"
authorizer_uri = fnSub( # type: ignore[no-untyped-call]
authorizer_uri = fnSub(
ArnGenerator.generate_arn( # type: ignore[no-untyped-call]
partition=partition, service="apigateway", resource=resource, include_account_id=False
),
Expand Down
6 changes: 3 additions & 3 deletions samtranslator/model/apigatewayv2.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ class ApiGatewayV2HttpApi(Resource):
"CorsConfiguration": PropertyType(False, is_type(dict)),
}

runtime_attrs = {"http_api_id": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"http_api_id": lambda self: ref(self.logical_id)}


class ApiGatewayV2Stage(Resource):
Expand All @@ -37,7 +37,7 @@ class ApiGatewayV2Stage(Resource):
"AutoDeploy": PropertyType(False, is_type(bool)),
}

runtime_attrs = {"stage_name": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"stage_name": lambda self: ref(self.logical_id)}


class ApiGatewayV2DomainName(Resource):
Expand Down Expand Up @@ -218,7 +218,7 @@ def generate_openapi(self): # type: ignore[no-untyped-def]
# Generate the lambda arn
partition = ArnGenerator.get_partition_name() # type: ignore[no-untyped-call]
resource = "lambda:path/2015-03-31/functions/${__FunctionArn__}/invocations"
authorizer_uri = fnSub( # type: ignore[no-untyped-call]
authorizer_uri = fnSub(
ArnGenerator.generate_arn( # type: ignore[no-untyped-call]
partition=partition, service="apigateway", resource=resource, include_account_id=False
),
Expand Down
2 changes: 1 addition & 1 deletion samtranslator/model/cloudformation.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,4 +14,4 @@ class NestedStack(Resource):
"TimeoutInMinutes": PropertyType(False, is_type(int)),
}

runtime_attrs = {"stack_id": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"stack_id": lambda self: ref(self.logical_id)}
4 changes: 2 additions & 2 deletions samtranslator/model/codedeploy.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ class CodeDeployApplication(Resource):
resource_type = "AWS::CodeDeploy::Application"
property_types = {"ComputePlatform": PropertyType(False, one_of(is_str(), is_type(dict)))}

runtime_attrs = {"name": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"name": lambda self: ref(self.logical_id)}


class CodeDeployDeploymentGroup(Resource):
Expand All @@ -22,4 +22,4 @@ class CodeDeployDeploymentGroup(Resource):
"TriggerConfigurations": PropertyType(False, is_type(list)),
}

runtime_attrs = {"name": lambda self: ref(self.logical_id)} # type: ignore[no-untyped-call]
runtime_attrs = {"name": lambda self: ref(self.logical_id)}
8 changes: 4 additions & 4 deletions samtranslator/model/cognito.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,8 @@ class CognitoUserPool(Resource):
}

runtime_attrs = {
"name": lambda self: ref(self.logical_id), # type: ignore[no-untyped-call]
"arn": lambda self: fnGetAtt(self.logical_id, "Arn"), # type: ignore[no-untyped-call]
"provider_name": lambda self: fnGetAtt(self.logical_id, "ProviderName"), # type: ignore[no-untyped-call]
"provider_url": lambda self: fnGetAtt(self.logical_id, "ProviderURL"), # type: ignore[no-untyped-call]
"name": lambda self: ref(self.logical_id),
"arn": lambda self: fnGetAtt(self.logical_id, "Arn"),
"provider_name": lambda self: fnGetAtt(self.logical_id, "ProviderName"),
"provider_url": lambda self: fnGetAtt(self.logical_id, "ProviderURL"),
}
Loading