python-sdk-remote 0.0.86__tar.gz → 0.0.88__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.
Potentially problematic release.
This version of python-sdk-remote might be problematic. Click here for more details.
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/PKG-INFO +2 -1
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/utilities.py +35 -15
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote.egg-info/PKG-INFO +2 -1
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote.egg-info/requires.txt +1 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/setup.py +3 -2
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/README.md +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/pyproject.toml +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/__init__.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/constants.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/item.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/mini_logger.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/our_object.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/unified_json.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/valid_json_versions.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/validate_environment.py +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote.egg-info/SOURCES.txt +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote.egg-info/top_level.txt +0 -0
- {python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/setup.cfg +0 -0
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-sdk-remote
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.88
|
|
4
4
|
Summary: PyPI Package for Circles Python SDK Local Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -11,5 +11,6 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: python-dotenv
|
|
13
13
|
Requires-Dist: url-remote
|
|
14
|
+
Requires-Dist: http-status-codes
|
|
14
15
|
|
|
15
16
|
This is a package for sharing common functions used in different repositories
|
|
@@ -4,6 +4,7 @@ from datetime import date, datetime, time, timedelta
|
|
|
4
4
|
from dotenv import load_dotenv
|
|
5
5
|
from url_remote.environment_name_enum import EnvironmentName
|
|
6
6
|
from urllib.parse import urlparse
|
|
7
|
+
from http_constants import status
|
|
7
8
|
|
|
8
9
|
from .mini_logger import MiniLogger as logger
|
|
9
10
|
|
|
@@ -74,7 +75,7 @@ def is_valid_time_range(time_range: tuple) -> bool:
|
|
|
74
75
|
return True
|
|
75
76
|
|
|
76
77
|
|
|
77
|
-
def validate_url(url):
|
|
78
|
+
def validate_url(url: str):
|
|
78
79
|
if url is not None or url != "":
|
|
79
80
|
parsed_url = urlparse(url)
|
|
80
81
|
return parsed_url.scheme and parsed_url.netloc
|
|
@@ -125,7 +126,7 @@ def is_valid_datetime_range(datetime_range: tuple) -> bool:
|
|
|
125
126
|
return True
|
|
126
127
|
|
|
127
128
|
|
|
128
|
-
def is_list_of_dicts(obj):
|
|
129
|
+
def is_list_of_dicts(obj: object) -> bool:
|
|
129
130
|
"""
|
|
130
131
|
Check if an object is a list of dictionaries.
|
|
131
132
|
|
|
@@ -138,14 +139,13 @@ def is_list_of_dicts(obj):
|
|
|
138
139
|
Example:
|
|
139
140
|
Usage of is_list_of_dicts:
|
|
140
141
|
|
|
141
|
-
>>>
|
|
142
|
-
>>> result = is_list_of_dicts(data)
|
|
143
|
-
>>> print(result)
|
|
142
|
+
>>> is_list_of_dicts([{'name': 'Alice', 'age': 30}, {'name': 'Bob', 'age': 25}])
|
|
144
143
|
True
|
|
145
144
|
|
|
146
|
-
>>>
|
|
147
|
-
|
|
148
|
-
|
|
145
|
+
>>> is_list_of_dicts([1, 2, 3])
|
|
146
|
+
False
|
|
147
|
+
|
|
148
|
+
>>> is_list_of_dicts(1)
|
|
149
149
|
False
|
|
150
150
|
"""
|
|
151
151
|
IS_LIST_OF_DICTS_FUNCTION_NAME = "is_list_of_dicts"
|
|
@@ -251,33 +251,53 @@ def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: tupl
|
|
|
251
251
|
# TODO Shall we create also createInternalServerErrorHttpResponse(), createOkHttpResponse() like we have in TypeScript?
|
|
252
252
|
|
|
253
253
|
# Former name was create_http_headers()
|
|
254
|
-
def create_authorization_http_headers(user_jwt: str):
|
|
255
|
-
|
|
254
|
+
def create_authorization_http_headers(user_jwt: str) -> dict:
|
|
255
|
+
return {
|
|
256
256
|
'Content-Type': 'application/json',
|
|
257
257
|
'Authorization': f'Bearer {user_jwt}',
|
|
258
258
|
}
|
|
259
|
-
return http_headers
|
|
260
259
|
|
|
261
260
|
|
|
262
|
-
def
|
|
261
|
+
def get_jwt_from_event(event: dict) -> str:
|
|
262
|
+
auth_header = event.get('headers', {}).get('authorization')
|
|
263
|
+
if auth_header is None:
|
|
264
|
+
auth_header = event.get('headers', {}).get('Authorization')
|
|
265
|
+
return auth_header.split('Bearer ')[1]
|
|
266
|
+
|
|
267
|
+
|
|
268
|
+
def create_return_http_headers() -> dict:
|
|
263
269
|
return {
|
|
264
270
|
"Content-Type": "application/json",
|
|
265
271
|
"Access-Control-Allow-Origin": "*",
|
|
266
272
|
}
|
|
267
273
|
|
|
274
|
+
def create_error_http_response(exception: Exception) -> dict:
|
|
275
|
+
return {
|
|
276
|
+
"statusCode": status.BAD_GATEWAY,
|
|
277
|
+
"headers": create_return_http_headers(),
|
|
278
|
+
"body": create_http_body({"error": str(exception)})
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
def create_ok_http_response(body: dict) -> dict:
|
|
282
|
+
return {
|
|
283
|
+
"statusCode": status.OK,
|
|
284
|
+
"headers": create_return_http_headers(),
|
|
285
|
+
"body": create_http_body(body)
|
|
286
|
+
}
|
|
287
|
+
|
|
268
288
|
|
|
269
289
|
# https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format
|
|
270
|
-
def create_http_body(body):
|
|
290
|
+
def create_http_body(body: dict) -> str:
|
|
271
291
|
# TODO console.warning() if the body is not a valid camelCase JSON
|
|
272
292
|
# https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
|
|
273
293
|
return json.dumps(body)
|
|
274
294
|
|
|
275
295
|
|
|
276
|
-
def get_brand_name():
|
|
296
|
+
def get_brand_name() -> str:
|
|
277
297
|
return our_get_env("BRAND_NAME")
|
|
278
298
|
|
|
279
299
|
|
|
280
|
-
def get_environment_name():
|
|
300
|
+
def get_environment_name() -> str:
|
|
281
301
|
environment_name = our_get_env("ENVIRONMENT_NAME")
|
|
282
302
|
EnvironmentName(environment_name) # if invalid, raises ValueError: x is not a valid EnvironmentName
|
|
283
303
|
return environment_name
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: python-sdk-remote
|
|
3
|
-
Version: 0.0.
|
|
3
|
+
Version: 0.0.88
|
|
4
4
|
Summary: PyPI Package for Circles Python SDK Local Python
|
|
5
5
|
Home-page: https://github.com/circles-zone/python-sdk-remote-python-package
|
|
6
6
|
Author: Circles
|
|
@@ -11,5 +11,6 @@ Classifier: Operating System :: OS Independent
|
|
|
11
11
|
Description-Content-Type: text/markdown
|
|
12
12
|
Requires-Dist: python-dotenv
|
|
13
13
|
Requires-Dist: url-remote
|
|
14
|
+
Requires-Dist: http-status-codes
|
|
14
15
|
|
|
15
16
|
This is a package for sharing common functions used in different repositories
|
|
@@ -7,7 +7,7 @@ package_dir = PACKAGE_NAME.replace("-", "_")
|
|
|
7
7
|
# python -m build needs pyproject.toml or setup.py
|
|
8
8
|
setuptools.setup(
|
|
9
9
|
name=PACKAGE_NAME,
|
|
10
|
-
version='0.0.
|
|
10
|
+
version='0.0.88', # https://pypi.org/project/python-sdk-remote/
|
|
11
11
|
author="Circles",
|
|
12
12
|
author_email="info@circles.life",
|
|
13
13
|
description="PyPI Package for Circles Python SDK Local Python",
|
|
@@ -24,6 +24,7 @@ setuptools.setup(
|
|
|
24
24
|
],
|
|
25
25
|
install_requires=[
|
|
26
26
|
"python-dotenv",
|
|
27
|
-
"url-remote"
|
|
27
|
+
"url-remote",
|
|
28
|
+
"http-status-codes"
|
|
28
29
|
]
|
|
29
30
|
)
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/valid_json_versions.py
RENAMED
|
File without changes
|
{python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote/src/validate_environment.py
RENAMED
|
File without changes
|
{python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote.egg-info/SOURCES.txt
RENAMED
|
File without changes
|
|
File without changes
|
{python-sdk-remote-0.0.86 → python-sdk-remote-0.0.88}/python_sdk_remote.egg-info/top_level.txt
RENAMED
|
File without changes
|
|
File without changes
|