polyapi-python 0.2.7.dev3__tar.gz → 0.2.8__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.
Files changed (39) hide show
  1. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/PKG-INFO +20 -2
  2. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/README.md +18 -0
  3. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/api.py +2 -2
  4. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/client.py +1 -1
  5. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/server.py +2 -2
  6. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/utils.py +16 -5
  7. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi_python.egg-info/PKG-INFO +20 -2
  8. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/pyproject.toml +2 -2
  9. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_utils.py +5 -1
  10. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/LICENSE +0 -0
  11. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/__init__.py +0 -0
  12. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/__main__.py +0 -0
  13. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/auth.py +0 -0
  14. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/cli.py +0 -0
  15. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/config.py +0 -0
  16. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/constants.py +0 -0
  17. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/error_handler.py +0 -0
  18. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/exceptions.py +0 -0
  19. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/execute.py +0 -0
  20. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/function_cli.py +0 -0
  21. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/generate.py +0 -0
  22. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/py.typed +0 -0
  23. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/rendered_spec.py +0 -0
  24. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/schema.py +0 -0
  25. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/typedefs.py +0 -0
  26. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/variables.py +0 -0
  27. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi/webhook.py +0 -0
  28. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi_python.egg-info/SOURCES.txt +0 -0
  29. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi_python.egg-info/dependency_links.txt +0 -0
  30. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi_python.egg-info/requires.txt +0 -0
  31. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/polyapi_python.egg-info/top_level.txt +0 -0
  32. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/setup.cfg +0 -0
  33. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_api.py +0 -0
  34. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_auth.py +0 -0
  35. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_function_cli.py +0 -0
  36. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_rendered_spec.py +0 -0
  37. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_schema.py +0 -0
  38. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_server.py +0 -0
  39. {polyapi_python-0.2.7.dev3 → polyapi_python-0.2.8}/tests/test_variables.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.2.7.dev3
3
+ Version: 0.2.8
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -25,7 +25,7 @@ License: MIT License
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
27
  Project-URL: Homepage, https://github.com/polyapi/polyapi-python
28
- Requires-Python: >=3.10
28
+ Requires-Python: <=3.12,>=3.10
29
29
  Description-Content-Type: text/markdown
30
30
  License-File: LICENSE
31
31
  Requires-Dist: requests==2.31.0
@@ -109,6 +109,24 @@ def bar():
109
109
  return "Hello World"
110
110
  ```
111
111
 
112
+ ## See Server Function Logs
113
+
114
+ In order to see function logs, please first set `logsEnabled` to `true` in Canopy for the function.
115
+
116
+ https://na1.polyapi.io/canopy/polyui/collections/server-functions
117
+
118
+ Then in your code, get the poly logger and log with it like so:
119
+
120
+ ```python
121
+ logger = logging.getLogger("poly")
122
+ def bar():
123
+ logger.warning("I AM THE LOG")
124
+ return "Hello World"
125
+ ```
126
+
127
+ Finally, click the "Show Logs" button to see your server function logs in Canopy!
128
+
129
+
112
130
  ## Complex Types In Server Functions
113
131
 
114
132
  You can define arbitrarily complex argument and return types using TypedDicts.
@@ -70,6 +70,24 @@ def bar():
70
70
  return "Hello World"
71
71
  ```
72
72
 
73
+ ## See Server Function Logs
74
+
75
+ In order to see function logs, please first set `logsEnabled` to `true` in Canopy for the function.
76
+
77
+ https://na1.polyapi.io/canopy/polyui/collections/server-functions
78
+
79
+ Then in your code, get the poly logger and log with it like so:
80
+
81
+ ```python
82
+ logger = logging.getLogger("poly")
83
+ def bar():
84
+ logger.warning("I AM THE LOG")
85
+ return "Hello World"
86
+ ```
87
+
88
+ Finally, click the "Show Logs" button to see your server function logs in Canopy!
89
+
90
+
73
91
  ## Complex Types In Server Functions
74
92
 
75
93
  You can define arbitrarily complex argument and return types using TypedDicts.
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, List, Tuple
2
2
 
3
3
  from polyapi.typedefs import PropertySpecification
