|
5 | 5 | from ..errors import FunctionsHttpError, FunctionsRelayError |
6 | 6 | from ..utils import AsyncClient, is_http_url, is_valid_jwt, is_valid_str_arg, FunctionRegion |
7 | 7 | from ..version import __version__ |
| 8 | +from warnings import warn |
8 | 9 |
|
9 | 10 |
|
10 | 11 | class AsyncFunctionsClient: |
@@ -88,16 +89,12 @@ async def invoke( |
88 | 89 | response_type = invoke_options.get("responseType", "text/plain") |
89 | 90 |
|
90 | 91 | region = invoke_options.get("region") |
91 | | - try: |
92 | | - fn_region = FunctionRegion(region) |
93 | | - if fn_region and region != "any": |
94 | | - headers["x-region"] = region.lower().strip() |
95 | | - except ValueError as e: |
96 | | - # print(e) |
97 | | - pass # In the future can become an error/warning. |
98 | | - |
99 | | - if region and isinstance(region, str) and region != "any": |
100 | | - headers["x-region"] = region.lower().strip() |
| 92 | + if not isinstance(region, FunctionRegion): |
| 93 | + warn(f"Use FunctionRegion({region})") |
| 94 | + region = FunctionRegion(region) |
| 95 | + |
| 96 | + if region and region.value != "any": |
| 97 | + headers["x-region"] = region.value |
101 | 98 |
|
102 | 99 | body = invoke_options.get("body") |
103 | 100 | if isinstance(body, str): |
|
0 commit comments