atk-common 1.37.0__py3-none-any.whl → 1.38.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.
atk_common/__init__.py CHANGED
@@ -8,7 +8,7 @@ from atk_common.http_utils import is_http_status_ok, is_http_status_internal, ge
8
8
  from atk_common.file_utils import get_image_file_type
9
9
  from atk_common.log_utils import add_log_item, add_log_item_http
10
10
  from atk_common.rabbitmq_consumer import RabbitMQConsumer
11
- from atk_common.response_utils import create_response, is_response_ok, is_response_http, is_response_internal
11
+ from atk_common.internal_response_utils import create_response, is_response_ok, is_response_http, is_response_internal
12
12
 
13
13
  __all__ = [
14
14
  'get_utc_date_time',
atk_common/error_utils.py CHANGED
@@ -7,7 +7,7 @@ from atk_common.datetime_utils import get_utc_date_time
7
7
  from atk_common.enums.api_error_type_enum import ApiErrorType
8
8
  from atk_common.http_utils import is_http_status_internal
9
9
  from atk_common.log_utils import add_log_item
10
- from atk_common.response_utils import create_response
10
+ from atk_common.internal_response_utils import create_response
11
11
 
12
12
  def get_message(error):
13
13
  if hasattr(error, 'message'):
@@ -0,0 +1,26 @@
1
+ import json
2
+ from flask import Response
3
+ from http import HTTPStatus
4
+ from atk_common.enums.api_error_type_enum import ApiErrorType
5
+ from atk_common.error_utils import get_error_entity, resend_error_entity
6
+ from atk_common.http_utils import is_http_status_internal, is_http_status_ok
7
+ from atk_common.internal_response_utils import is_response_http
8
+
9
+ # If response['status'] == 0 (OK, http status = 200): create Response and return response['responseMsg']
10
+ # If http status == 500:
11
+ # If response['status'] == 1 (HTTP): resend received error entity
12
+ # If response['status'] == 2 (INTERNAL): create new error entity and return as response
13
+ # If http status other value: create new error entity and return as response
14
+ def create_http_response(method, response, container_info):
15
+ if is_http_status_ok(response['statusCode']):
16
+ return Response(
17
+ response=json.dumps(response['responseMsg']),
18
+ status=HTTPStatus.OK,
19
+ mimetype='application/json'
20
+ )
21
+ if is_http_status_internal(response['statusCode']):
22
+ if is_response_http(response):
23
+ resend_error_entity(response['responseMsg'])
24
+ return get_error_entity(response['responseMsg'], method, ApiErrorType.INTERNAL, response['statusCode'], container_info)
25
+ return get_error_entity(response['responseMsg'], method, ApiErrorType.CONNECTION, response['statusCode'], container_info)
26
+
atk_common/http_utils.py CHANGED
@@ -4,7 +4,7 @@ from http import HTTPStatus
4
4
  from atk_common.datetime_utils import get_utc_date_time
5
5
  from atk_common.enums.api_error_type_enum import ApiErrorType
6
6
  from atk_common.error_utils import get_error_entity, resend_error_entity
7
- from atk_common.response_utils import is_response_http
7
+ from atk_common.internal_response_utils import is_response_http
8
8
 
9
9
  def is_http_status_ok(status_code):
10
10
  return status_code >= HTTPStatus.OK.value and status_code < HTTPStatus.MULTIPLE_CHOICES.value
@@ -0,0 +1,18 @@
1
+ from atk_common.enums.response_status_type_enum import ResponseStatusType
2
+
3
+ def create_response(status, status_code, response_msg):
4
+ data = {}
5
+ data['status'] = status
6
+ data['statusCode'] = status_code
7
+ data['responseMsg'] = response_msg
8
+ return data
9
+
10
+ def is_response_ok(response):
11
+ return response['status'] == ResponseStatusType.OK
12
+
13
+ def is_response_http(response):
14
+ return response['status'] == ResponseStatusType.HTTP
15
+
16
+ def is_response_internal(response):
17
+ return response['status'] == ResponseStatusType.INTERNAL
18
+
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: atk_common
3
- Version: 1.37.0
3
+ Version: 1.38.0
4
4
  Summary: ATK common methods
5
5
  Home-page: https://github.com/pypa/atk_common
6
6
  Author: Roger
@@ -1,11 +1,13 @@
1
- atk_common/__init__.py,sha256=csSn6oq7DBZQ7-Ji9rAgNbWv5MfdEX118REj4W_6TBM,1725
1
+ atk_common/__init__.py,sha256=3BAQv-w7ngwXmAlYdEHLrHy9WB_gHXEm_zAiub1QXwc,1734
2
2
  atk_common/datetime_utils.py,sha256=3OIzPCt7W3vA4HvjnlfV0KJjRAjXuTaJ_QOa-cCMNns,2044
3
3
  atk_common/db_utils.py,sha256=odUtXcS7Mumw5eGyVyVimL_U_lP7TqMX9v8nWO5nMvg,902
4
4
  atk_common/docker_utils.py,sha256=nkUhp2OhwJsm41JDujHDY-JxQfdDjy91duprH59Esfk,2084
5
5
  atk_common/env_utils.py,sha256=66v-S0vlkJNaun6ay1XcOGRtYJb4Ce4odJsWxuaHsQc,373
6
- atk_common/error_utils.py,sha256=6sEWTmqIoz4gk_GL3I6QeyMfRYz1iYdptMn-bCYLbLQ,2636
6
+ atk_common/error_utils.py,sha256=l0V4I34Jio-uJf9in8ZoTfnXqWoUY1ILIURSKsc1EFY,2645
7
7
  atk_common/file_utils.py,sha256=UDwcRquO9IrqRrlUM0t-_g4R1-FKt8ZqQinSEqXOAk8,112
8
- atk_common/http_utils.py,sha256=ujGHxLbB5-5HgdhkMWgxochdF-j1Dd9ZCpBh1Hx1LDk,1963
8
+ atk_common/http_response_utils.py,sha256=Zvm52yHAAxooRA_op6HR23t3qxuilqbrLOHERoLIhoU,1423
9
+ atk_common/http_utils.py,sha256=Vcs2qWLNtKLYE0s-alXfHQ4QANLHaJVyuUJcqPwiB2E,1972
10
+ atk_common/internal_response_utils.py,sha256=nEbNxv4y03Qzhs1yRn--RnCfPrT7-ThlmqarAAQJtbw,562
9
11
  atk_common/log_utils.py,sha256=k7VaknmSGvHQV6-eznltNUa3BOAywjFHkhVzDT1P0Hs,496
10
12
  atk_common/mq_utils.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
11
13
  atk_common/rabbitmq_consumer.py,sha256=4MhuwZs47Jt1fX4sUxr1MKRe7o2QRbPe9_utXEsa8QE,1907
@@ -42,11 +44,11 @@ atk_common/enums/sensor_type_enum.py,sha256=UBa3LPyGTKgEJV578CqFlwXjnlXqVlybrvzd
42
44
  atk_common/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
43
45
  atk_common/enums/speed_control_status_type_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
44
46
  atk_common/enums/violation_type_enum.py,sha256=01qTHOj-O8bOc-nwIHVnxLosm4cusD_YuqXM3ZsiRRk,86
45
- atk_common-1.37.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
46
- atk_package/__init__.py,sha256=EceDa352WFHTdC_LxYANXf_TS9pGzK3MCx87bwAKTvg,811
47
+ atk_common-1.38.0.dist-info/licenses/license.txt,sha256=_0O6fWM00-wTurDjnZhUP_N5QiwGhItaQZqHq5eqadA,1063
48
+ atk_package/__init__.py,sha256=NcsmwFadivgIeWV0-5ACZxqmfo4EzTkJX0r4N6DFAdg,820
47
49
  atk_package/datetime_utils.py,sha256=qsVF7l90P1-xukG2tV_jLqG9J_Yfl5wTpyfrdPBlyMo,239
48
50
  atk_package/env_utils.py,sha256=bXOrxM3fZUslqfmZt75iphbEJHbG4riJa8XOVzPwIII,313
49
- atk_package/error_utils.py,sha256=cBDe5zOzOOuzRCs5WHo55knx74-ZUnDvaqrQtXBuZKw,1421
51
+ atk_package/error_utils.py,sha256=C-1GPo4hXHd0reW1gMEqyTjLMt257adGDjdYIyftiRE,1430
50
52
  atk_package/http_utils.py,sha256=5PjGYy-TiBbtNOElEDhsCs3BPDTfqg_aMQBNCuHfcrQ,90
51
53
  atk_package/log_utils.py,sha256=DGGwXjD5jvpMZJNW1QBoJRdDaTY1e1Z69j0LSOOzsWA,419
52
54
  atk_package/rabbitmq_consumer.py,sha256=wmZQieeONkfXB5RmM6yiNkwl0_QK4oWWDBSfiD47CdA,1753
@@ -55,7 +57,7 @@ atk_package/enums/__init__.py,sha256=EtUr_--MQj1Rc_R0sF_ELXIThmhpfmhDWq3YaK9oQMk
55
57
  atk_package/enums/command_status_enum.py,sha256=M2Nln27a_DbzI07-gfytWQk2X087JhkU6Fmard5qVHs,127
56
58
  atk_package/enums/speed_control_status_enum.py,sha256=qpURh0K1L1tSpbrzVnckoe4hUn1illIkbo7k4mLfzIM,182
57
59
  shared_python_atk_enforcement/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
58
- atk_common-1.37.0.dist-info/METADATA,sha256=XO-0ZTatJq7tuXy7HsawtmpNz80kpy2PjP7y7mJGeqE,1464
59
- atk_common-1.37.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
60
- atk_common-1.37.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
61
- atk_common-1.37.0.dist-info/RECORD,,
60
+ atk_common-1.38.0.dist-info/METADATA,sha256=oREqM-3i5coACoQfuJ66ktPeQ-uAvSVtJFz-ZKhtF2I,1464
61
+ atk_common-1.38.0.dist-info/WHEEL,sha256=pxyMxgL8-pra_rKaQ4drOZAegBVuX-G_4nRHjjgWbmo,91
62
+ atk_common-1.38.0.dist-info/top_level.txt,sha256=4CwRjkLnheIdI4jQwc4tK3dbRc58WqUmoqjkdDTWlME,41
63
+ atk_common-1.38.0.dist-info/RECORD,,
atk_package/__init__.py CHANGED
@@ -5,7 +5,7 @@ from atk_common.error_utils import get_message, get_error_entity, handle_error,
5
5
  from atk_common.http_utils import is_status_code_ok
6
6
  from atk_common.log_utils import add_log_item, add_log_item_http
7
7
  from atk_common.rabbitmq_consumer import RabbitMQConsumer
8
- from atk_common.response_utils import create_save_resp
8
+ from atk_common.internal_response_utils import create_save_resp
9
9
 
10
10
  __all__ = [
11
11
  'date_time_utc',
@@ -2,7 +2,7 @@ from datetime import datetime
2
2
  import json
3
3
  from atk_common.datetime_utils import get_utc_date_time
4
4
  from atk_common.log_utils import add_log_item
5
- from atk_common.response_utils import create_save_resp
5
+ from atk_common.internal_response_utils import create_save_resp
6
6
 
7
7
  def get_message(error):
8
8
  if hasattr(error, 'message'):