4
- from polyapi.utils import add_type_import_path, camelCase, parse_arguments, get_type_and_def
4
+ from polyapi.utils import add_type_import_path, parse_arguments, get_type_and_def, rewrite_arg_name
5
5
 
6
6
 
7
7
  API_DEFS_TEMPLATE = """
@@ -41,7 +41,7 @@ def render_api_function(
41
41
  arg_names = [a["name"] for a in arguments]
42
42
  args, args_def = parse_arguments(function_name, arguments)
43
43
  return_type_name, return_type_def = get_type_and_def(return_type) # type: ignore
44
- data = "{" + ", ".join([f"'{arg}': {camelCase(arg)}" for arg in arg_names]) + "}"
44
+ data = "{" + ", ".join([f"'{arg}': {rewrite_arg_name(arg)}" for arg in arg_names]) + "}"
45
45
 
46
46
  api_response_type = f"{function_name}Response"
47
47
  func_type_defs = API_DEFS_TEMPLATE.format(
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, List, Tuple
2
2
 
3
3
  from polyapi.typedefs import PropertySpecification
4
- from polyapi.utils import camelCase, add_type_import_path, parse_arguments, get_type_and_def
4
+ from polyapi.utils import parse_arguments, get_type_and_def
5
5
 
6
6
  DEFS_TEMPLATE = """
7
7
  from typing import List, Dict, Any, TypedDict
@@ -1,7 +1,7 @@
1
1
  from typing import Any, Dict, List, Tuple
2
2
 
3
3
  from polyapi.typedefs import PropertySpecification
4
- from polyapi.utils import camelCase, add_type_import_path, parse_arguments, get_type_and_def
4
+ from polyapi.utils import add_type_import_path, parse_arguments, get_type_and_def, rewrite_arg_name
5
5
 
6
6
  SERVER_DEFS_TEMPLATE = """
7
7
  from typing import List, Dict, Any, TypedDict, Callable
@@ -38,7 +38,7 @@ def render_server_function(
38
38
  arg_names = [a["name"] for a in arguments]
39
39
  args, args_def = parse_arguments(function_name, arguments)
40
40
  return_type_name, return_type_def = get_type_and_def(return_type) # type: ignore
41
- data = "{" + ", ".join([f"'{arg}': {camelCase(arg)}" for arg in arg_names]) + "}"
41
+ data = "{" + ", ".join([f"'{arg}': {rewrite_arg_name(arg)}" for arg in arg_names]) + "}"
42
42
  func_type_defs = SERVER_DEFS_TEMPLATE.format(
43
43
  args_def=args_def,
44
44
  return_type_def=return_type_def,
@@ -1,3 +1,4 @@
1
+ import keyword
1
2
  import re
2
3
  import os
3
4
  from typing import Tuple, List
@@ -164,9 +165,10 @@ def parse_arguments(function_name: str, arguments: List[PropertySpecification])
164
165
  arg_type, arg_def = get_type_and_def(a["type"])
165
166
  if arg_def:
166
167
  args_def.append(arg_def)
167
- a["name"] = camelCase(a["name"])
168
+ a["name"] = rewrite_arg_name(a["name"])
168
169
  arg_string += f" {a['name']}: {add_type_import_path(function_name, arg_type)}"
169
170
  description = a.get("description", "")
171
+ description = description.replace("\n", " ")
170
172
  if description:
171
173
  if idx == len(arguments) - 1:
172
174
  arg_string += f" # {description}\n"
@@ -186,7 +188,7 @@ def poly_full_path(context, name) -> str:
186
188
  return f"poly.{path}"
187
189
 
188
190
 
189
- RESERVED_TYPES = {"List", "Dict", "Any", "Optional", "Callable"}
191
+ RESERVED_WORDS = {"List", "Dict", "Any", "Optional", "Callable"} | set(keyword.kwlist)
190
192
 
191
193
 
192
194
  def to_func_namespace(s: str) -> str:
@@ -194,7 +196,16 @@ def to_func_namespace(s: str) -> str:
194
196
  by default it is
195
197
  """
196
198
  rv = s[0].upper() + s[1:]
197
- if rv in RESERVED_TYPES:
198
- return "_" + rv
199
+ rv = rewrite_reserved(rv)
200
+ return rv
201
+
202
+
203
+ def rewrite_reserved(s: str) -> str:
204
+ if s in RESERVED_WORDS:
205
+ return "_" + s
199
206
  else:
