polyapi-python 0.3.1.dev4__py3-none-any.whl → 0.3.1.dev6__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
@@ -64,9 +64,10 @@ class SyncDeployment(TypedDict, total=False):
64
64
  context: str
65
65
  name: str
66
66
  description: str
67
- type: str # This should be an enumeration or a predefined set of strings if you have known types.
67
+ type: str
68
68
  fileRevision: str
69
69
  file: str
70
+ types: DeployableFunctionTypes
70
71
  typeSchemas: Dict[str, any]
71
72
  dependencies: List[str]
72
73
  config: Dict[str, any]
polyapi/sync.py CHANGED
@@ -3,6 +3,7 @@ from datetime import datetime
3
3
  from typing import List, Dict
4
4
  import requests
5
5
 
6
+ from polyapi.parser import get_jsonschema_type
6
7
  from polyapi.deployables import (
7
8
  prepare_deployable_directory, load_deployable_records,
8
9
  save_deployable_records, remove_deployable_records,
@@ -25,31 +26,43 @@ def group_by(items: List[Dict], key: str) -> Dict[str, List[Dict]]:
25
26
  grouped.setdefault(item[key], []).append(item)
26
27
  return grouped
27
28
 
28
- def remove_deployable(deployable: SyncDeployment) -> bool:
29
- # Example function call, adjust as needed
30
- url = f"{deployable['instance']}/{deployable['type']}/{deployable['name']}"
29
+ def remove_deployable_function(deployable: SyncDeployment) -> bool:
30
+ url = f'{deployable["instance"]}/functions/{deployable["type"].replace("-function", "")}/{deployable['id']}'
31
31
  response = requests.get(url)
32
32
  if response.status_code != 200:
33
33
  return False
34
34
  requests.delete(url)
35
35
  return True
36
36
 
37
- def sync_deployable_and_get_id(deployable: SyncDeployment, code: str) -> str:
38
- # Example function call, adjust as needed
39
- url = f"{deployable['instance']}/{deployable['type']}"
40
- print(deployable)
37
+ def remove_deployable(deployable: SyncDeployment) -> bool:
38
+
39
+ if deployable["type"] == 'client-function' or deployable["type"] == 'server-function':
40
+ return remove_deployable_function(deployable)
41
+
42
+ raise Exception(f"Unsupported deployable type '{deployable['type']}'")
43
+
44
+ def sync_function_and_get_id(deployable: SyncDeployment, code: str) -> str:
45
+ url = f'{deployable["instance"]}/functions/{deployable["type"].replace("-function", "")}'
41
46
  payload = {
42
47
  "context": deployable["context"],
43
48
  "name": deployable["name"],
44
49
  "description": deployable["description"],
45
50
  "code": code,
46
51
  "typeSchemas": deployable["typeSchemas"],
47
- "config": deployable["config"]
52
+ **deployable["config"],
53
+ "arguments": [{**p, "type": get_jsonschema_type(p["type"]) } for p in deployable["types"]["params"]],
48
54
  }
49
55
  response = requests.post(url, json=payload)
50
56
  response.raise_for_status()
51
57
  return response.json()['id']
52
58
 
59
+ def sync_deployable_and_get_id(deployable: SyncDeployment, code: str) -> str:
60
+
61
+ if deployable["type"] == 'client-function' or deployable["type"] == 'server-function':
62
+ return sync_function_and_get_id(deployable, code)
63
+
64
+ raise Exception(f"Unsupported deployable type '{deployable['type']}'")
65
+
53
66
  def sync_deployable(deployable: SyncDeployment) -> Deployment:
54
67
  code = read_file(deployable['file'])
55
68
  id = sync_deployable_and_get_id(deployable, code)
@@ -93,12 +106,16 @@ def sync_deployables(dry_run: bool, instance: str = os.getenv('POLY_API_BASE_URL
93
106
  # Any deployable may be deployed to multiple instances/environments at the same time
94
107
  # So we reduce the deployable record down to a single instance we want to deploy to
95
108
  if previous_deployment:
96
- sync_deployment = { **deployable, **previous_deployment, "instance": instance }
109
+ sync_deployment = {
110
+ **deployable,
111
+ **previous_deployment,
112
+ "description": deployable["types"]["description"],
113
+ "instance": instance
114
+ }
97
115
  else:
98
116
  sync_deployment = { **deployable, "instance": instance }
99
117
  if git_revision == deployable['gitRevision']:
100
118
  deployment = sync_deployable(sync_deployment)
101
- print(deployment)
102
119
  if previous_deployment:
103
120
  previous_deployment.update(deployment)
104
121
  else:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.3.1.dev4
3
+ Version: 0.3.1.dev6
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
@@ -6,7 +6,7 @@ polyapi/cli.py,sha256=wXR5UE73nk26WQRbE8yK69h3h5udNrZFr85ORhbPnRs,8251
6
6
  polyapi/client.py,sha256=CoFDYvyKsqL4wPQbUDIr0Qb8Q5eD92xN4OEEcJEVuGQ,1296
7
7
  polyapi/config.py,sha256=uvEvOfWYZTLmBmZX-5jJxCzWPpwzVmEOIiQIdi98P4Y,3015
8
8
  polyapi/constants.py,sha256=sc-FnS0SngBLvSu1ZWMs0UCf9EYD1u1Yhfr-sZXGLns,607
9
- polyapi/deployables.py,sha256=L2n0Gx5Ih3NBhjCD8FL0DnmTRasTgQK56aRo8ntZOyo,12010
9
+ polyapi/deployables.py,sha256=qKoyuPUv46yZoLBvSOmk6JsBWqomwJAkadhItp8Lx40,11956
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=kXnvlNQ7nz9cRlV2_5gXH09UCmyiDP5zi3wiAw0uDuk,1943
@@ -18,13 +18,13 @@ polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
18
18
  polyapi/rendered_spec.py,sha256=uaNzBhP4cX7iGfKwzZv0dxMagWzsGeDr0cQYx_AyIhQ,2153
19
19
  polyapi/schema.py,sha256=VVMHAT5yU47cRC7xF44BrmUSemlk5oIKSxH2HTVPaQ8,3169
20
20
  polyapi/server.py,sha256=NzQCZFSAJK7XiRw1kiU_i9uMvgYK7i8qh7UX2xjytJU,1908
21
- polyapi/sync.py,sha256=JZ0Q8QCu8IgdwDIhO8PtDPagcmVanrtGqJIMdLDmai4,5051
21
+ polyapi/sync.py,sha256=LSSpVpCN41AqCk5i08RAr6HVoimf-t0L9f451WdIiTA,5879
22
22
  polyapi/typedefs.py,sha256=jmKprGFQSxmJXvwV53p-MFMcStmTp-tsgsynWjoVmU0,1986
23
23
  polyapi/utils.py,sha256=jzCh-ivKMcgp5fIXynhYmP9UyzsISr9bGGEzdPP8n3w,7644
24
24
  polyapi/variables.py,sha256=d36-trnfTL_8m2NkorMiImb4O3UrJbiFV38CHxV5i0A,4200
25
25
  polyapi/webhook.py,sha256=LWv28c2MLz_OKBI_Nn7WR4C-gs1SWgbdXsoxIIf-9UI,4886
26
- polyapi_python-0.3.1.dev4.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
27
- polyapi_python-0.3.1.dev4.dist-info/METADATA,sha256=AjPecgfD0Sxawugfe8-xdNtUxgkJHiTzL6HBM8E9KTA,5326
28
- polyapi_python-0.3.1.dev4.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
29
- polyapi_python-0.3.1.dev4.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
30
- polyapi_python-0.3.1.dev4.dist-info/RECORD,,
26
+ polyapi_python-0.3.1.dev6.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
27
+ polyapi_python-0.3.1.dev6.dist-info/METADATA,sha256=11a__aaaOPkQEe9K4sp_P-b8d2D2R5zbCJY0gCujRc0,5326
28
+ polyapi_python-0.3.1.dev6.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
29
+ polyapi_python-0.3.1.dev6.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
30
+ polyapi_python-0.3.1.dev6.dist-info/RECORD,,