polyapi-python 0.2.5.dev1__py3-none-any.whl → 0.2.5.dev2__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 +2 -1
- polyapi/function_cli.py +2 -0
- polyapi/generate.py +0 -19
- polyapi/rendered_spec.py +34 -0
- {polyapi_python-0.2.5.dev1.dist-info → polyapi_python-0.2.5.dev2.dist-info}/METADATA +1 -1
- {polyapi_python-0.2.5.dev1.dist-info → polyapi_python-0.2.5.dev2.dist-info}/RECORD +9 -8
- {polyapi_python-0.2.5.dev1.dist-info → polyapi_python-0.2.5.dev2.dist-info}/LICENSE +0 -0
- {polyapi_python-0.2.5.dev1.dist-info → polyapi_python-0.2.5.dev2.dist-info}/WHEEL +0 -0
- {polyapi_python-0.2.5.dev1.dist-info → polyapi_python-0.2.5.dev2.dist-info}/top_level.txt +0 -0
polyapi/cli.py
CHANGED
|
@@ -3,8 +3,9 @@ import argparse
|
|
|
3
3
|
from polyapi.utils import print_green
|
|
4
4
|
|
|
5
5
|
from .config import clear_config, set_api_key_and_url
|
|
6
|
-
from .generate import generate, clear
|
|
6
|
+
from .generate import generate, clear
|
|
7
7
|
from .function_cli import function_add_or_update
|
|
8
|
+
from .rendered_spec import save_rendered_specs
|
|
8
9
|
|
|
9
10
|
|
|
10
11
|
CLI_COMMANDS = ["setup", "generate", "function", "clear", "help", "save_rendered_specs"]
|
polyapi/function_cli.py
CHANGED
|
@@ -13,6 +13,7 @@ from importlib.metadata import packages_distributions
|
|
|
13
13
|
from polyapi.generate import get_functions_and_parse, generate_functions
|
|
14
14
|
from polyapi.config import get_api_key_and_url
|
|
15
15
|
from polyapi.constants import PYTHON_TO_JSONSCHEMA_TYPE_MAP
|
|
16
|
+
# from polyapi.rendered_spec import update_rendered_spec
|
|
16
17
|
from polyapi.utils import get_auth_headers, print_green, print_red, print_yellow
|
|
17
18
|
import importlib
|
|
18
19
|
|
|
@@ -270,6 +271,7 @@ def function_add_or_update(
|
|
|
270
271
|
print(f"Function ID: {function_id}")
|
|
271
272
|
print("Generating new custom function...", end="")
|
|
272
273
|
functions = get_functions_and_parse(limit_ids=[function_id])
|
|
274
|
+
# update_rendered_spec(functions[0])
|
|
273
275
|
generate_functions(functions)
|
|
274
276
|
print_green("DONE")
|
|
275
277
|
else:
|
polyapi/generate.py
CHANGED
|
@@ -6,7 +6,6 @@ from typing import List
|
|
|
6
6
|
|
|
7
7
|
from polyapi.auth import render_auth_function
|
|
8
8
|
from polyapi.client import render_client_function
|
|
9
|
-
from polyapi.execute import execute_post
|
|
10
9
|
from polyapi.webhook import render_webhook_handle
|
|
11
10
|
|
|
12
11
|
from .typedefs import PropertySpecification, SpecificationDto, VariableSpecDto
|
|
@@ -157,24 +156,6 @@ def clear() -> None:
|
|
|
157
156
|
print("Cleared!")
|
|
158
157
|
|
|
159
158
|
|
|
160
|
-
def save_rendered_specs() -> None:
|
|
161
|
-
specs = read_cached_specs()
|
|
162
|
-
# right now we just support rendered apiFunctions
|
|
163
|
-
api_specs = [spec for spec in specs if spec["type"] == "apiFunction"]
|
|
164
|
-
for spec in api_specs:
|
|
165
|
-
assert spec["function"]
|
|
166
|
-
func_str, type_defs = render_spec(spec)
|
|
167
|
-
data = {
|
|
168
|
-
"language": "python",
|
|
169
|
-
"apiFunctionId": spec["id"],
|
|
170
|
-
"signature": func_str,
|
|
171
|
-
"typedefs": type_defs,
|
|
172
|
-
}
|
|
173
|
-
resp = execute_post("/functions/rendered-specs", data)
|
|
174
|
-
print("adding", spec["context"], spec["name"])
|
|
175
|
-
assert resp.status_code == 201, (resp.text, resp.status_code)
|
|
176
|
-
|
|
177
|
-
|
|
178
159
|
def render_spec(spec: SpecificationDto):
|
|
179
160
|
function_type = spec["type"]
|
|
180
161
|
function_description = spec["description"]
|
polyapi/rendered_spec.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
from typing import Dict
|
|
2
|
+
from polyapi.generate import read_cached_specs, render_spec
|
|
3
|
+
from polyapi.execute import execute_post
|
|
4
|
+
from polyapi.typedefs import SpecificationDto
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def update_rendered_spec(spec: SpecificationDto):
|
|
8
|
+
print("Updating rendered spec...")
|
|
9
|
+
func_str, type_defs = render_spec(spec)
|
|
10
|
+
data = {
|
|
11
|
+
"language": "python",
|
|
12
|
+
"signature": func_str,
|
|
13
|
+
"typedefs": type_defs,
|
|
14
|
+
}
|
|
15
|
+
if spec["type"] == "apiFunction":
|
|
16
|
+
data["apiFunctionId"] = spec["id"]
|
|
17
|
+
elif spec["type"] == "serverFunction":
|
|
18
|
+
data["customFunctionId"] = spec["id"]
|
|
19
|
+
else:
|
|
20
|
+
raise NotImplementedError("todo")
|
|
21
|
+
|
|
22
|
+
resp = execute_post("/functions/rendered-specs", data)
|
|
23
|
+
assert resp.status_code == 201, (resp.text, resp.status_code)
|
|
24
|
+
# this needs to run with something like `kn func run...`
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def save_rendered_specs() -> None:
|
|
28
|
+
specs = read_cached_specs()
|
|
29
|
+
# right now we just support rendered apiFunctions
|
|
30
|
+
api_specs = [spec for spec in specs if spec["type"] == "apiFunction"]
|
|
31
|
+
for spec in api_specs:
|
|
32
|
+
assert spec["function"]
|
|
33
|
+
print("adding", spec["context"], spec["name"])
|
|
34
|
+
update_rendered_spec(spec)
|
|
@@ -2,24 +2,25 @@ 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=IbMbapuH5jo6W5-IOtTvGmNlqQtd1ZKjXSOhZcK-yi8,2213
|
|
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
|
|
9
9
|
polyapi/error_handler.py,sha256=I_e0iz6VM23FLVQWJljxs2NGcl_OODbi43OcbnqBlp8,2398
|
|
10
10
|
polyapi/exceptions.py,sha256=Zh7i7eCUhDuXEdUYjatkLFTeZkrx1BJ1P5ePgbJ9eIY,89
|
|
11
11
|
polyapi/execute.py,sha256=kXnvlNQ7nz9cRlV2_5gXH09UCmyiDP5zi3wiAw0uDuk,1943
|
|
12
|
-
polyapi/function_cli.py,sha256=
|
|
13
|
-
polyapi/generate.py,sha256=
|
|
12
|
+
polyapi/function_cli.py,sha256=4G4xqDCF7HSVERXRJx1D3uytNI1_mhaU-bNFeNRsQ3E,9231
|
|
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=pIgINiae-VjDNLGI3YAMeK_r6RQvOyhq7CfGs7gVKoo,1172
|
|
15
16
|
polyapi/schema.py,sha256=1a7nIO867Xy3bagmPUNdYMxtS5OoCAv8oKIbYgj55dk,2957
|
|
16
17
|
polyapi/server.py,sha256=n-nMGjXoq9T9ZwE2EBDkAaxJ7UytConGaHthkjbkCXA,1894
|
|
17
18
|
polyapi/typedefs.py,sha256=mRqwd2LKofxNn_VSKxBzixni2j-tai8mfTQ0Wi2aLNM,1487
|
|
18
19
|
polyapi/utils.py,sha256=CXzQC5u8vNMyS7f3E45plSuB2EodevDmkOXhHA2zxoc,7108
|
|
19
20
|
polyapi/variables.py,sha256=d36-trnfTL_8m2NkorMiImb4O3UrJbiFV38CHxV5i0A,4200
|
|
20
21
|
polyapi/webhook.py,sha256=GvnS49Vl4k5STTvv4KKUnUAyn27OhIHHXChFmiI53Cs,4849
|
|
21
|
-
polyapi_python-0.2.5.
|
|
22
|
-
polyapi_python-0.2.5.
|
|
23
|
-
polyapi_python-0.2.5.
|
|
24
|
-
polyapi_python-0.2.5.
|
|
25
|
-
polyapi_python-0.2.5.
|
|
22
|
+
polyapi_python-0.2.5.dev2.dist-info/LICENSE,sha256=Hi0kDr56Dsy0uYIwNt4r9G7tI8x8miXRTlyvbeplCP8,1068
|
|
23
|
+
polyapi_python-0.2.5.dev2.dist-info/METADATA,sha256=9zDKI-h5eqQ64xxMc26vEmm4HhXk95PgTPLCNpZt94U,4867
|
|
24
|
+
polyapi_python-0.2.5.dev2.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
25
|
+
polyapi_python-0.2.5.dev2.dist-info/top_level.txt,sha256=CEFllOnzowci_50RYJac-M54KD2IdAptFsayVVF_f04,8
|
|
26
|
+
polyapi_python-0.2.5.dev2.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|