Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 10 additions & 1 deletion polyapi/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import os
import sys
import copy
import truststore
from typing import Any, Optional, overload, Literal
from typing_extensions import TypedDict
Expand All @@ -22,6 +23,7 @@ class PolyCustomDict(TypedDict, total=False):
executionApiKey: Optional[str]
responseStatusCode: int
responseContentType: Optional[str]
responseHeaders: Dict[str, str]


class _PolyCustom:
Expand All @@ -31,6 +33,7 @@ def __init__(self):
"executionApiKey": None,
"responseStatusCode": 200,
"responseContentType": None,
"responseHeaders": {},
}
self._execution_id_locked = False

Expand Down Expand Up @@ -63,6 +66,9 @@ def __getitem__(self, key: Literal["responseStatusCode"]) -> int: ...

@overload
def __getitem__(self, key: Literal["responseContentType"]) -> Optional[str]: ...

@overload
def __getitem__(self, key: Literal["responseHeaders"]) -> Dict[str, str]: ...

def __getitem__(self, key: str) -> Any:
return self.get(key)
Expand All @@ -75,6 +81,9 @@ def __setitem__(self, key: Literal["responseStatusCode"], value: int) -> None: .

@overload
def __setitem__(self, key: Literal["responseContentType"], value: Optional[str]) -> None: ...

@overload
def __setitem__(self, key: Literal["responseHeaders"], value: Dict[str, str]) -> None: ...

def __setitem__(self, key: str, value: Any) -> None:
self.set_once(key, value)
Expand All @@ -84,7 +93,7 @@ def __repr__(self) -> str:

def copy(self) -> '_PolyCustom':
new = _PolyCustom()
new._internal_store = self._internal_store.copy()
new._internal_store = copy.deepcopy(self._internal_store)
new._execution_id_locked = self._execution_id_locked
return new

Expand Down
1 change: 1 addition & 0 deletions polyapi/webhook.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ async def handleEvent(data):
"data": resp,
"statusCode": polyCustom.get("responseStatusCode", 200),
"contentType": polyCustom.get("responseContentType", None),
"headers": polyCustom.get("responseHeaders", {{}}),
}},
}}, namespace="/events")

Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]

[project]
name = "polyapi-python"
version = "0.3.7.dev4"
version = "0.3.7.dev5"
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
dependencies = [
Expand Down