polyapi-python 0.2.5.dev3__py3-none-any.whl → 0.2.5.dev5__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/cli.py +11 -5
- polyapi/rendered_spec.py +34 -5
- {polyapi_python-0.2.5.dev3.dist-info → polyapi_python-0.2.5.dev5.dist-info}/METADATA +1 -1
- {polyapi_python-0.2.5.dev3.dist-info → polyapi_python-0.2.5.dev5.dist-info}/RECORD +7 -7
- {polyapi_python-0.2.5.dev3.dist-info → polyapi_python-0.2.5.dev5.dist-info}/LICENSE +0 -0
- {polyapi_python-0.2.5.dev3.dist-info → polyapi_python-0.2.5.dev5.dist-info}/WHEEL +0 -0
- {polyapi_python-0.2.5.dev3.dist-info → polyapi_python-0.2.5.dev5.dist-info}/top_level.txt +0 -0
polyapi/cli.py
CHANGED
|
@@ -5,10 +5,10 @@ from polyapi.utils import print_green
|
|
|
5
5
|
from .config import clear_config, set_api_key_and_url
|
|
6
6
|
from .generate import generate, clear
|
|
7
7
|
from .function_cli import function_add_or_update
|
|
8
|
-
from .rendered_spec import
|
|
8
|
+
from .rendered_spec import get_and_update_rendered_spec
|
|
9
9
|
|
|
10
10
|
|
|
11
|
-
CLI_COMMANDS = ["setup", "generate", "function", "clear", "help", "
|
|
11
|
+
CLI_COMMANDS = ["setup", "generate", "function", "clear", "help", "update_rendered_spec"]
|
|
12
12
|
|
|
13
13
|
CLIENT_DESC = """Commands
|
|
14
14
|
python -m polyapi setup Setup your Poly connection
|
|
@@ -18,7 +18,7 @@ CLIENT_DESC = """Commands
|
|
|
18
18
|
"""
|
|
19
19
|
|
|
20
20
|
|
|
21
|
-
def execute_from_cli():
|
|
21
|
+
def execute_from_cli() -> None:
|
|
22
22
|
parser = argparse.ArgumentParser(
|
|
23
23
|
prog="python -m polyapi", description=CLIENT_DESC, formatter_class=argparse.RawTextHelpFormatter
|
|
24
24
|
)
|
|
@@ -43,8 +43,14 @@ def execute_from_cli():
|
|
|
43
43
|
elif command == "setup":
|
|
44
44
|
clear_config()
|
|
45
45
|
generate()
|
|
46
|
-
elif command == "
|
|
47
|
-
|
|
46
|
+
elif command == "update_rendered_spec":
|
|
47
|
+
assert len(args.subcommands) == 2
|
|
48
|
+
updated = get_and_update_rendered_spec(args.subcommands[0], args.subcommands[1])
|
|
49
|
+
if updated:
|
|
50
|
+
print("Updated rendered spec!")
|
|
51
|
+
else:
|
|
52
|
+
print("Failed to update rendered spec!")
|
|
53
|
+
exit(1)
|
|
48
54
|
elif command == "clear":
|
|
49
55
|
print("Clearing the generated library...")
|
|
50
56
|
clear()
|
polyapi/rendered_spec.py
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
from typing import Dict
|
|
1
|
+
from typing import Dict, Optional
|
|
2
|
+
|
|
3
|
+
import requests
|
|
4
|
+
from polyapi.config import get_api_key_and_url
|
|
2
5
|
from polyapi.generate import read_cached_specs, render_spec
|
|
3
|
-
from polyapi.execute import execute_post
|
|
4
6
|
from polyapi.typedefs import SpecificationDto
|
|
5
7
|
|
|
6
8
|
|
|
7
|
-
def update_rendered_spec(spec: SpecificationDto):
|
|
9
|
+
def update_rendered_spec(api_key: str, spec: SpecificationDto):
|
|
8
10
|
print("Updating rendered spec...")
|
|
9
11
|
func_str, type_defs = render_spec(spec)
|
|
10
12
|
data = {
|
|
@@ -19,11 +21,38 @@ def update_rendered_spec(spec: SpecificationDto):
|
|
|
19
21
|
else:
|
|
20
22
|
raise NotImplementedError("todo")
|
|
21
23
|
|
|
22
|
-
|
|
24
|
+
# use super key on develop-k8s here!
|
|
25
|
+
_, base_url = get_api_key_and_url()
|
|
26
|
+
url = f"{base_url}/functions/rendered-specs"
|
|
27
|
+
headers = {"Authorization": f"Bearer {api_key}"}
|
|
28
|
+
resp = requests.post(url, json=data, headers=headers)
|
|
23
29
|
assert resp.status_code == 201, (resp.text, resp.status_code)
|
|
24
30
|
# this needs to run with something like `kn func run...`
|
|
25
31
|
|
|
26
32
|
|
|
33
|
+
def _get_spec(api_key: str, spec_id: str) -> Optional[SpecificationDto]:
|
|
34
|
+
_, base_url = get_api_key_and_url()
|
|
35
|
+
url = f"{base_url}/specs"
|
|
36
|
+
headers = {"Authorization": f"Bearer {api_key}"}
|
|
37
|
+
resp = requests.get(url, headers=headers)
|
|
38
|
+
if resp.status_code == 200:
|
|
39
|
+
specs = resp.json()
|
|
40
|
+
for spec in specs:
|
|
41
|
+
if spec['id'] == spec_id:
|
|
42
|
+
return spec
|
|
43
|
+
return None
|
|
44
|
+
else:
|
|
45
|
+
raise NotImplementedError(resp.content)
|
|
46
|
+
|
|
47
|
+
|
|
48
|
+
def get_and_update_rendered_spec(api_key: str, spec_id: str) -> bool:
|
|
49
|
+
spec = _get_spec(api_key, spec_id)
|
|
50
|
+
if spec:
|
|
51
|
+
update_rendered_spec(api_key, spec)
|
|
52
|
+
return True
|
|
53
|
+
return False
|
|
54
|
+
|
|
55
|
+
|
|
27
56
|
def save_rendered_specs() -> None:
|
|
28
57
|
specs = read_cached_specs()
|
|
29
58
|
# right now we just support rendered apiFunctions
|
|
@@ -31,4 +60,4 @@ def save_rendered_specs() -> None:
|
|
|
31
60
|
for spec in api_specs:
|
|
32
61
|
assert spec["function"]
|
|
33
62
|
print("adding", spec["context"], spec["name"])
|
|
34
|
-
update_rendered_spec(spec)
|
|
63
|
+
update_rendered_spec("FIXME", spec)
|
|
@@ -2,7 +2,7 @@ polyapi/__init__.py,sha256=5iujRodfgRyLxT-zY0L3xax3rKRvfSt4NZlZYKOz03w,608
|
|
|
2
2
|
polyapi/__main__.py,sha256=V4zhAh_YGxno5f_KSrlkELxcuDh9bR3WSd0n-2r-qQQ,93
|
|
3
3
|
polyapi/api.py,sha256=bE651P47RuhqNYkVyvTH_pA44JypRZED_2M5UG_qzDI,1863
|
|
4
4
|
polyapi/auth.py,sha256=zrIGatjba5GwUTNjKj1GHQWTEDP9B-HrSzCKbLFoqvc,5336
|
|
5
|
-
polyapi/cli.py,sha256=
|
|
5
|
+
polyapi/cli.py,sha256=QYsZmsnVLsf4LgE4iN7Tse1rrlTpycgG9nuL3Uoq9HU,2484
|
|
6
6
|
polyapi/client.py,sha256=w15XOABkwdL4V4r2iWY_nypzLjvoKVuux8jUKbA16pQ,1329
|
|
7
7
|
polyapi/config.py,sha256=S8TU10upy5OW1_vX-CqQTJD-ZOB6329aMjiUCmukfUI,2292
|
|
8
8
|
polyapi/constants.py,sha256=sc-FnS0SngBLvSu1ZWMs0UCf9EYD1u1Yhfr-sZXGLns,607
|
|
@@ -12,15 +12,15 @@ polyapi/execute.py,sha256=kXnvlNQ7nz9cRlV2_5gXH09UCmyiDP5zi3wiAw0uDuk,1943
|
|
|
12
12
|
polyapi/function_cli.py,sha256=4G4xqDCF7HSVERXRJx1D3uytNI1_mhaU-bNFeNRsQ3E,9231
|
|
13
13
|
polyapi/generate.py,sha256=dtS6Wyb_lq9FrOs7NA_ceKCX9rogx2_3Fp57_hGwdDc,7957
|
|
14
14
|
polyapi/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
polyapi/rendered_spec.py,sha256=
|
|
15
|
+
polyapi/rendered_spec.py,sha256=1jRiV4P5qUH8NAO2CSD4TvgTEV149jHyOqLxQKthpwM,2090
|
|
16
16
|
polyapi/schema.py,sha256=VQl3YJNiejShAcgPHq3IyRMiwpVEy52Jq5alB-65udg,2956
|
|
17
17
|
polyapi/server.py,sha256=n-nMGjXoq9T9ZwE2EBDkAaxJ7UytConGaHthkjbkCXA,1894
|
|
18
18
|
polyapi/typedefs.py,sha256=mRqwd2LKofxNn_VSKxBzixni2j-tai8mfTQ0Wi2aLNM,1487
|
|
19
19
|
polyapi/utils.py,sha256=CXzQC5u8vNMyS7f3E45plSuB2EodevDmkOXhHA2zxoc,7108
|
|
20
20
|
polyapi/variables.py,sha256=d36-trnfTL_8m2NkorMiImb4O3UrJbiFV38CHxV5i0A,4200
|
|
21
21
|
polyapi/webhook.py,sha256=GvnS49Vl4k5STTvv4KKUnUAyn27OhIHHXChFmiI53Cs,4849
|
|
22
|
-
polyapi_python-0.2.5.
|
|
23
|
-
polyapi_python-0.2.5.
|
|
24
|
-
polyapi_python-0.2.5.
|
|
25
|
-
polyapi_python-0.2.5.
|
|
26
|
-
polyapi_python-0.2.5.
|
|
22
|
+
polyapi_python-0.2.5.dev5.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
|
|
23
|
+
polyapi_python-0.2.5.dev5.dist-info/METADATA,sha256=-b787MldneWyey4k2WYmgDBgqIr-zl2zhF0fZ0sciIM,4867
|
|
24
|
+
polyapi_python-0.2.5.dev5.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
25
|
+
polyapi_python-0.2.5.dev5.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
|
|
26
|
+
polyapi_python-0.2.5.dev5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|