polyapi-python 0.2.4.dev9__tar.gz → 0.2.4.dev10__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {polyapi_python-0.2.4.dev9/polyapi_python.egg-info → polyapi_python-0.2.4.dev10}/PKG-INFO +1 -1
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/error_handler.py +7 -3
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/generate.py +2 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/utils.py +10 -1
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/webhook.py +6 -3
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10/polyapi_python.egg-info}/PKG-INFO +1 -1
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/pyproject.toml +1 -1
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/LICENSE +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/README.md +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/__init__.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/__main__.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/api.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/auth.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/cli.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/client.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/config.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/constants.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/exceptions.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/execute.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/function_cli.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/poly_custom.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/py.typed +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/schema.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/server.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/typedefs.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi/variables.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi_python.egg-info/SOURCES.txt +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi_python.egg-info/dependency_links.txt +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi_python.egg-info/requires.txt +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi_python.egg-info/top_level.txt +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/setup.cfg +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/tests/test_api.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/tests/test_auth.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/tests/test_function_cli.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/tests/test_server.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/tests/test_utils.py +0 -0
- {polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/tests/test_variables.py +0 -0
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import asyncio
|
|
2
2
|
import copy
|
|
3
3
|
import socketio # type: ignore
|
|
4
|
+
from socketio.exceptions import ConnectionError # type: ignore
|
|
4
5
|
from typing import Any, Callable, Dict, List, Optional
|
|
5
6
|
|
|
6
7
|
from polyapi.config import get_api_key_and_url
|
|
@@ -28,7 +29,7 @@ async def get_client_and_connect():
|
|
|
28
29
|
|
|
29
30
|
|
|
30
31
|
async def unregister(data: Dict[str, Any]):
|
|
31
|
-
print(f"
|
|
32
|
+
print(f"Stopping error handler for {data['path']}...")
|
|
32
33
|
assert client
|
|
33
34
|
await client.emit(
|
|
34
35
|
"unregisterErrorHandler",
|
|
@@ -40,14 +41,17 @@ async def unregister(data: Dict[str, Any]):
|
|
|
40
41
|
async def unregister_all():
|
|
41
42
|
_, base_url = get_api_key_and_url()
|
|
42
43
|
# need to reconnect because maybe socketio client disconnected after Ctrl+C?
|
|
43
|
-
|
|
44
|
+
try:
|
|
45
|
+
await client.connect(base_url, transports=["websocket"], namespaces=["/events"])
|
|
46
|
+
except ConnectionError:
|
|
47
|
+
pass
|
|
44
48
|
await asyncio.gather(*[unregister(handler) for handler in active_handlers])
|
|
45
49
|
|
|
46
50
|
|
|
47
51
|
async def on(
|
|
48
52
|
path: str, callback: Callable, options: Optional[Dict[str, Any]] = None
|
|
49
53
|
) -> None:
|
|
50
|
-
print(f"
|
|
54
|
+
print(f"Starting error handler for {path}...")
|
|
51
55
|
|
|
52
56
|
if not client:
|
|
53
57
|
raise Exception("Client not initialized. Abort!")
|
|
@@ -176,6 +176,7 @@ def render_spec(spec: SpecificationDto):
|
|
|
176
176
|
function_type = spec["type"]
|
|
177
177
|
function_description = spec["description"]
|
|
178
178
|
function_name = spec["name"]
|
|
179
|
+
function_context = spec["context"]
|
|
179
180
|
function_id = spec["id"]
|
|
180
181
|
|
|
181
182
|
arguments: List[PropertySpecification] = []
|
|
@@ -223,6 +224,7 @@ def render_spec(spec: SpecificationDto):
|
|
|
223
224
|
elif function_type == "webhookHandle":
|
|
224
225
|
func_str, func_type_defs = render_webhook_handle(
|
|
225
226
|
function_type,
|
|
227
|
+
function_context,
|
|
226
228
|
function_name,
|
|
227
229
|
function_id,
|
|
228
230
|
function_description,
|
|
@@ -165,4 +165,13 @@ def parse_arguments(function_name: str, arguments: List[PropertySpecification])
|
|
|
165
165
|
arg_string += f", # {description}\n"
|
|
166
166
|
else:
|
|
167
167
|
arg_string += ",\n"
|
|
168
|
-
return arg_string.rstrip("\n"), "\n\n".join(args_def)
|
|
168
|
+
return arg_string.rstrip("\n"), "\n\n".join(args_def)
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def poly_full_path(context, name) -> str:
|
|
172
|
+
"""get the functions path as it will be exposed in the poly library"""
|
|
173
|
+
if context:
|
|
174
|
+
path = context + "." + name
|
|
175
|
+
else:
|
|
176
|
+
path = name
|
|
177
|
+
return f"poly.{path}"
|
|
@@ -6,6 +6,7 @@ from typing import Any, Dict, List, Tuple
|
|
|
6
6
|
|
|
7
7
|
from polyapi.config import get_api_key_and_url
|
|
8
8
|
from polyapi.typedefs import PropertySpecification
|
|
9
|
+
from polyapi.utils import poly_full_path
|
|
9
10
|
|
|
10
11
|
# all active webhook handlers, used by unregister_all to cleanup
|
|
11
12
|
active_handlers: List[Dict[str, Any]] = []
|
|
@@ -24,7 +25,7 @@ async def {function_name}(callback, options=None):
|
|
|
24
25
|
\"""
|
|
25
26
|
from polyapi.webhook import client, active_handlers
|
|
26
27
|
|
|
27
|
-
print("Starting webhook for {
|
|
28
|
+
print("Starting webhook for {function_path}...")
|
|
28
29
|
|
|
29
30
|
if not client:
|
|
30
31
|
raise Exception("Client not initialized. Abort!")
|
|
@@ -66,7 +67,7 @@ async def {function_name}(callback, options=None):
|
|
|
66
67
|
"waitForResponse": options.get("waitForResponse"),
|
|
67
68
|
}}
|
|
68
69
|
await client.emit('registerWebhookEventHandler', data, namespace="/events", callback=registerCallback)
|
|
69
|
-
active_handlers.append({{"clientID": eventsClientId, "webhookHandleID": function_id, "apiKey": api_key}})
|
|
70
|
+
active_handlers.append({{"clientID": eventsClientId, "webhookHandleID": function_id, "apiKey": api_key, "path": "{function_path}"}})
|
|
70
71
|
"""
|
|
71
72
|
|
|
72
73
|
|
|
@@ -78,7 +79,7 @@ async def get_client_and_connect():
|
|
|
78
79
|
|
|
79
80
|
|
|
80
81
|
async def unregister(data: Dict[str, Any]):
|
|
81
|
-
print(f"
|
|
82
|
+
print(f"Stopping webhook handler for {data['path']}...")
|
|
82
83
|
assert client
|
|
83
84
|
await client.emit(
|
|
84
85
|
"unregisterWebhookEventHandler",
|
|
@@ -104,6 +105,7 @@ async def unregister_all():
|
|
|
104
105
|
|
|
105
106
|
def render_webhook_handle(
|
|
106
107
|
function_type: str,
|
|
108
|
+
function_context: str,
|
|
107
109
|
function_name: str,
|
|
108
110
|
function_id: str,
|
|
109
111
|
function_description: str,
|
|
@@ -115,6 +117,7 @@ def render_webhook_handle(
|
|
|
115
117
|
client_id=uuid.uuid4().hex,
|
|
116
118
|
function_id=function_id,
|
|
117
119
|
function_name=function_name,
|
|
120
|
+
function_path=poly_full_path(function_context, function_name),
|
|
118
121
|
)
|
|
119
122
|
|
|
120
123
|
return func_str, ""
|
|
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = "polyapi-python"
|
|
6
|
-
version = "0.2.4.
|
|
6
|
+
version = "0.2.4.dev10"
|
|
7
7
|
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
|
|
8
8
|
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
|
|
9
9
|
dependencies = [
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi_python.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi_python.egg-info/requires.txt
RENAMED
|
File without changes
|
{polyapi_python-0.2.4.dev9 → polyapi_python-0.2.4.dev10}/polyapi_python.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|