ul-api-utils 7.9.2__py3-none-any.whl → 7.10.0__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.
Potentially problematic release.
This version of ul-api-utils might be problematic. Click here for more details.
- ul_api_utils/commands/cmd_start.py +7 -0
- ul_api_utils/conf.py +4 -1
- ul_api_utils/resources/swagger.py +4 -5
- {ul_api_utils-7.9.2.dist-info → ul_api_utils-7.10.0.dist-info}/METADATA +1 -1
- {ul_api_utils-7.9.2.dist-info → ul_api_utils-7.10.0.dist-info}/RECORD +9 -9
- {ul_api_utils-7.9.2.dist-info → ul_api_utils-7.10.0.dist-info}/LICENSE +0 -0
- {ul_api_utils-7.9.2.dist-info → ul_api_utils-7.10.0.dist-info}/WHEEL +0 -0
- {ul_api_utils-7.9.2.dist-info → ul_api_utils-7.10.0.dist-info}/entry_points.txt +0 -0
- {ul_api_utils-7.9.2.dist-info → ul_api_utils-7.10.0.dist-info}/top_level.txt +0 -0
|
@@ -4,6 +4,7 @@ import re
|
|
|
4
4
|
import subprocess
|
|
5
5
|
import sys
|
|
6
6
|
from datetime import datetime
|
|
7
|
+
from typing import Optional
|
|
7
8
|
|
|
8
9
|
from ul_py_tool.commands.cmd import Cmd
|
|
9
10
|
from ul_py_tool.utils.arg_str2bool import arg_str2bool
|
|
@@ -26,6 +27,7 @@ class CmdStart(Cmd):
|
|
|
26
27
|
max_requests: int
|
|
27
28
|
max_requests_jitter: int
|
|
28
29
|
worker_class: str
|
|
30
|
+
statsd_endpoint: Optional[str]
|
|
29
31
|
|
|
30
32
|
@property
|
|
31
33
|
def app_rel_dir(self) -> str:
|
|
@@ -51,6 +53,7 @@ class CmdStart(Cmd):
|
|
|
51
53
|
parser.add_argument('--max-requests', dest='max_requests', type=int, default=1000, required=False)
|
|
52
54
|
parser.add_argument('--max-requests-jitter', dest='max_requests_jitter', type=int, default=50, required=False)
|
|
53
55
|
parser.add_argument('--worker-class', dest='worker_class', type=str, default='sync', required=False)
|
|
56
|
+
parser.add_argument('--statsd_endpoint', dest='statsd_endpoint', type=str, default=None, required=False)
|
|
54
57
|
|
|
55
58
|
def run(self) -> None:
|
|
56
59
|
env = os.environ.copy()
|
|
@@ -84,6 +87,10 @@ class CmdStart(Cmd):
|
|
|
84
87
|
*(['--reload'] if debug else ['--preload']),
|
|
85
88
|
f'{self.app_module}:{self.app_name}',
|
|
86
89
|
]
|
|
90
|
+
|
|
91
|
+
if self.statsd_endpoint and self.env != ENV_LOCAL:
|
|
92
|
+
args.extend([f'--statsd-host={self.statsd_endpoint}', f'--statsd-prefix={self.app_module}:{self.env}'])
|
|
93
|
+
|
|
87
94
|
write_stdout(f'name={name}')
|
|
88
95
|
write_stdout(f'args={args}')
|
|
89
96
|
subprocess.run(['gunicorn', '--check-config', '--print-config', *args], cwd=os.getcwd(), stdout=sys.stdout, stderr=sys.stderr, text=True, env=env)
|
ul_api_utils/conf.py
CHANGED
|
@@ -6,7 +6,7 @@ from typing import Optional
|
|
|
6
6
|
|
|
7
7
|
from ul_py_tool.utils.colors import NC, FG_BLUE
|
|
8
8
|
|
|
9
|
-
from ul_api_utils.const import APPLICATION_ENV__LOCAL
|
|
9
|
+
from ul_api_utils.const import APPLICATION_ENV__LOCAL, API_PATH__SWAGGER, API_PATH__SWAGGER_SPEC
|
|
10
10
|
from ul_api_utils.utils.decode_base64 import decode_base64_to_string
|
|
11
11
|
from ul_api_utils.utils.flags import Flagged
|
|
12
12
|
|
|
@@ -58,6 +58,9 @@ APPLICATION_SENTRY_ENABLED_FLASK = os.environ.get('APPLICATION_SENTRY_FLASK', '1
|
|
|
58
58
|
|
|
59
59
|
APPLICATION_F = Flagged(os.environ.get('APPLICATION_F', ''))
|
|
60
60
|
|
|
61
|
+
APPLICATION_SWAGGER_SPECIFICATION_PATH = os.environ.get('APPLICATION_SWAGGER_SPECIFICATION_PATH', API_PATH__SWAGGER_SPEC)
|
|
62
|
+
APPLICATION_SWAGGER_PATH = os.environ.get('APPLICATION_SWAGGER_PATH', API_PATH__SWAGGER)
|
|
63
|
+
|
|
61
64
|
logging.basicConfig(
|
|
62
65
|
handlers=[logging.StreamHandler(sys.stdout)],
|
|
63
66
|
level=_LOG_MAP[APPLICATION_LOG_LEVEL],
|
|
@@ -13,8 +13,7 @@ from ul_api_utils.api_resource.api_resource_config import ApiResourceConfig
|
|
|
13
13
|
from ul_api_utils.api_resource.api_resource_fn_typing import ApiResourceFnTyping
|
|
14
14
|
from ul_api_utils.api_resource.api_resource_type import ApiResourceType
|
|
15
15
|
from ul_api_utils.api_resource.api_response import EmptyJsonApiResponse, ApiResponse
|
|
16
|
-
from ul_api_utils.conf import APPLICATION_TMP, APPLICATION_DIR, APPLICATION_F
|
|
17
|
-
from ul_api_utils.const import API_PATH__SWAGGER_SPEC, API_PATH__SWAGGER
|
|
16
|
+
from ul_api_utils.conf import APPLICATION_TMP, APPLICATION_DIR, APPLICATION_F, APPLICATION_SWAGGER_PATH, APPLICATION_SWAGGER_SPECIFICATION_PATH
|
|
18
17
|
from ul_api_utils.debug.debugger import Debugger, AJAX_INTERSEPTOR
|
|
19
18
|
from ul_api_utils.utils.api_method import ApiMethod
|
|
20
19
|
from ul_api_utils.utils.api_path_version import ApiPathVersion
|
|
@@ -45,8 +44,8 @@ def load_swagger(sdk: 'ApiSdk', resources: List[ApiSdkResource], api_route_path_
|
|
|
45
44
|
|
|
46
45
|
bp = get_swaggerui_blueprint(
|
|
47
46
|
blueprint_name='swagger_ui',
|
|
48
|
-
base_url=ApiPathVersion.NO_VERSION.compile_path(
|
|
49
|
-
api_url=ApiPathVersion.NO_VERSION.compile_path(
|
|
47
|
+
base_url=ApiPathVersion.NO_VERSION.compile_path(APPLICATION_SWAGGER_PATH, api_route_path_prefix),
|
|
48
|
+
api_url=ApiPathVersion.NO_VERSION.compile_path(APPLICATION_SWAGGER_SPECIFICATION_PATH, api_route_path_prefix),
|
|
50
49
|
)
|
|
51
50
|
|
|
52
51
|
@bp.after_request
|
|
@@ -61,7 +60,7 @@ def load_swagger(sdk: 'ApiSdk', resources: List[ApiSdkResource], api_route_path_
|
|
|
61
60
|
|
|
62
61
|
flask_app.register_blueprint(bp)
|
|
63
62
|
|
|
64
|
-
@sdk.rest_api('GET',
|
|
63
|
+
@sdk.rest_api('GET', APPLICATION_SWAGGER_SPECIFICATION_PATH, v=ApiPathVersion.NO_VERSION, access=GLOBAL_PERMISSION__PUBLIC, config=ApiResourceConfig(swagger_disabled=True))
|
|
65
64
|
def swagger_specification(api_resource: ApiResource) -> EmptyJsonApiResponse:
|
|
66
65
|
try:
|
|
67
66
|
if not os.path.exists(swagger_open_api_cache_file):
|
|
@@ -10,7 +10,7 @@ example/routes/api_some.py,sha256=Gkyb3r1AT7Fg8cAhJk7StTS5aGb-vylvyEuXx7g3Yc4,13
|
|
|
10
10
|
example/workers/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
11
11
|
example/workers/worker.py,sha256=flMYq50OhLtNSaA2qyDJSMeXSNXIqhdBIsaxcmO5-xQ,681
|
|
12
12
|
ul_api_utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
13
|
-
ul_api_utils/conf.py,sha256=
|
|
13
|
+
ul_api_utils/conf.py,sha256=zLWsA0TTmekzxYrs5PbeqEkeylaNC_gIui3CGM9aZew,3487
|
|
14
14
|
ul_api_utils/const.py,sha256=pzY-zRznCJjZ0mFlte6XEsQQCU7EydN2WweEsVHSE7k,2563
|
|
15
15
|
ul_api_utils/errors.py,sha256=kmmgNXJtgVczOskVG8Ye1WSHbqSSAWC2OzUjPUGCkGo,8137
|
|
16
16
|
ul_api_utils/main.py,sha256=-0S7qYgyNnom9xUhqowi0ErrYz82m3Z4K_uVxarXhN8,922
|
|
@@ -34,7 +34,7 @@ ul_api_utils/commands/cmd_enc_keys.py,sha256=-Tblh6lI7G6M5YVwbVQqZmXhBMiIpB3a7b0
|
|
|
34
34
|
ul_api_utils/commands/cmd_gen_api_user_token.py,sha256=Vg7oEYHvof7DSLat9yJ_k5AYL9ZOC4Jvd38DBn5U-R0,2730
|
|
35
35
|
ul_api_utils/commands/cmd_gen_new_api_user.py,sha256=ICZbKqz2D6DRvjwtNM08rNjIlWN3qClcUQw5L8FxRBY,4549
|
|
36
36
|
ul_api_utils/commands/cmd_generate_api_docs.py,sha256=cEBUOkn8iQIir78yXzHK_gy_hna2cP58x8N5DzCeZEA,9617
|
|
37
|
-
ul_api_utils/commands/cmd_start.py,sha256=
|
|
37
|
+
ul_api_utils/commands/cmd_start.py,sha256=kGEZkfe7mQ6bUqvVABzTCWQ_ZVlZrADIcLyYeuFsWuY,3976
|
|
38
38
|
ul_api_utils/commands/cmd_worker_start.py,sha256=1tt4_mL8T8_q7i1bqnfjPSkSYlRNNNp8eJ-5rTYj36w,2593
|
|
39
39
|
ul_api_utils/commands/start/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
40
40
|
ul_api_utils/commands/start/gunicorn.conf.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
@@ -73,7 +73,7 @@ ul_api_utils/resources/not_implemented.py,sha256=OQE5LGA4KqZDwP5Wtub3Aw-icwzbqCS
|
|
|
73
73
|
ul_api_utils/resources/permissions.py,sha256=8c8cEPkm69zxgXbDiwUkW6Mi_496-MZXbPOxHITetKs,1436
|
|
74
74
|
ul_api_utils/resources/rate_limitter.py,sha256=QMpaLu1LoFbvtIEhxF8HbAZIAW4oGKTClt7XEUsqx98,3358
|
|
75
75
|
ul_api_utils/resources/sockets.py,sha256=gftL6QR762GetSrm8Yjh9kfoMAwH64ijqOBexXBz0BY,76
|
|
76
|
-
ul_api_utils/resources/swagger.py,sha256=
|
|
76
|
+
ul_api_utils/resources/swagger.py,sha256=fK8S9X4YCSqe_weCzV_BcMPoL_NR073BsGUzn2ImbHI,5391
|
|
77
77
|
ul_api_utils/resources/health_check/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
78
78
|
ul_api_utils/resources/health_check/const.py,sha256=QzVZP_ZKmVKleUACiOGjzP-v54FD7tEN6NEF4Jb50Ow,78
|
|
79
79
|
ul_api_utils/resources/health_check/health_check.py,sha256=bb_ONn3akNXxNFELIUcW6foqwiKqeinmr-Wl0fQ7Q4c,18449
|
|
@@ -135,9 +135,9 @@ ul_api_utils/validators/validate_empty_object.py,sha256=3Ck_iwyJE_M5e7l6s1i88aqb
|
|
|
135
135
|
ul_api_utils/validators/validate_uuid.py,sha256=EfvlRirv2EW0Z6w3s8E8rUa9GaI8qXZkBWhnPs8NFrA,257
|
|
136
136
|
ul_api_utils/validators/__tests__/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
137
137
|
ul_api_utils/validators/__tests__/test_custom_fields.py,sha256=QLZ7DFta01Z7DOK9Z5Iq4uf_CmvDkVReis-GAl_QN48,1447
|
|
138
|
-
ul_api_utils-7.
|
|
139
|
-
ul_api_utils-7.
|
|
140
|
-
ul_api_utils-7.
|
|
141
|
-
ul_api_utils-7.
|
|
142
|
-
ul_api_utils-7.
|
|
143
|
-
ul_api_utils-7.
|
|
138
|
+
ul_api_utils-7.10.0.dist-info/LICENSE,sha256=6Qo8OdcqI8aGrswJKJYhST-bYqxVQBQ3ujKdTSdq-80,1062
|
|
139
|
+
ul_api_utils-7.10.0.dist-info/METADATA,sha256=_Lb3-KsVEXqlz71kGrcwoftsRNNQIZIF2ufTjvqfpzI,14672
|
|
140
|
+
ul_api_utils-7.10.0.dist-info/WHEEL,sha256=G16H4A3IeoQmnOrYV4ueZGKSjhipXx8zc8nu9FGlvMA,92
|
|
141
|
+
ul_api_utils-7.10.0.dist-info/entry_points.txt,sha256=8tL3ySHWTyJMuV1hx1fHfN8zumDVOCOm63w3StphkXg,53
|
|
142
|
+
ul_api_utils-7.10.0.dist-info/top_level.txt,sha256=1XsW8iOSFaH4LOzDcnNyxHpHrbKU3fSn-aIAxe04jmw,21
|
|
143
|
+
ul_api_utils-7.10.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|