polyapi-python 0.3.1.dev7__py3-none-any.whl → 0.3.1.dev8__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 +8 -3
- polyapi/sync.py +9 -3
- {polyapi_python-0.3.1.dev7.dist-info → polyapi_python-0.3.1.dev8.dist-info}/METADATA +1 -1
- {polyapi_python-0.3.1.dev7.dist-info → polyapi_python-0.3.1.dev8.dist-info}/RECORD +7 -7
- {polyapi_python-0.3.1.dev7.dist-info → polyapi_python-0.3.1.dev8.dist-info}/LICENSE +0 -0
- {polyapi_python-0.3.1.dev7.dist-info → polyapi_python-0.3.1.dev8.dist-info}/WHEEL +0 -0
- {polyapi_python-0.3.1.dev7.dist-info → polyapi_python-0.3.1.dev8.dist-info}/top_level.txt +0 -0
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
|
-
|
|
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("
|
|
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("
|
|
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,6 +46,8 @@ 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"],
|
|
@@ -52,7 +58,7 @@ def sync_function_and_get_id(deployable: SyncDeployment, code: str) -> str:
|
|
|
52
58
|
**deployable["config"],
|
|
53
59
|
"arguments": [{**p, "type": get_jsonschema_type(p["type"]) } for p in deployable["types"]["params"]],
|
|
54
60
|
}
|
|
55
|
-
response = requests.post(url, json=payload)
|
|
61
|
+
response = requests.post(url, headers=headers, json=payload)
|
|
56
62
|
response.raise_for_status()
|
|
57
63
|
return response.json()['id']
|
|
58
64
|
|
|
@@ -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=
|
|
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=
|
|
21
|
+
polyapi/sync.py,sha256=4AMEu7900T-3UmUl7FC8GaubGxu_n8MP6BLf5SLhLBk,6170
|
|
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.
|
|
27
|
-
polyapi_python-0.3.1.
|
|
28
|
-
polyapi_python-0.3.1.
|
|
29
|
-
polyapi_python-0.3.1.
|
|
30
|
-
polyapi_python-0.3.1.
|
|
26
|
+
polyapi_python-0.3.1.dev8.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
|
|
27
|
+
polyapi_python-0.3.1.dev8.dist-info/METADATA,sha256=t1pHAF2Pg0l30M-d3IHPFfLrv-pD8HuwQqGbVwIkSds,5326
|
|
28
|
+
polyapi_python-0.3.1.dev8.dist-info/WHEEL,sha256=R06PA3UVYHThwHvxuRWMqaGcr-PuniXahwjmQRFMEkY,91
|
|
29
|
+
polyapi_python-0.3.1.dev8.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
|
|
30
|
+
polyapi_python-0.3.1.dev8.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|