python-sdk-remote 0.0.126__tar.gz → 0.0.127__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.

Files changed (21) hide show
  1. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/PKG-INFO +1 -1
  2. python_sdk_remote-0.0.127/README.md +27 -0
  3. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/constants.py +9 -0
  4. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/http_response.py +19 -51
  5. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/item.py +3 -2
  6. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/our_object.py +9 -0
  7. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/unified_json.py +7 -0
  8. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/utilities.py +32 -32
  9. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote.egg-info/PKG-INFO +1 -1
  10. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/setup.py +1 -1
  11. python_sdk_remote-0.0.126/README.md +0 -11
  12. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/pyproject.toml +0 -0
  13. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/__init__.py +0 -0
  14. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/mini_logger.py +0 -0
  15. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/valid_json_versions.py +0 -0
  16. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote/src/validate_environment.py +0 -0
  17. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote.egg-info/SOURCES.txt +0 -0
  18. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote.egg-info/dependency_links.txt +0 -0
  19. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote.egg-info/requires.txt +0 -0
  20. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/python_sdk_remote.egg-info/top_level.txt +0 -0
  21. {python_sdk_remote-0.0.126 → python_sdk_remote-0.0.127}/setup.cfg +0 -0
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.126
3
+ Version: 0.0.127
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
@@ -0,0 +1,27 @@
1
+ # python-sdk-package
2
+
3
+ https://github.com/grosser/repo_dependency_graph Ruby, Graph the dependencies of your repositories
4
+ https://github.com/thebjorn/pydeps Python
5
+
6
+ To create local package and remote package layers (not to create GraphQL and REST-API layers)
7
+
8
+ #database Python scripts in /db folder
9
+ Please place <table-name>.py in /db<br>
10
+ No need for seperate file for _ml table<br>
11
+ Please delete the example file if not needed<br>
12
+
13
+ # Create the files to create the database schema, tables, view and populate Meta Data and Test Date
14
+
15
+ /db/<table-name>.py - CREATE SCHEMA ... CREATE TABLE ... CREATE VIEW ...<br>
16
+ /db/<table-name>_insert.py to create records
17
+
18
+ # Update the setup.py (i.e.name, version)
19
+
20
+ # Please create test directory inside the directory of the project i.e. /<project-name>/tests
21
+
22
+ # Update the serverless.yml in the root directory
23
+
24
+ provider:
25
+ stage: play1
26
+
27
+ Update the endpoints in serverless.yml
@@ -1,8 +1,17 @@
1
+ import os
2
+
1
3
  from logger_local.LoggerComponentEnum import LoggerComponentEnum
2
4
 
3
5
  PYTHON_SDK_REMOTE_COMPONENT_ID = 184
4
6
  PYTHON_SDK_REMOTE_COMPONENT_NAME = 'python_sdk_remote'
5
7
 
