MCPcopy Create free account
hub / github.com/firebase/functions-samples / get_function_url

Function get_function_url

Python/post-signup-event/functions/main.py:127–148  ·  view source on GitHub ↗

Get the URL of a given v2 cloud function. Params: name: the function's name location: the function's location Returns: The URL of the function

(name: str, location: str = options.SupportedRegion.US_CENTRAL1)

Source from the content-addressed store, hash-verified

125
126
127def get_function_url(name: str, location: str = options.SupportedRegion.US_CENTRAL1) -> str:
128 """Get the URL of a given v2 cloud function.
129
130 Params:
131 name: the function's name
132 location: the function's location
133
134 Returns:
135 The URL of the function
136 """
137 credentials, project_id = google.auth.default(
138 scopes=["https://www.googleapis.com/auth/cloud-platform"]
139 )
140 authed_session = google.auth.transport.requests.AuthorizedSession(credentials)
141 url = (
142 "https://cloudfunctions.googleapis.com/v2beta/"
143 + f"projects/{project_id}/locations/{location}/functions/{name}"
144 )
145 response = authed_session.get(url)
146 data = response.json()
147 function_url = data["serviceConfig"]["uri"]
148 return function_url

Callers 1

savegoogletokenFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected