polyapi-python 0.3.9.dev13__py3-none-any.whl → 0.3.9.dev15__py3-none-any.whl

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/deployables.py CHANGED
@@ -1,4 +1,6 @@
1
1
  import os
2
+ import string
3
+ import random
2
4
  import subprocess
3
5
  import json
4
6
  import hashlib
@@ -76,9 +78,10 @@ class SyncDeployment(TypedDict, total=False):
76
78
  id: Optional[str]
77
79
  deployed: Optional[str]
78
80
 
81
+
79
82
  DeployableTypeEntries: List[Tuple[DeployableTypeNames, DeployableTypes]] = [
80
- ("PolyServerFunction", "server-function"), # type: ignore
81
- ("PolyClientFunction", "client-function"), # type: ignore
83
+ ("PolyServerFunction", "server-function"), # type: ignore
84
+ ("PolyClientFunction", "client-function"), # type: ignore
82
85
  ]
83
86
 
84
87
  DeployableTypeToName: Dict[DeployableTypeNames, DeployableTypes] = {name: type for name, type in DeployableTypeEntries}
@@ -175,7 +178,7 @@ def get_git_revision(branch_or_tag: str = "HEAD") -> str:
175
178
  return check_output(["git", "rev-parse", "--short", branch_or_tag], text=True).strip()
176
179
  except CalledProcessError:
177
180
  # Return a random 7-character hash as a fallback
178
- return "".join(format(ord(str(c)), 'x') for c in os.urandom(4))[:7]
181
+ return "".join([random.choice(string.ascii_letters + string.digits) for _ in range(7)])
179
182
 
180
183
  def get_cache_deployments_revision() -> str:
181
184
  """Retrieve the cache deployments revision from a file."""
polyapi/poly_tables.py CHANGED
@@ -7,6 +7,19 @@ from polyapi.typedefs import TableSpecDto
7
7
  from polyapi.constants import JSONSCHEMA_TO_PYTHON_TYPE_MAP
8
8
 
9
9
 
10
+ def scrub_keys(e: Exception) -> Dict[str, Any]:
11
+ """
12
+ Scrub the keys of an exception to remove sensitive information.
13
+ Returns a dictionary with the error message and type.
14
+ """
15
+ return {
16
+ "error": str(e),
17
+ "type": type(e).__name__,
18
+ "message": str(e),
19
+ "args": getattr(e, 'args', None)
20
+ }
21
+
22
+
10
23
  def execute_query(table_id, method, query):
11
24
  from polyapi import polyCustom
12
25
  from polyapi.poly.client_id import client_id
polyapi/sync.py CHANGED
@@ -24,7 +24,7 @@ def read_file(file_path: str) -> str:
24
24
  return file.read()
25
25
 
26
26
  def group_by(items: List[Dict], key: str) -> Dict[str, List[Dict]]:
27
- grouped = {}
27
+ grouped = {} # type: ignore
28
28
  for item in items:
29
29
  grouped.setdefault(item[key], []).append(item)
30
30
  return grouped
@@ -32,7 +32,7 @@ def group_by(items: List[Dict], key: str) -> Dict[str, List[Dict]]:
32
32
  def remove_deployable_function(deployable: SyncDeployment) -> bool:
33
33
  api_key, _ = get_api_key_and_url()
34
34
  if not api_key:
35
- raise Error("Missing api key!")
35
+ raise Exception("Missing api key!")
36
36
  headers = get_auth_headers(api_key)
37
37
  url = f'{deployable["instance"]}/functions/{deployable["type"].replace("-function", "")}/{deployable["id"]}'
38
38
  response = requests.get(url, headers=headers)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: polyapi-python
3
- Version: 0.3.9.dev13
3
+ Version: 0.3.9.dev15
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
@@ -110,24 +110,6 @@ def bar():
110
110
  return "Hello World"
111
111
  ```
112
112
 
113
- ## See Server Function Logs
114
-
115
- In order to see function logs, please first set `logsEnabled` to `true` in Canopy for the function.
116
-
117
- https://na1.polyapi.io/canopy/polyui/collections/server-functions
118
-
119
- Then in your code, get the poly logger and log with it like so:
120
-
121
- ```python
122
- logger = logging.getLogger("poly")
123
- def bar():
124
- logger.warning("I AM THE LOG")
125
- return "Hello World"
126
- ```
127
-
128
- Finally, click the "Show Logs" button to see your server function logs in Canopy!
129
-
130
-
131
113
  ## Complex Types In Server Functions
132
114
 
133
115
  You can define arbitrarily complex argument and return types using TypedDicts.
@@ -6,7 +6,7 @@ polyapi/cli.py,sha256=unKqAoZ1hTGAeyYRfNQ6jO15Um7N4F95k__1qFue5bI,10659
6
6
  polyapi/client.py,sha256=DW6ljG_xCwAo2yz23A9QfLooE6ZUDvSpdA4e_dCQjiQ,1418
7
7
  polyapi/config.py,sha256=cAMv2n9tGN_BTvqt7V32o5F86qRhxAKyey_PoId2D8s,7638
8
8
  polyapi/constants.py,sha256=sc-FnS0SngBLvSu1ZWMs0UCf9EYD1u1Yhfr-sZXGLns,607
9
- polyapi/deployables.py,sha256=W8K6D8dypqntwjC9jAHxoR7hTfnG3Oj49nVULtq1OTQ,12133
9
+ polyapi/deployables.py,sha256=6R7XSgpTohZBcqoGd7GioQdXXKuvbBsdq_cAJ1p8jfQ,12184
10
10
  polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
11
11
  polyapi/exceptions.py,sha256=Zh7i7eCUhDuXEdUYjatkLFTeZkrx1BJ1P5ePgbJ9eIY,89
12
12
  polyapi/execute.py,sha256=q4xtV6rYO8f-8hULlFTlVgoTVQSahvlMu3FHkFzYpMs,4423
@@ -14,19 +14,19 @@ polyapi/function_cli.py,sha256=H0sVrbvRBXw_xeApe2MvQw8p_xE7jVTTOU-07Dg041A,4220
14
14
  polyapi/generate.py,sha256=thOrjq4suOkR97x00rthor96aslzzOaAAo4yxLtiuh0,21081
15
15
  polyapi/parser.py,sha256=20ZE7kSXx3UL7QVSIYYxzsnJlygVbsaDAg9q7c41WxQ,20695
16
16
  polyapi/poly_schemas.py,sha256=fZ6AGvHcOKQJtlrzSuzeBNed5DxPMA2dJGdJvuFCHWM,9066
17
- polyapi/poly_tables.py,sha256=gRLGnNnLdFYuSfy-7gg4hjzzeVak8LJkfLX6n0u4RJg,15559
17
+ polyapi/poly_tables.py,sha256=adftBHGncvxpPchpjfFwDjQncVn9lZTrRHNroei4Nw0,15897
18
18
  polyapi/prepare.py,sha256=NQzpMIoakNovStvOGOmqSYIpTwiWXaweNSE9se10A2E,7420
19
19
  polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
20
20
  polyapi/rendered_spec.py,sha256=nJEj2vRgG3N20fU4s-ThRtOIwAuTzXwXuOBIkXljDVc,2240
21
21
  polyapi/schema.py,sha256=-mtRV5iL3CV0X3phXhGYFV8sLz0KouTACOKWyGO9Pwc,5309
22
22
  polyapi/server.py,sha256=YXWxhYBx-hluwDQ8Jvfpy2s8ogz0GsNTMcZVNcP5ca8,2147
23
- polyapi/sync.py,sha256=5iiQHu76my2AuGVoPRjD2t9Y0VvGJCZ8W2uG0F1sWPY,6722
23
+ polyapi/sync.py,sha256=52ODc82jBJpbNYTB9zXlrVZLR39iwDPW3cuIC3P8dbM,6742
24
24
  polyapi/typedefs.py,sha256=VEaYODLm-3a26_cK1uSRoYwenmprLOQQdoKFz4gqK_0,5587
25
25
  polyapi/utils.py,sha256=RpkXWi6jiwjozrX9iovPBK708w0W117ueN41uhQgnZU,12567
26
26
  polyapi/variables.py,sha256=SJv106ePpQP5mx7Iiafl_shtFlE8FoaO9Q8lvw-3IRg,7270
27
27
  polyapi/webhook.py,sha256=I3_uOl4f4L2-2WehzRLMVMRrB-76EiXCPA9Vzoaj30I,5326
28
- polyapi_python-0.3.9.dev13.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
29
- polyapi_python-0.3.9.dev13.dist-info/METADATA,sha256=T4AzW7yA3-JgL5qSCqQ3ZwGiQo1Wfd_87nC5wr-zkcs,5785
30
- polyapi_python-0.3.9.dev13.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
- polyapi_python-0.3.9.dev13.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
32
- polyapi_python-0.3.9.dev13.dist-info/RECORD,,
28
+ polyapi_python-0.3.9.dev15.dist-info/licenses/LICENSE,sha256=6b_I7aPVp8JXhqQwdw7_B84Ca0S4JGjHj0sr_1VOdB4,1068
29
+ polyapi_python-0.3.9.dev15.dist-info/METADATA,sha256=S6ra-8aBsNYAPAJZCDaKOg5AR9ledzZi54ouWFWlhjQ,5318
30
+ polyapi_python-0.3.9.dev15.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
31
+ polyapi_python-0.3.9.dev15.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
32
+ polyapi_python-0.3.9.dev15.dist-info/RECORD,,