MCPcopy Index your code
hub / github.com/zappa/Zappa / get_api_id

Method get_api_id

zappa/core.py:2936–2961  ·  view source on GitHub ↗

Given a lambda_name, return the API id.

(self, lambda_name: str, apigateway_version: str = DEFAULT_APIGATEWAY_VERSION)

Source from the content-addressed store, hash-verified

2934 return None
2935
2936 def get_api_id(self, lambda_name: str, apigateway_version: str = DEFAULT_APIGATEWAY_VERSION):
2937 """
2938 Given a lambda_name, return the API id.
2939 """
2940 # Try v2 resource name first if v2, otherwise try v1 resource name
2941 resource_name = "Api"
2942 if apigateway_version != "v1":
2943 resource_name = "ApiV2"
2944
2945 try:
2946 response = self.cf_client.describe_stack_resource(StackName=lambda_name, LogicalResourceId=resource_name)
2947 return response["StackResourceDetail"].get("PhysicalResourceId", None)
2948 except Exception: # pragma: no cover
2949 # Try the old method (project was probably made on an older, non CF version)
2950 try:
2951 response = self.apigateway_client.get_rest_apis(limit=500)
2952
2953 for item in response["items"]:
2954 if item["name"] == lambda_name:
2955 return item["id"]
2956
2957 logger.exception("Could not get API ID.")
2958 return None
2959 except Exception: # pragma: no cover
2960 # We don't even have an API deployed. That's okay!
2961 return None
2962
2963 def create_domain_name(
2964 self,

Callers 10

get_api_urlMethod · 0.95
create_domain_nameMethod · 0.95
test_get_api_id_v1Method · 0.95
test_get_api_id_v2Method · 0.95
deployMethod · 0.80
updateMethod · 0.80
undeployMethod · 0.80
statusMethod · 0.80

Calls 1

get_rest_apisMethod · 0.80

Tested by 3

test_get_api_id_v1Method · 0.76
test_get_api_id_v2Method · 0.76