8
+ ENVIRONMENT_NAME = os.getenv("ENVIRONMENT_NAME")
9
+ BRAND_NAME = os.getenv("BRAND_NAME")
10
+ LOGZIO_TOKEN = os.getenv("LOGZIO_TOKEN")
11
+ # TODO Shall Can we use python-sdk function to get the value from Environment?
12
+ # TODO Shall we get the value from environment here of send the value to the function as @akiva-skolnik did?
13
+ GOOGLE_PORT_FOR_AUTHENTICATION = os.getenv("PORT_FOR_AUTHENTICATION")
14
+
6
15
  OBJECT_TO_INSERT_CODE = {
7
16
  'component_id': PYTHON_SDK_REMOTE_COMPONENT_ID,
8
17
  'component_name': PYTHON_SDK_REMOTE_COMPONENT_NAME,
@@ -1,10 +1,10 @@
1
+ import json
1
2
  import traceback
2
- from functools import wraps
3
3
  from http import HTTPStatus
4
4
  from typing import Any
5
5
 
6
6
  from .mini_logger import MiniLogger as logger
7
- from .utilities import camel_to_snake, snake_to_camel, to_dict, to_json
7
+ import warnings
8
8
 
9
9
  HEADERS_KEY = 'headers'
10
10
  AUTHORIZATION_KEY = 'authorization'
@@ -17,66 +17,28 @@ AUTHORIZATION_PREFIX = 'Bearer '
17
17
  # TODO: add handler wrapper?
18
18
 
19
19
  def get_payload_dict_from_event(event: dict) -> dict:
20
+ warnings.warn("DELETE get_payload_dict_from_event",DeprecationWarning,stacklevel=2)
20
21
  """Extracts params sent with payload"""
21
- return to_dict(event.get('body'))
22
+ return json.loads(event.get('body') or '{}')
22
23
 
23
24
 
24
25
  def get_path_parameters_dict_from_event(event: dict) -> dict:
26
+ warnings.warn("DELETE get_path_parameters_dict_from_event",DeprecationWarning,stacklevel=2)
25
27
  """Extracts params sent implicitly: `url/param?test=5` -> param
26
28
  (when the path is defined with /{param})"""
27
29
  return event.get('pathParameters') or {}
28
30
 
29
31
 
30
32
  def get_query_string_parameters_from_event(event: dict) -> dict:
33
+ warnings.warn("DELETE get_query_string_parameters_from_event",DeprecationWarning,stacklevel=2)
31
34
  """Extracts params sent explicitly: `url/test?a=1&b=2` -> {'a': '1', 'b': '2'}"""
32
35
  return event.get("queryStringParameters") or {} # params sent with ?a=1&b=2
33
36
 
34
37
 
35
- def get_request_parameters_from_event(event: dict) -> dict:
36
- """Extracts all params from the event object.
37
- The order of precedence is: payload > path > query string
38
- returns a dictionary with all the parameters, with both camelCase and snake_case keys."""
39
- all_parameters_dict = get_payload_dict_from_event(event)
40
- all_parameters_dict.update(get_path_parameters_dict_from_event(event))
41
- all_parameters_dict.update(get_query_string_parameters_from_event(event))
42
- all_parameters_dict = {camel_to_snake(key): value for key, value in all_parameters_dict.items()}
43
- all_parameters_dict.update({snake_to_camel(key): value for key, value in all_parameters_dict.items()})
44
- return all_parameters_dict
45
-
46
-
47
- # TODO: test
48
- def handler_decorator(logger):
49
- """Decorator for AWS Lambda handler functions. It wraps the handler function with logging and error handling.
50
- Usage:
51
- from python_sdk_remote.http_response import handler_decorator
52
- logger = ...
53
- @handler_decorator(logger=logger)
54
- def my_handler(request_parameters: dict) -> dict:
55
- return {"message": "Hello, World!"}"""
56
-
57
- def decorator(handler: callable) -> callable:
58
- @wraps(handler)
59
- def wrapper(event, context):
60
- handler_response = None
61
- try:
62
- logger.start(object={"event": event, "context": context})
63
- request_parameters = get_request_parameters_from_event(event)
64
- body_result: dict = handler(request_parameters)
65
- handler_response = create_ok_http_response(body_result)
66
- except Exception as e:
67
- handler_response = create_error_http_response(e)
68
- finally:
69
- logger.end(object={"handler_response": handler_response})
70
- return handler_response
71
-
72
- return wrapper
73
-
74
- return decorator
75
-
76
-
77
- # TODO: should we auto detect user_jwt if not provided?
78
38
  def create_authorization_http_headers(user_jwt: str) -> dict:
39
+ warnings.warn("DELETE create_authorization_http_headers",DeprecationWarning,stacklevel=2)
79
40
  logger.start(object={"user_jwt": user_jwt})
41
+ #TODO check the validity of user_jwt and it is not None and raise exception, please do the same in all other functions.
80
42
  authorization_http_headers = {
81
43
  'Content-Type': 'application/json',
82
44
  'Authorization': AUTHORIZATION_PREFIX + user_jwt,
@@ -86,6 +48,7 @@ def create_authorization_http_headers(user_jwt: str) -> dict:
86
48
 
87
49
 
88
50
  def get_user_jwt_from_event(event: dict) -> str:
51
+ warnings.warn("DELETE get_user_jwt_from_event",DeprecationWarning,stacklevel=2)
89
52
  logger.start(object={"event": event})
90
53
  auth_header = event.get(HEADERS_KEY, {}).get(AUTHORIZATION_KEY)
91
54
  if auth_header is None:
@@ -96,7 +59,10 @@ def get_user_jwt_from_event(event: dict) -> str:
96
59
 
97
60
 
98
61
  def create_return_http_headers() -> dict:
62
+ warnings.warn("DELETE create_return_http_headers",DeprecationWarning,stacklevel=2)
99
63
  logger.start()
64
+ # Adding "Access-Control-Allow-Origin" : "*" to take care of CORS from localhost
65
+ # TODO Do we need to add those? In which cases? try adding crossDomain: true, to the request, 'Access-Control-Allow-Credentials': true to header
100
66
  return_http_headers = {
101
67
  "Content-Type": "application/json",
102
68
  "Access-Control-Allow-Origin": "*",
@@ -106,6 +72,7 @@ def create_return_http_headers() -> dict:
106
72
 
107
73
 
108
74
  def create_error_http_response(exception: Exception, status_code: HTTPStatus = HTTPStatus.BAD_REQUEST) -> dict:
75
+ warnings.warn("DELETE create_error_http_response",DeprecationWarning,stacklevel=2)
109
76
  logger.start(object={"exception": exception})
110
77
  error_http_response = {
111
78
  "statusCode": status_code.value,
@@ -118,12 +85,12 @@ def create_error_http_response(exception: Exception, status_code: HTTPStatus = H
118
85
 
119
86
 
120
87
  def create_ok_http_response(body: Any) -> dict:
88
+ warnings.warn("DELETE create_ok_http_response",DeprecationWarning,stacklevel=2)
121
89
  logger.start(object={"body": body})
122
- # TODO: test sending statusCode/headers/body inside the body
123
90
  ok_http_response = {
124
- "statusCode": body.get("statusCode") or HTTPStatus.OK.value,
125
- "headers": body.get("headers") or create_return_http_headers(),
126
- "body": create_http_body(body.get("body") or body)
91
+ "statusCode": HTTPStatus.OK.value,
92
+ "headers": create_return_http_headers(),
93
+ "body": create_http_body(body)
127
94
  }
128
95
  logger.end(object={"ok_http_response": ok_http_response})
129
96
  return ok_http_response
@@ -131,9 +98,10 @@ def create_ok_http_response(body: Any) -> dict:
131
98
 
132
99
  # https://google.github.io/styleguide/jsoncstyleguide.xml?showone=Property_Name_Format#Property_Name_Format
133
100
  def create_http_body(body: Any) -> str:
101
+ warnings.warn("DELETE create_http_body",DeprecationWarning,stacklevel=2)
134
102
  # TODO console.warning() if the body is not a valid camelCase JSON
135
103
  # https://stackoverflow.com/questions/17156078/converting-identifier-naming-between-camelcase-and-underscores-during-json-seria
136
104
  logger.start(object={"body": body})
137
- http_body = to_json(body)
105
+ http_body = json.dumps(body)
138
106
  logger.end(object={"http_body": http_body})
139
107
  return http_body
@@ -1,12 +1,13 @@
1
1
  from abc import abstractmethod
2
2
 
3
3
  from .our_object import OurObject
4
-
5
-
4
+ import warnings
6
5
  class Item(OurObject):
7
6
  def __init__(self, **kwargs):
7
+ warnings.warn("DELETE __init__",DeprecationWarning,stacklevel=2)
8
8
  super().__init__(**kwargs)
9
9
 
10
10
  @abstractmethod
11
11
  def get_id(self):
12
+ warnings.warn("DELETE get_id",DeprecationWarning,stacklevel=2)
12
13
  raise NotImplementedError("Subclasses must implement the 'get_id' method.")
@@ -2,11 +2,13 @@ import json
2
2
  from abc import ABC, abstractmethod
3
3
 
4
4
  from .mini_logger import MiniLogger as logger
5
+ import warnings
5
6
 
6
7
 
7
8
  # TODO Where are we using it? Shall we extend the usage of OurObject as the father of all our entities?
8
9
  class OurObject(ABC):
9
10
  def __init__(self, **kwargs):
11
+ warnings.warn("DELETE __init__",DeprecationWarning,stacklevel=2)
10
12
  INIT_METHOD_NAME = '__init__'
11
13
  logger.start(INIT_METHOD_NAME, object={'kwargs': kwargs})
12
14
  self.kwargs = kwargs
@@ -14,11 +16,13 @@ class OurObject(ABC):
14
16
 
15
17
  @abstractmethod
16
18
  def get_name(self):
19
+ warnings.warn("DELETE get_name",DeprecationWarning,stacklevel=2)
17
20
  """Returns the name of the object"""
18
21
  raise NotImplementedError(
19
22
  "Subclasses must implement the 'get_name' method.")
20
23
 
21
24
  def get(self, attr_name: str):
25
+ warnings.warn("DELETE get",DeprecationWarning,stacklevel=2)
22
26
  """Returns the value of the attribute with the given name"""
23
27
  GET_METHOD_NAME = 'get'
24
28
  logger.start(GET_METHOD_NAME, object={'attr_name': attr_name})
@@ -28,14 +32,17 @@ class OurObject(ABC):
28
32
  return value
29
33
 
30
34
  def get_all_arguments(self):
35
+ warnings.warn("DELETE get_all_arguments",DeprecationWarning,stacklevel=2)
31
36
  """Returns all the arguments passed to the constructor as a dictionary"""
32
37
  return getattr(self, 'kwargs', None)
33
38
 
34
39
  def to_json(self) -> str:
40
+ warnings.warn("DELETE to_json",DeprecationWarning,stacklevel=2)
35
41
  """Returns a json string representation of this object"""
36
42
  return json.dumps(self.__dict__)
37
43
 
38
44
  def from_json(self, json_string: str) -> 'OurObject':
45
+ warnings.warn("DELETE from_json",DeprecationWarning,stacklevel=2)
39
46
  """Returns an instance of the class from a json string"""
40
47
  FROM_JSON_METHOD_NAME = 'from_json'
41
48
  logger.start(FROM_JSON_METHOD_NAME,
@@ -46,11 +53,13 @@ class OurObject(ABC):
46
53
  return self
47
54
 
48
55
  def __eq__(self, other) -> bool:
56
+ warnings.warn("DELETE __eq__",DeprecationWarning,stacklevel=2)
49
57
  """Checks if two objects are equal"""
50
58
  if not isinstance(other, OurObject):
51
59
  return False
52
60
  return self.__dict__ == other.__dict__
53
61
 
54
62
  def __ne__(self, other) -> bool:
63
+ warnings.warn("DELETE __ne__",DeprecationWarning,stacklevel=2)
55
64
  """Checks if two objects are not equal"""
56
65
  return not self.__eq__(other)
@@ -1,9 +1,11 @@
1
1
  from .valid_json_versions import valid_json_versions
2
+ import warnings
2
3
 
3
4
 
4
5
  # TODO Shall we merge it with the machine-learning-unified-json?
5
6
  class UnifiedJson:
6
7
  def __init__(self, data: dict, json_version: str):
8
+ warnings.warn("DELETE __init__",DeprecationWarning,stacklevel=2)
7
9
  if json_version not in valid_json_versions:
8
10
  raise Exception(
9
11
  f"version {json_version} is not in valid_json_versions {valid_json_versions}, "
@@ -13,16 +15,21 @@ class UnifiedJson:
13
15
  self.data = data
14
16
 
15
17
  def get_unified_json(self):
18
+ warnings.warn("DELETE get_unified_json",DeprecationWarning,stacklevel=2)
16
19
  return {"version": self.json_version, "data": self.data}
17
20
 
18
21
  def get_data(self):
22
+ warnings.warn("DELETE get_data",DeprecationWarning,stacklevel=2)
19
23
  return self.data
20
24
 
21
25
  def get_json_version(self):
26
+ warnings.warn("DELETE get_json_version",DeprecationWarning,stacklevel=2)
22
27
  return self.json_version
23
28
 
24
29
  def __str__(self):
30
+ warnings.warn("DELETE __str__",DeprecationWarning,stacklevel=2)
25
31
  return self.get_unified_json()
26
32
 
27
33
  def __repr__(self):
34
+ warnings.warn("DELETE __repr__",DeprecationWarning,stacklevel=2)
28
35
  return self.__str__()
@@ -1,18 +1,21 @@
1
- import inspect
2
1
  import json
2
+ import jwt
3
+ import requests
4
+ import re
3
5
  import os
4
6
  import random
5
- import re
6
7
  from datetime import date, datetime, time, timedelta, timezone
7
- from functools import lru_cache
8
8
  from urllib.parse import urlparse
9
+ import warnings
9
10
 
10
- import jwt
11
- import requests
12
11
  from dotenv import load_dotenv
13
12
  from url_remote.environment_name_enum import EnvironmentName
14
13
 
15
14
  from .mini_logger import MiniLogger as logger
15
+ from .http_response import (create_authorization_http_headers, # noqa - used for backwards compatibility
16
+ get_user_jwt_from_event,
17
+ create_return_http_headers, create_error_http_response, create_ok_http_response,
18
+ create_http_body)
16
19
 
17
20
  load_dotenv()
18
21
  # TODO Let's do brainstorming on this
@@ -33,11 +36,13 @@ DEFAULT_DATETIME_FORMAT = "%Y-%m-%d %H:%M:%S"
33
36
 
34
37
 
35
38
  def append_if_not_exist(lst: list, item: object) -> None:
39
+ warnings.warn("DELETE append_if_not_exist",DeprecationWarning,stacklevel=2)
36
40
  if item not in lst:
37
41
  lst.append(item)
38
42
 
39
43
 
40
44
  def to_dict(data: json or dict or None) -> dict:
45
+ warnings.warn("DELETE to_dict",DeprecationWarning,stacklevel=2)
41
46
  if data is None:
42
47
  return {}
43
48
  if isinstance(data, dict):
@@ -46,6 +51,7 @@ def to_dict(data: json or dict or None) -> dict:
46
51
 
47
52
 
48
53
  def to_json(data: json or dict or None) -> json:
54
+ warnings.warn("DELETE to_json",DeprecationWarning,stacklevel=2)
49
55
  if data is None:
50
56
  data = {}
51
57
  if isinstance(data, dict):
@@ -54,6 +60,7 @@ def to_json(data: json or dict or None) -> json:
54
60
 
55
61
 
56
62
  def timedelta_to_time_format(time_delta: timedelta) -> str:
63
+ warnings.warn("DELETE timedelta_to_time_format",DeprecationWarning,stacklevel=2)
57
64
  """
58
65
  Convert a timedelta to a time format in HH:MM:SS.
59
66
 
@@ -90,6 +97,7 @@ def timedelta_to_time_format(time_delta: timedelta) -> str:
90
97
 
91
98
 
92
99
  def is_valid_time_range(time_range: tuple) -> bool:
100
+ warnings.warn("DELETE is_valid_time_range",DeprecationWarning,stacklevel=2)
93
101
  """
94
102
  Validate that the time range is in the format 'HH:MM:SS'.
95
103
  """
@@ -116,6 +124,7 @@ def is_valid_time_range(time_range: tuple) -> bool:
116
124
  # TODO shall we also use Url type and not only str? - Strongly Type which I prefer
117
125
  # (if yes we should change it also in all the calls to this function)
118
126
  def validate_url(url: str):
127
+ warnings.warn("DELETE validate_url",DeprecationWarning,stacklevel=2)
119
128
  logger.start(object={"url": url})
120
129
  if url is not None or url != "":
121
130
  parsed_url = urlparse(url)
@@ -127,6 +136,7 @@ def validate_url(url: str):
127
136
 
128
137
 
129
138
  def is_valid_date_range(date_range: tuple) -> bool:
139
+ warnings.warn("DELETE is_valid_date_range",DeprecationWarning,stacklevel=2)
130
140
  """
131
141
  Validate that the date range is in the format 'YYYY-MM-DD'.
132
142
  """
@@ -145,6 +155,7 @@ def is_valid_date_range(date_range: tuple) -> bool:
145
155
 
146
156
 
147
157
  def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
158
+ warnings.warn("DELETE is_valid_datetime_range",DeprecationWarning,stacklevel=2)
148
159
  """
149
160
  Validate that the datetime range is in the format 'YYYY-MM-DD HH:MM:SS'.
150
161
  """
@@ -162,6 +173,7 @@ def is_valid_datetime_range(datetime_range: (datetime, datetime)) -> bool:
162
173
 
163
174
 
164
175
  def is_list_of_dicts(obj: object) -> bool:
176
+ warnings.warn("DELETE is_list_of_dicts",DeprecationWarning,stacklevel=2)
165
177
  """
166
178
  Check if an object is a list of dictionaries.
167
179
 
@@ -206,6 +218,7 @@ def is_list_of_dicts(obj: object) -> bool:
206
218
 
207
219
 
208
220
  def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
221
+ warnings.warn("DELETE is_time_in_time_range",DeprecationWarning,stacklevel=2)
209
222
  """
210
223
  Check if the given time is within the specified time range.
211
224
 
@@ -229,6 +242,7 @@ def is_time_in_time_range(check_time: time, time_range: tuple) -> bool:
229
242
 
230
243
 
231
244
  def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
245
+ warnings.warn("DELETE is_date_in_date_range",DeprecationWarning,stacklevel=2)
232
246
  """
233
247
  Check if the given date is within the specified date range.
234
248
 
@@ -253,6 +267,7 @@ def is_date_in_date_range(check_date: date, date_range: tuple) -> bool:
253
267
 
254
268
 
255
269
  def is_datetime_in_datetime_range(check_datetime: datetime, datetime_range: (datetime, datetime)) -> bool:
270
+ warnings.warn("DELETE is_datetime_in_datetime_range",DeprecationWarning,stacklevel=2)
256
271
  """
257
272
  Check if the given datetime is within the specified datetime range.
258
273
 
@@ -316,6 +331,7 @@ def get_dialog_jwt_secret_key() -> str:
316
331
 
317
332
 
318
333
  def encode_jwt(payload: dict, key: str) -> str:
334
+ warnings.warn("DELETE encode_jwt",DeprecationWarning,stacklevel=2)
319
335
  """Example:
320
336
  payload = {
321
337
  "user_id": 123,
@@ -327,6 +343,7 @@ def encode_jwt(payload: dict, key: str) -> str:
327
343
 
328
344
 
329
345
  def decode_jwt(token: str, key: str) -> dict:
346
+ warnings.warn("DELETE decode_jwt",DeprecationWarning,stacklevel=2)
330
347
  """key can be private / public"""
331
348
  return jwt.decode(token, key, algorithms=['HS256'])
332
349
 
@@ -352,39 +369,44 @@ def obfuscate_log_dict(log_dict: dict) -> dict:
352
369
  if isinstance(value, dict):
353
370
  obfuscated_log_dict[key] = obfuscate_log_dict(value)
354
371
  elif re.search(r'password|secret|token|jwt|e[\-_]?mail|phone|name|address|ssn', key, re.IGNORECASE):
355
- # TODO Maybe we can reveal a small part
372
+ # TODO Maybe we can reveal a small part
356
373
  obfuscated_log_dict[key] = "***"
357
374
  else:
358
375
  obfuscated_log_dict[key] = value
359
376
  return obfuscated_log_dict
360
377
 
361
-
362
378
  # TODO: add tests to the following functions
363
379
 
364
380
  def remove_digits(text: str) -> str:
381
+ warnings.warn("DELETE remove_digits",DeprecationWarning,stacklevel=2)
365
382
  return ''.join(i for i in text if not i.isdigit())
366
383
 
367
384
 
368
385
  def generate_otp():
386
+ warnings.warn("DELETE generate_otp",DeprecationWarning,stacklevel=2)
369
387
  """Generates a 6-digit OTP"""
370
388
  otp = random.randint(100000, 999999)
371
389
  return otp
372
390
 
373
391
 
374
392
  def get_current_datetime_string(datetime_format: str = DEFAULT_DATETIME_FORMAT, tz: timezone = None) -> str:
393
+ warnings.warn("DELETE get_current_datetime_string",DeprecationWarning,stacklevel=2)
375
394
  current_datetime_string = datetime.now(tz).strftime(datetime_format)
376
395
  return current_datetime_string
377
396
 
378
397
 
379
398
  def datetime_from_str(date_str: str, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> datetime:
399
+ warnings.warn("DELETE datetime_from_str",DeprecationWarning,stacklevel=2)
380
400
  return datetime.strptime(date_str, datetime_format)
381
401
 
382
402
 
383
403
  def datetime_to_str(input_datetime: datetime, datetime_format: str = DEFAULT_DATETIME_FORMAT) -> str:
404
+ warnings.warn("DELETE datetime_to_str",DeprecationWarning,stacklevel=2)
384
405
  return input_datetime.strftime(datetime_format)
385
406
 
386
407
 
387
408
  def validate_arguments(args: dict) -> None:
409
+ warnings.warn("DELETE validate_arguments",DeprecationWarning,stacklevel=2)
388
410
  """
389
411
  Validate method arguments to ensure they are not None or ''
390
412
  :param args: arguments to be validated (usually locals())
@@ -396,6 +418,7 @@ def validate_arguments(args: dict) -> None:
396
418
 
397
419
 
398
420
  def reformat_time_string(input_str: str) -> str:
421
+ warnings.warn("DELETE reformat_time_string",DeprecationWarning,stacklevel=2)
399
422
  """Example:
400
423
  "1234" -> "12:34:00:00"
401
424
  """
@@ -409,33 +432,10 @@ def reformat_time_string(input_str: str) -> str:
409
432
 
410
433
 
411
434
  def get_ip_v4():
435
+ warnings.warn("DELETE get_ip_v4",DeprecationWarning,stacklevel=2)
412
436
  return requests.get('https://ipv4.seeip.org/jsonip').json()['ip']
413
437
 
414
438
 
415
439
  def get_ip_v6():
440
+ warnings.warn("DELETE get_ip_v6",DeprecationWarning,stacklevel=2)
416
441
  return requests.get('https://api.seeip.org/jsonip').json()['ip']
417
-
418
-
419
- def snake_to_camel(snake_str: str) -> str:
420
- """Converts snake_case to camelCase."""
421
- components = snake_str.split('_')
422
- camel_str = components[0] + ''.join(x.title() for x in components[1:])
423
- return camel_str
424
-
425
-
426
- def camel_to_snake(camel_str: str) -> str:
427
- """Converts camelCase to snake_case."""
428
- snake_str = re.sub(r'(?<!^)(?=[A-Z])', '_', camel_str).lower()
429
- return snake_str
430
-
431
-
432
- @lru_cache(maxsize=64) # don't print the same warning multiple times
433
- def deprecation_warning(old_name: str, new_name: str, start_date: date = None) -> None:
434
- if start_date and start_date < date.today():
435
- return
436
- warnings_message = f"Please use {old_name} instead of {new_name}."
437
- try:
438
- warnings_message += " Called from: " + inspect.stack()[2].filename
439
- except Exception:
440
- pass
441
- logger.warning(warnings_message)
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: python-sdk-remote
3
- Version: 0.0.126
3
+ Version: 0.0.127
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
@@ -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.126', # https://pypi.org/project/python-sdk-remote/
10
+ version='0.0.127', # https://pypi.org/project/python-sdk-remote/
11
11
  author="Circles",
12
12
  author_email="info@circlez.ai",
13
13
  description="PyPI Package for Circles Python SDK Local Python",
@@ -1,11 +0,0 @@
1
- # TODO: rewrite with more example
2
-
3
- In serverless, use this decorator:
4
- ```py
5
- from python_sdk_remote.http_response import handler_decorator
6
- from logger_local.Logger import Logger
7
- logger = Logger.create_logger(object=your_logger_object)
8
- @handler_decorator(logger=logger)
9
- def my_handler(request_parameters: dict) -> dict:
10
- # here you can use both camelCase and snake_case keys from request_parameters
11
- ```