polyapi-python 0.3.19.dev2__tar.gz → 0.3.19.dev3__tar.gz
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_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/PKG-INFO +2 -2
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/README.md +1 -1
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/cli.py +4 -2
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/function_cli.py +3 -3
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi_python.egg-info/PKG-INFO +2 -2
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi_python.egg-info/SOURCES.txt +1 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/pyproject.toml +1 -1
- polyapi_python-0.3.19.dev3/tests/test_cli.py +99 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/LICENSE +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/__init__.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/__main__.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/api.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/auth.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/cli_constants.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/client.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/config.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/constants.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/deployables.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/error_handler.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/exceptions.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/execute.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/generate.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/http_client.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/parser.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/poly_schemas.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/poly_tables.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/prepare.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/py.typed +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/rendered_spec.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/schema.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/server.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/sync.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/typedefs.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/utils.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/variables.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi/webhook.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi_python.egg-info/dependency_links.txt +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi_python.egg-info/requires.txt +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi_python.egg-info/top_level.txt +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/setup.cfg +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_api.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_async_proof.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_auth.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_dependency_pins.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_deployables.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_generate.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_parser.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_poly_custom.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_poly_schemas.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_rendered_spec.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_schema.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_server.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_tabi.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_utils.py +0 -0
- {polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/tests/test_variables.py +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: polyapi-python
|
|
3
|
-
Version: 0.3.19.
|
|
3
|
+
Version: 0.3.19.dev3
|
|
4
4
|
Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
|
|
5
5
|
Author-email: PolyAPI <support@polyapi.io>
|
|
6
6
|
License: MIT License
|
|
@@ -99,7 +99,7 @@ print(poly.polyapi.function.api.list(my_server, my_api_key))
|
|
|
99
99
|
To add a new server function, please follow the quickstart. Then you can add a server function like so:
|
|
100
100
|
|
|
101
101
|
```bash
|
|
102
|
-
python -m polyapi
|
|
102
|
+
python -m polyapi function add <function_name> foo.py --server --context mycontext --description mydesc
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
The code in `foo.py` should contain a single defined function named the same as your `<function_name>` variable.
|
|
@@ -58,7 +58,7 @@ print(poly.polyapi.function.api.list(my_server, my_api_key))
|
|
|
58
58
|
To add a new server function, please follow the quickstart. Then you can add a server function like so:
|
|
59
59
|
|
|
60
60
|
```bash
|
|
61
|
-
python -m polyapi
|
|
61
|
+
python -m polyapi function add <function_name> foo.py --server --context mycontext --description mydesc
|
|
62
62
|
```
|
|
63
63
|
|
|
64
64
|
The code in `foo.py` should contain a single defined function named the same as your `<function_name>` variable.
|
|
@@ -127,7 +127,7 @@ def execute_from_cli():
|
|
|
127
127
|
fn_add_parser.add_argument("--logs", choices=["enabled", "disabled"], default=None, help="Enable or disable logs for the function.")
|
|
128
128
|
fn_add_parser.add_argument("--execution-api-key", required=False, default="", help="API key for execution (for server functions only).")
|
|
129
129
|
fn_add_parser.add_argument("--skip-generate", action="store_true", help="Skip running generate after function add command, especially useful if you are deploying a bunch of functions at once. Run generate manually at the end!")
|
|
130
|
-
fn_add_parser.add_argument("--
|
|
130
|
+
fn_add_parser.add_argument("--image", type=str, default=None, help="Docker image to use when deploying a server function")
|
|
131
131
|
fn_add_parser.add_argument("--generate-contexts", type=str, help="Server function only – only include certain contexts to speed up function execution")
|
|
132
132
|
fn_add_parser.add_argument("--visibility", type=str, default="environment", help="Specifies the visibility of a function. Options: PUBLIC, TENANT, ENVIRONMENT. Case insensitive")
|
|
133
133
|
|
|
@@ -142,6 +142,8 @@ def execute_from_cli():
|
|
|
142
142
|
err = "You must specify `--server` or `--client`."
|
|
143
143
|
elif logs_enabled and not args.server:
|
|
144
144
|
err = "Option `logs` is only for server functions (--server)."
|
|
145
|
+
elif args.image and not args.server:
|
|
146
|
+
err = "Option `image` is only for server functions (--server)."
|
|
145
147
|
elif args.generate_contexts and not args.server:
|
|
146
148
|
err = "Option `generate-contexts` is only for server functions (--server)."
|
|
147
149
|
elif visibility not in ["PUBLIC", "TENANT", "ENVIRONMENT"]:
|
|
@@ -164,7 +166,7 @@ def execute_from_cli():
|
|
|
164
166
|
execution_api_key=args.execution_api_key,
|
|
165
167
|
generate_contexts=args.generate_contexts,
|
|
166
168
|
visibility=visibility,
|
|
167
|
-
|
|
169
|
+
image=args.image,
|
|
168
170
|
)
|
|
169
171
|
|
|
170
172
|
fn_add_parser.set_defaults(command=add_function)
|
|
@@ -25,9 +25,9 @@ def function_add_or_update(
|
|
|
25
25
|
logs_enabled: Optional[bool],
|
|
26
26
|
generate_contexts: Optional[str],
|
|
27
27
|
visibility: Optional[str],
|
|
28
|
+
image: Optional[str],
|
|
28
29
|
generate: bool = True,
|
|
29
30
|
execution_api_key: str = "",
|
|
30
|
-
skip_toolkit_build: bool = False,
|
|
31
31
|
):
|
|
32
32
|
verb = "Updating" if _func_already_exists(context, name) else "Adding"
|
|
33
33
|
ftype = "server" if server else "client"
|
|
@@ -69,8 +69,8 @@ def function_add_or_update(
|
|
|
69
69
|
if generate_contexts:
|
|
70
70
|
data["generateContexts"] = generate_contexts.split(",")
|
|
71
71
|
|
|
72
|
-
if server:
|
|
73
|
-
data["
|
|
72
|
+
if server and image:
|
|
73
|
+
data["image"] = image
|
|
74
74
|
|
|
75
75
|
if server and parsed["dependencies"]:
|
|
76
76
|
print_yellow(
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: polyapi-python
|
|
3
|
-
Version: 0.3.19.
|
|
3
|
+
Version: 0.3.19.dev3
|
|
4
4
|
Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
|
|
5
5
|
Author-email: PolyAPI <support@polyapi.io>
|
|
6
6
|
License: MIT License
|
|
@@ -99,7 +99,7 @@ print(poly.polyapi.function.api.list(my_server, my_api_key))
|
|
|
99
99
|
To add a new server function, please follow the quickstart. Then you can add a server function like so:
|
|
100
100
|
|
|
101
101
|
```bash
|
|
102
|
-
python -m polyapi
|
|
102
|
+
python -m polyapi function add <function_name> foo.py --server --context mycontext --description mydesc
|
|
103
103
|
```
|
|
104
104
|
|
|
105
105
|
The code in `foo.py` should contain a single defined function named the same as your `<function_name>` variable.
|
|
@@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "polyapi-python"
|
|
7
|
-
version = "0.3.19.
|
|
7
|
+
version = "0.3.19.dev3"
|
|
8
8
|
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
|
|
9
9
|
authors = [{ name = "PolyAPI", email = "support@polyapi.io" }]
|
|
10
10
|
dependencies = [
|
|
@@ -0,0 +1,99 @@
|
|
|
1
|
+
import sys
|
|
2
|
+
import unittest
|
|
3
|
+
from unittest.mock import mock_open, patch
|
|
4
|
+
|
|
5
|
+
from polyapi.cli import execute_from_cli
|
|
6
|
+
from polyapi.function_cli import function_add_or_update
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
class T(unittest.TestCase):
|
|
10
|
+
@patch("polyapi.cli.initialize_config")
|
|
11
|
+
@patch("polyapi.cli.function_add_or_update")
|
|
12
|
+
def test_function_add_forwards_image(self, mock_add, _mock_initialize):
|
|
13
|
+
with patch.object(
|
|
14
|
+
sys,
|
|
15
|
+
"argv",
|
|
16
|
+
[
|
|
17
|
+
"polyapi",
|
|
18
|
+
"function",
|
|
19
|
+
"add",
|
|
20
|
+
"my_func",
|
|
21
|
+
"foo.py",
|
|
22
|
+
"--server",
|
|
23
|
+
"--image",
|
|
24
|
+
"python:3.12",
|
|
25
|
+
],
|
|
26
|
+
):
|
|
27
|
+
execute_from_cli()
|
|
28
|
+
|
|
29
|
+
kwargs = mock_add.call_args.kwargs
|
|
30
|
+
self.assertEqual(kwargs["image"], "python:3.12")
|
|
31
|
+
self.assertNotIn("skip_toolkit_build", kwargs)
|
|
32
|
+
|
|
33
|
+
def test_function_add_skip_toolkit_build_removed(self):
|
|
34
|
+
with patch.object(
|
|
35
|
+
sys,
|
|
36
|
+
"argv",
|
|
37
|
+
[
|
|
38
|
+
"polyapi",
|
|
39
|
+
"function",
|
|
40
|
+
"add",
|
|
41
|
+
"my_func",
|
|
42
|
+
"foo.py",
|
|
43
|
+
"--server",
|
|
44
|
+
"--skip-toolkit-build",
|
|
45
|
+
],
|
|
46
|
+
):
|
|
47
|
+
with self.assertRaises(SystemExit) as cm:
|
|
48
|
+
execute_from_cli()
|
|
49
|
+
|
|
50
|
+
self.assertEqual(cm.exception.code, 2)
|
|
51
|
+
|
|
52
|
+
@patch("polyapi.function_cli._func_already_exists", return_value=False)
|
|
53
|
+
@patch("polyapi.function_cli.parse_function_code")
|
|
54
|
+
@patch("polyapi.function_cli.get_jsonschema_type", side_effect=lambda type_name: type_name)
|
|
55
|
+
@patch("polyapi.function_cli.get_api_key_and_url", return_value=("api-key", "https://api.example.com"))
|
|
56
|
+
@patch("polyapi.function_cli.get_auth_headers", return_value={"Authorization": "Bearer api-key"})
|
|
57
|
+
@patch("polyapi.function_cli.http_client.post")
|
|
58
|
+
def test_function_add_includes_image_in_server_payload(
|
|
59
|
+
self,
|
|
60
|
+
mock_post,
|
|
61
|
+
_mock_headers,
|
|
62
|
+
_mock_api_config,
|
|
63
|
+
_mock_jsonschema,
|
|
64
|
+
mock_parse,
|
|
65
|
+
_mock_exists,
|
|
66
|
+
):
|
|
67
|
+
mock_parse.return_value = {
|
|
68
|
+
"context": "demo",
|
|
69
|
+
"types": {
|
|
70
|
+
"description": "",
|
|
71
|
+
"returns": {"type": "int"},
|
|
72
|
+
"params": [{"name": "arg", "type": "str", "typeSchema": None, "description": ""}],
|
|
73
|
+
},
|
|
74
|
+
"config": {},
|
|
75
|
+
"dependencies": [],
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
mock_post.return_value.status_code = 201
|
|
79
|
+
mock_post.return_value.json.return_value = {"id": "fn-123"}
|
|
80
|
+
|
|
81
|
+
with patch("builtins.open", mock_open(read_data="def my_func(arg: str) -> int:\n return 1\n")):
|
|
82
|
+
function_add_or_update(
|
|
83
|
+
name="my_func",
|
|
84
|
+
file="foo.py",
|
|
85
|
+
context="demo",
|
|
86
|
+
description="",
|
|
87
|
+
client=False,
|
|
88
|
+
server=True,
|
|
89
|
+
logs_enabled=None,
|
|
90
|
+
generate_contexts=None,
|
|
91
|
+
visibility="ENVIRONMENT",
|
|
92
|
+
image="python:3.12",
|
|
93
|
+
generate=False,
|
|
94
|
+
execution_api_key="",
|
|
95
|
+
)
|
|
96
|
+
|
|
97
|
+
payload = mock_post.call_args.kwargs["json"]
|
|
98
|
+
self.assertEqual(payload["image"], "python:3.12")
|
|
99
|
+
self.assertNotIn("skipToolkitBuild", payload)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi_python.egg-info/requires.txt
RENAMED
|
File without changes
|
{polyapi_python-0.3.19.dev2 → polyapi_python-0.3.19.dev3}/polyapi_python.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|