polyapi-python 0.3.0__tar.gz → 0.3.1.dev0__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.
Files changed (39) hide show
  1. {polyapi_python-0.3.0/polyapi_python.egg-info → polyapi_python-0.3.1.dev0}/PKG-INFO +1 -1
  2. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/cli.py +2 -2
  3. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/config.py +23 -5
  4. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/utils.py +21 -1
  5. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0/polyapi_python.egg-info}/PKG-INFO +1 -1
  6. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/pyproject.toml +1 -1
  7. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/LICENSE +0 -0
  8. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/README.md +0 -0
  9. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/__init__.py +0 -0
  10. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/__main__.py +0 -0
  11. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/api.py +0 -0
  12. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/auth.py +0 -0
  13. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/client.py +0 -0
  14. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/constants.py +0 -0
  15. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/error_handler.py +0 -0
  16. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/exceptions.py +0 -0
  17. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/execute.py +0 -0
  18. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/function_cli.py +0 -0
  19. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/generate.py +0 -0
  20. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/py.typed +0 -0
  21. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/rendered_spec.py +0 -0
  22. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/schema.py +0 -0
  23. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/server.py +0 -0
  24. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/typedefs.py +0 -0
  25. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/variables.py +0 -0
  26. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi/webhook.py +0 -0
  27. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi_python.egg-info/SOURCES.txt +0 -0
  28. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi_python.egg-info/dependency_links.txt +0 -0
  29. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi_python.egg-info/requires.txt +0 -0
  30. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/polyapi_python.egg-info/top_level.txt +0 -0
  31. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/setup.cfg +0 -0
  32. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_api.py +0 -0
  33. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_auth.py +0 -0
  34. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_function_cli.py +0 -0
  35. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_rendered_spec.py +0 -0
  36. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_schema.py +0 -0
  37. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_server.py +0 -0
  38. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_utils.py +0 -0
  39. {polyapi_python-0.3.0 → polyapi_python-0.3.1.dev0}/tests/test_variables.py +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.3.0
3
+ Version: 0.3.1.dev0
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -2,7 +2,7 @@ import argparse
2
2
 
3
3
  from polyapi.utils import print_green
4
4
 
5
- from .config import clear_config, set_api_key_and_url
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
@@ -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
- clear_config()
46
+ initialize_config(force=True)
47
47
  generate()
48
48
  elif command == "update_rendered_spec":
49
49
  assert len(args.subcommands) == 1
@@ -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 (https://na1.polyapi.io): ") or "https://na1.polyapi.io"
63
- key = input("? Poly App Key or User Key: ")
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
- print("Poly API Key and Poly API Base URL are required.")
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
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: polyapi-python
3
- Version: 0.3.0
3
+ Version: 0.3.1.dev0
4
4
  Summary: The Python Client for PolyAPI, the IPaaS by Developers for Developers
5
5
  Author-email: Dan Fellin <dan@polyapi.io>
6
6
  License: MIT License
@@ -3,7 +3,7 @@ requires = ["setuptools>=61.2", "wheel"]
3
3
 
4
4
  [project]
5
5
  name = "polyapi-python"
6
- version = "0.3.0"
6
+ version = "0.3.1.dev0"
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 = [