polyapi-python 0.3.1.dev7__py3-none-any.whl → 0.3.1.dev9__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/prepare.py CHANGED
@@ -3,6 +3,8 @@ import sys
3
3
  from typing import List, Tuple, Literal
4
4
  import requests
5
5
 
6
+ from polyapi.utils import get_auth_headers
7
+ from polyapi.config import get_api_key_and_url
6
8
  from polyapi.parser import parse_function_code
7
9
  from polyapi.deployables import (
8
10
  prepare_deployable_directory, write_cache_revision,
@@ -26,15 +28,18 @@ def get_function_description(deploy_type: Literal["server-function", "client-fun
26
28
  raise ValueError("Unsupported deployable type")
27
29
 
28
30
  def get_server_function_description(description: str, arguments, code: str) -> str:
29
- # Simulated API call to generate server function descriptions
31
+ api_key, api_url = get_api_key_and_url()
32
+ headers = get_auth_headers(api_key)
30
33
  data = {"description": description, "arguments": arguments, "code": code}
31
- response = requests.post("http://your-api-url/server-function-description", json=data)
34
+ response = requests.post(f"{api_url}/server-function-description", headers=headers, json=data)
32
35
  return response.json()
33
36
 
34
37
  def get_client_function_description(description: str, arguments, code: str) -> str:
38
+ api_key, api_url = get_api_key_and_url()
39
+ headers = get_auth_headers(api_key)
35
40
  # Simulated API call to generate client function descriptions
36
41
  data = {"description": description, "arguments": arguments, "code": code}
37
- response = requests.post("http://your-api-url/client-function-description", json=data)
42
+ response = requests.post(f"{api_url}/client-function-description", headers=headers, json=data)
38
43
  return response.json()
39
44
 
40
45
  def fill_in_missing_function_details(deployable: DeployableRecord, code: str) -> DeployableRecord:
polyapi/sync.py CHANGED
@@ -3,6 +3,8 @@ from datetime import datetime
3
3
  from typing import List, Dict
4
4
  import requests
5
5
 
6
+ from polyapi.utils import get_auth_headers
7
+ from polyapi.config import get_api_key_and_url
6
8
  from polyapi.parser import get_jsonschema_type
7
9
  from polyapi.deployables import (
8
10
  prepare_deployable_directory, load_deployable_records,
@@ -27,11 +29,13 @@ def group_by(items: List[Dict], key: str) -> Dict[str, List[Dict]]:
27
29
  return grouped
28
30
 
29
31
  def remove_deployable_function(deployable: SyncDeployment) -> bool:
32
+ api_key, _ = get_api_key_and_url()
33
+ headers = get_auth_headers(api_key)
30
34
  url = f'{deployable["instance"]}/functions/{deployable["type"].replace("-function", "")}/{deployable["id"]}'
31
- response = requests.get(url)
35
+ response = requests.get(url, headers=headers)
32
36
  if response.status_code != 200:
33
37
  return False
34
- requests.delete(url)
38
+ requests.delete(url, headers)
35
39
  return True
36
40
 
37
41
  def remove_deployable(deployable: SyncDeployment) -> bool:
@@ -42,17 +46,21 @@ def remove_deployable(deployable: SyncDeployment) -> bool:
42
46
  raise Exception(f"Unsupported deployable type '{deployable['type']}'")
43
47
 
44
48
  def sync_function_and_get_id(deployable: SyncDeployment, code: str) -> str:
49
+ api_key, _ = get_api_key_and_url()
50
+ headers = get_auth_headers(api_key)
45
51
  url = f'{deployable["instance"]}/functions/{deployable["type"].replace("-function", "")}'
46
52
  payload = {
47
53
  "context": deployable["context"],
48
54
  "name": deployable["name"],
49
55
  "description": deployable["description"],
50
56
  "code": code,
51
- "typeSchemas": deployable["typeSchemas"],
57
+ "language": "python",
58
+ "returnType": deployable["types"]["returns"]["type"],
59
+ "returnTypeSchema": deployable["types"]["returns"]["typeSchema"],
52
60
  **deployable["config"],
53
61
  "arguments": [{**p, "type": get_jsonschema_type(p["type"]) } for p in deployable["types"]["params"]],
54
62
  }
55
- response = requests.post(url, json=payload)
63
+ response = requests.post(url, headers=headers, json=payload)
56
64
  response.raise_for_status()
57
65
  return response.json()['id']
58
66
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.3.1.dev7
3
+ Version: 0.3.1.dev9
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
@@ -13,18 +13,18 @@ polyapi/execute.py,sha256=kXnvlNQ7nz9cRlV2_5gXH09UCmyiDP5zi3wiAw0uDuk,1943
13
13
  polyapi/function_cli.py,sha256=TDoSuhj7lkx3LZfI4ndL0v1VJrKm-UNycoAO5EpZydA,4147
14
14
  polyapi/generate.py,sha256=SIRfN7RF3Z7eQ8kSNg4H70LeT7Hmh-Mn5maibvM7kAM,7969
15
15
  polyapi/parser.py,sha256=ySPA-pFllc-UuRc1vN3xuDqGSGZR1uo90Lk0VP_v5ak,20130
16
- polyapi/prepare.py,sha256=4n7N5mSAHsjlpw56K_q45T4utpDpfT0atXZJ_Vn77Bg,6374
16
+ polyapi/prepare.py,sha256=uwW3oyn-2klLXib4ZBLSbul4pBMlqmhQjqkP_IGFWIY,6584
17
17
  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=mH5MJORnCOZfsRktfluu-AuUd7vMUj4za2DPkX1DCHY,5879
21
+ polyapi/sync.py,sha256=umI20a_EMRJ4OJeDlJviLM4QiXl9pLzH0T2TiEhIv2A,6286
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.dev7.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
27
- polyapi_python-0.3.1.dev7.dist-info/METADATA,sha256=06tVm37czXvuRSjbHPBiiFGDiE2OEpV6hkP1kahYkSU,5326
28
- polyapi_python-0.3.1.dev7.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
29
- polyapi_python-0.3.1.dev7.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
30
- polyapi_python-0.3.1.dev7.dist-info/RECORD,,
26
+ polyapi_python-0.3.1.dev9.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
27
+ polyapi_python-0.3.1.dev9.dist-info/METADATA,sha256=VV6QMnrjYHJr6PulEF9ZcJxH6klfpbKm3913kaCoGxU,5326
28
+ polyapi_python-0.3.1.dev9.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
29
+ polyapi_python-0.3.1.dev9.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
30
+ polyapi_python-0.3.1.dev9.dist-info/RECORD,,