Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

Update the functions documentation for python lib (#18623)

Andrew Smith6af4035448ff
diff --git a/spec/supabase_py_v2.yml b/spec/supabase_py_v2.yml
index 7de0f138dde..77b3a75dc92 100644
--- a/spec/supabase_py_v2.yml
+++ b/spec/supabase_py_v2.yml
@@ -1795,16 +1795,59 @@ functions:
name: Basic invocation
description:
code: |
+ ```python
+ resp = supabase.functions.invoke(
+ "hello-world",
+ invoke_options={
+ "body": { "foo": "bar" }
+ },
+ )
```
- func = supabase.functions()
- @asyncio.coroutine
- async def test_func(loop):
- resp = await func.invoke("hello-world",invoke_options={'body':{}})
- return resp
-
- loop = asyncio.get_event_loop()
- resp = loop.run_until_complete(test_func(loop))
- loop.close()
+ - id: error-handling
+ name: Error handling
+ description: |
+ Returns one of the following errors:
+
+ - `FunctionsHttpError`: if your function throws an error
+ - `FunctionsRelayError`: if the Supabase Relay encounters an error processing your function
+ isSpotlight: true
+ code: |
+ ```python
+ from supafunc.errors import FunctionsRelayError, FunctionsHttpError
+
+ try:
+ resp = supabase.functions.invoke(
+ "hello-world",
+ invoke_options={
+ "body": {"foo": "bar"},
+ "headers": {"my-custom-header": "my-custom-header-value"},
+ },
+ )
+ except FunctionsHttpError as exception:
+ err = exception.to_dict()
+ print(f"Function returned an error {err.get("message")}")
+ except FunctionsRelayError as exception:
+ err = exception.to_dict()
+ print(f"Relay error: {err.get("message")}")
+ ```
+ - id: passing-custom-headers
+ name: Passing custom headers
+ description: |
+ The library accepts custom headers via the `headers` option.
+
+ Note: `supabase-py` automatically populates the `Authorization` header if there is a signed in user.
+ isSpotlight: true
+ code: |
+ ```python
+ resp = supabase.functions.invoke(
+ "hello-world",
+ invoke_options={
+ "headers": {
+ "my-custom-header": "my-custom-header-value"
+ },
+ "body": { "foo": "bar" }
+ }
+ )
```
- id: list-buckets