200
- return rv
207
+ return s
208
+
209
+
210
+ def rewrite_arg_name(s: str):
211
+ return rewrite_reserved(camelCase(s))
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.2.7.dev3
3
+ Version: 0.2.8
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -25,7 +25,7 @@ License: MIT License
25
25
  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
26
26
  SOFTWARE.
27
27
  Project-URL: Homepage, https://github.com/polyapi/polyapi-python
28
- Requires-Python: >=3.10
28
+ Requires-Python: <=3.12,>=3.10
29
29
  Description-Content-Type: text/markdown
30
30
  License-File: LICENSE
31
31
  Requires-Dist: requests==2.31.0
@@ -109,6 +109,24 @@ def bar():
109
109
  return "Hello World"
110
110
  ```
111
111
 
112
+ ## See Server Function Logs
113
+
114
+ In order to see function logs, please first set `logsEnabled` to `true` in Canopy for the function.
115
+
116
+ https://na1.polyapi.io/canopy/polyui/collections/server-functions
117
+
118
+ Then in your code, get the poly logger and log with it like so:
119
+
120
+ ```python
121
+ logger = logging.getLogger("poly")
122
+ def bar():
123
+ logger.warning("I AM THE LOG")
124
+ return "Hello World"
125
+ ```
126
+
127
+ Finally, click the "Show Logs" button to see your server function logs in Canopy!
128
+
129
+
112
130
  ## Complex Types In Server Functions
113
131
 
114
132
  You can define arbitrarily complex argument and return types using TypedDicts.
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
3
3
 
4
4
  [project]
5
5
  name = "polyapi-python"
6
- version = "0.2.7.dev3"
6
+ version = "0.2.8"
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 = [
@@ -18,7 +18,7 @@ dependencies = [
18
18
  ]
19
19
  readme = "README.md"
20
20
  license = { file = "LICENSE" }
21
- requires-python = ">=3.10"
21
+ requires-python = ">=3.10,<=3.12"
22
22
 
23
23
  [project.urls]
24
24
  Homepage = "https://github.com/polyapi/polyapi-python"
@@ -1,5 +1,5 @@
1
1
  import unittest
2
- from polyapi.utils import get_type_and_def
2
+ from polyapi.utils import get_type_and_def, rewrite_reserved
3
3
 
4
4
  OPENAPI_FUNCTION = {'kind': 'function', 'spec': {'arguments': [{'name': 'event', 'required': False, 'type': {'kind': 'object', 'schema': {'$schema': 'http://json-schema.org/draft-06/schema#', 'type': 'array', 'items': {'$ref': '#/definitions/WebhookEventTypeElement'}, 'definitions': {'WebhookEventTypeElement': {'type': 'object', 'additionalProperties': False, 'properties': {'title': {'type': 'string'}, 'manufacturerName': {'type': 'string'}, 'carType': {'type': 'string'}, 'id': {'type': 'integer'}}, 'required': ['carType', 'id', 'manufacturerName', 'title'], 'title': 'WebhookEventTypeElement'}}}}}, {'name': 'headers', 'required': False, 'type': {'kind': 'object', 'typeName': 'Record<string, any>'}}, {'name': 'params', 'required': False, 'type': {'kind': 'object', 'typeName': 'Record<string, any>'}}, {'name': 'polyCustom', 'required': False, 'type': {'kind': 'object', 'properties': [{'name': 'responseStatusCode', 'type': {'type': 'number', 'kind': 'primitive'}, 'required': True}, {'name': 'responseContentType', 'type': {'type': 'string', 'kind': 'primitive'}, 'required': True, 'nullable': True}]}}], 'returnType': {'kind': 'void'}, 'synchronous': True}}
5
5
 
@@ -8,3 +8,7 @@ class T(unittest.TestCase):
8
8
  def test_get_type_and_def(self):
9
9
  arg_type, arg_def = get_type_and_def(OPENAPI_FUNCTION)
10
10
  self.assertEqual(arg_type, "Callable[[List[WebhookEventTypeElement], Dict, Dict, Dict], None]")
11
+
12
+ def test_rewrite_reserved(self):
13
+ rv = rewrite_reserved("from")
14
+ self.assertEqual(rv, "_from")