polyapi-python 0.3.0__tar.gz → 0.3.1.dev1__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.0/polyapi_python.egg-info → polyapi_python-0.3.1.dev1}/PKG-INFO +1 -1
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/cli.py +5 -4
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/config.py +23 -5
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/utils.py +21 -1
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1/polyapi_python.egg-info}/PKG-INFO +1 -1
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/pyproject.toml +1 -1
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/LICENSE +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/README.md +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/__init__.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/__main__.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/api.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/auth.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/client.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/constants.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/error_handler.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/exceptions.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/execute.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/function_cli.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/generate.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/py.typed +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/rendered_spec.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/schema.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/server.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/typedefs.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/variables.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi/webhook.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi_python.egg-info/SOURCES.txt +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi_python.egg-info/dependency_links.txt +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi_python.egg-info/requires.txt +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/polyapi_python.egg-info/top_level.txt +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/setup.cfg +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_api.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_auth.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_function_cli.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_rendered_spec.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_schema.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_server.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_utils.py +0 -0
- {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev1}/tests/test_variables.py +0 -0
|
@@ -2,7 +2,7 @@ import argparse
|
|
|
2
2
|
|
|
3
3
|
from polyapi.utils import print_green
|
|
4
4
|
|
|
5
|
-
from .config import
|
|
5
|
+
from .config import initialize_config, set_api_key_and_url
|
|
6
6
|
from .generate import generate, clear
|
|
7
7
|
from .function_cli import function_add_or_update, function_execute
|
|
8
8
|
from .rendered_spec import get_and_update_rendered_spec
|
|
@@ -26,7 +26,7 @@ def execute_from_cli() -> None:
|
|
|
26
26
|
parser.add_argument("--description", required=False, default="")
|
|
27
27
|
parser.add_argument("--client", action="store_true", help="Pass --client when adding function to add a client function.")
|
|
28
28
|
parser.add_argument("--server", action="store_true", help="Pass --server when adding function to add a server function.")
|
|
29
|
-
parser.add_argument("--logs",
|
|
29
|
+
parser.add_argument("--logs", choices=["enabled", "disabled"], default="disabled", help="Enable or disable logs for the function.")
|
|
30
30
|
parser.add_argument("--skip-generate", action="store_true", help="Pass --skip-generate to skip generating the library after adding a function.")
|
|
31
31
|
parser.add_argument("--execution-api-key", required=False, default="", help="API key for execution (for server functions only).")
|
|
32
32
|
parser.add_argument("command", choices=CLI_COMMANDS)
|
|
@@ -43,7 +43,7 @@ def execute_from_cli() -> None:
|
|
|
43
43
|
elif command == "setup" and len(args.subcommands) == 2:
|
|
44
44
|
set_api_key_and_url(args.subcommands[1], args.subcommands[0])
|
|
45
45
|
elif command == "setup":
|
|
46
|
-
|
|
46
|
+
initialize_config(force=True)
|
|
47
47
|
generate()
|
|
48
48
|
elif command == "update_rendered_spec":
|
|
49
49
|
assert len(args.subcommands) == 1
|
|
@@ -57,6 +57,7 @@ def execute_from_cli() -> None:
|
|
|
57
57
|
print("Clearing the generated library...")
|
|
58
58
|
clear()
|
|
59
59
|
elif command == "function":
|
|
60
|
+
logs_enabled = args.logs == "enabled"
|
|
60
61
|
if args.subcommands[0] == "execute":
|
|
61
62
|
print(function_execute(args.context, args.subcommands))
|
|
62
63
|
else:
|
|
@@ -65,7 +66,7 @@ def execute_from_cli() -> None:
|
|
|
65
66
|
description=args.description,
|
|
66
67
|
client=args.client,
|
|
67
68
|
server=args.server,
|
|
68
|
-
logs_enabled=
|
|
69
|
+
logs_enabled=logs_enabled,
|
|
69
70
|
subcommands=args.subcommands,
|
|
70
71
|
generate=not args.skip_generate,
|
|
71
72
|
execution_api_key=args.execution_api_key
|
|
@@ -3,6 +3,8 @@ import os
|
|
|
3
3
|
import configparser
|
|
4
4
|
from typing import Tuple
|
|
5
5
|
|
|
6
|
+
from polyapi.utils import is_valid_polyapi_url, is_valid_uuid, print_green, print_yellow
|
|
7
|
+
|
|
6
8
|
# cached values
|
|
7
9
|
API_KEY = None
|
|
8
10
|
API_URL = None
|
|
@@ -55,18 +57,34 @@ def set_api_key_and_url(key: str, url: str):
|
|
|
55
57
|
config.write(f)
|
|
56
58
|
|
|
57
59
|
|
|
58
|
-
def initialize_config():
|
|
60
|
+
def initialize_config(force=False):
|
|
59
61
|
key, url = get_api_key_and_url()
|
|
60
|
-
if not key or not url:
|
|
62
|
+
if force or (not key or not url):
|
|
63
|
+
url = url or "https://na1.polyapi.io"
|
|
61
64
|
print("Please setup your connection to PolyAPI.")
|
|
62
|
-
url = input("? Poly API Base URL (
|
|
63
|
-
|
|
65
|
+
url = input(f"? Poly API Base URL ({url}): ").strip() or url
|
|
66
|
+
|
|
67
|
+
if not key:
|
|
68
|
+
key = input("? Poly App Key or User Key: ").strip()
|
|
69
|
+
else:
|
|
70
|
+
key_input = input(f"? Poly App Key or User Key ({key}): ").strip()
|
|
71
|
+
key = key_input if key_input else key
|
|
64
72
|
|
|
65
73
|
if url and key:
|
|
74
|
+
errors = []
|
|
75
|
+
if not is_valid_polyapi_url(url):
|
|
76
|
+
errors.append(f"{url} is not a valid Poly API Base URL")
|
|
77
|
+
if not is_valid_uuid(key):
|
|
78
|
+
errors.append(f"{key} is not a valid Poly App Key or User Key")
|
|
79
|
+
if errors:
|
|
80
|
+
print_yellow("\n".join(errors))
|
|
81
|
+
sys.exit(1)
|
|
82
|
+
|
|
66
83
|
set_api_key_and_url(key, url)
|
|
84
|
+
print_green(f"Poly setup complete.")
|
|
67
85
|
|
|
68
86
|
if not key or not url:
|
|
69
|
-
|
|
87
|
+
print_yellow("Poly API Key and Poly API Base URL are required.")
|
|
70
88
|
sys.exit(1)
|
|
71
89
|
|
|
72
90
|
return key, url
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import keyword
|
|
2
2
|
import re
|
|
3
3
|
import os
|
|
4
|
+
import uuid
|
|
4
5
|
from typing import Tuple, List
|
|
5
6
|
from colorama import Fore, Style
|
|
6
7
|
from polyapi.constants import BASIC_PYTHON_TYPES
|
|
@@ -208,4 +209,23 @@ def rewrite_reserved(s: str) -> str:
|
|
|
208
209
|
|
|
209
210
|
|
|
210
211
|
def rewrite_arg_name(s: str):
|
|
211
|
-
return rewrite_reserved(camelCase(s))
|
|
212
|
+
return rewrite_reserved(camelCase(s))
|
|
213
|
+
|
|
214
|
+
|
|
215
|
+
valid_subdomains = ["na[1-2]", "eu[1-2]", "dev"]
|
|
216
|
+
|
|
217
|
+
|
|
218
|
+
def is_valid_polyapi_url(_url: str):
|
|
219
|
+
# Join the subdomains into a pattern
|
|
220
|
+
subdomain_pattern = "|".join(valid_subdomains)
|
|
221
|
+
pattern = rf"^https://({subdomain_pattern})\.polyapi\.io$"
|
|
222
|
+
return re.match(pattern, _url) is not None
|
|
223
|
+
|
|
224
|
+
|
|
225
|
+
def is_valid_uuid(uuid_string, version=4):
|
|
226
|
+
try:
|
|
227
|
+
uuid_obj = uuid.UUID(uuid_string, version=version)
|
|
228
|
+
except ValueError:
|
|
229
|
+
return False
|
|
230
|
+
|
|
231
|
+
return str(uuid_obj) == uuid_string
|
|
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
|
|
|
3
3
|
|
|
4
4
|
[project]
|
|
5
5
|
name = "polyapi-python"
|
|
6
|
-
version = "0.3.
|
|
6
|
+
version = "0.3.1.dev1"
|
|
7
7
|
description = "The Python Client for PolyAPI, the IPaaS by Developers for Developers"
|
|
8
8
|
authors = [{ name = "Dan Fellin", email = "dan@polyapi.io" }]
|
|
9
9
|
dependencies = [
|
|
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.0 → polyapi_python-0.3.1.dev1}/polyapi_python.egg-info/dependency_links.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
|