stinger-python-utils 0.1.4__py3-none-any.whl → 0.1.5__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.
- stinger_python_utils/message_creator.py +10 -7
- {stinger_python_utils-0.1.4.dist-info → stinger_python_utils-0.1.5.dist-info}/METADATA +1 -1
- stinger_python_utils-0.1.5.dist-info/RECORD +7 -0
- stinger_python_utils-0.1.4.dist-info/RECORD +0 -7
- {stinger_python_utils-0.1.4.dist-info → stinger_python_utils-0.1.5.dist-info}/WHEEL +0 -0
- {stinger_python_utils-0.1.4.dist-info → stinger_python_utils-0.1.5.dist-info}/licenses/LICENSE +0 -0
|
@@ -2,7 +2,7 @@ from pyqttier.message import Message
|
|
|
2
2
|
from pydantic import BaseModel
|
|
3
3
|
from typing import Union, Optional
|
|
4
4
|
import uuid
|
|
5
|
-
|
|
5
|
+
from .return_codes import MethodReturnCode
|
|
6
6
|
|
|
7
7
|
class MessageCreator:
|
|
8
8
|
|
|
@@ -31,13 +31,14 @@ class MessageCreator:
|
|
|
31
31
|
def error_response_message(
|
|
32
32
|
cls,
|
|
33
33
|
topic: str,
|
|
34
|
-
return_code: int,
|
|
34
|
+
return_code: Union[int, MethodReturnCode],
|
|
35
35
|
correlation_id: Union[str, bytes, None] = None,
|
|
36
36
|
debug_info: Optional[str] = None,
|
|
37
37
|
) -> Message:
|
|
38
38
|
"""
|
|
39
39
|
This could be used for a response to a request, but where there was an error fulfilling the request.
|
|
40
40
|
"""
|
|
41
|
+
rc = return_code.value if isinstance(return_code, MethodReturnCode) else return_code
|
|
41
42
|
msg_obj = Message(
|
|
42
43
|
topic=topic,
|
|
43
44
|
payload=b"{}",
|
|
@@ -48,7 +49,7 @@ class MessageCreator:
|
|
|
48
49
|
if isinstance(correlation_id, str)
|
|
49
50
|
else correlation_id
|
|
50
51
|
),
|
|
51
|
-
user_properties={"ReturnCode": str(
|
|
52
|
+
user_properties={"ReturnCode": str(rc)},
|
|
52
53
|
)
|
|
53
54
|
if (
|
|
54
55
|
debug_info is not None and msg_obj.user_properties is not None
|
|
@@ -61,7 +62,7 @@ class MessageCreator:
|
|
|
61
62
|
cls,
|
|
62
63
|
response_topic: str,
|
|
63
64
|
response_obj: Union[BaseModel, str, bytes],
|
|
64
|
-
return_code: int,
|
|
65
|
+
return_code: Union[int, MethodReturnCode],
|
|
65
66
|
correlation_id: Union[str, bytes, None] = None,
|
|
66
67
|
) -> Message:
|
|
67
68
|
"""
|
|
@@ -73,6 +74,7 @@ class MessageCreator:
|
|
|
73
74
|
payload = response_obj.encode("utf-8")
|
|
74
75
|
else:
|
|
75
76
|
payload = response_obj
|
|
77
|
+
rc = return_code.value if isinstance(return_code, MethodReturnCode) else return_code
|
|
76
78
|
msg_obj = Message(
|
|
77
79
|
topic=response_topic,
|
|
78
80
|
payload=payload,
|
|
@@ -83,7 +85,7 @@ class MessageCreator:
|
|
|
83
85
|
if isinstance(correlation_id, str)
|
|
84
86
|
else correlation_id
|
|
85
87
|
),
|
|
86
|
-
user_properties={"ReturnCode": str(
|
|
88
|
+
user_properties={"ReturnCode": str(rc)},
|
|
87
89
|
)
|
|
88
90
|
return msg_obj
|
|
89
91
|
|
|
@@ -138,13 +140,14 @@ class MessageCreator:
|
|
|
138
140
|
response_topic: str,
|
|
139
141
|
property_obj: BaseModel,
|
|
140
142
|
version: str,
|
|
141
|
-
return_code: int,
|
|
143
|
+
return_code: Union[int, MethodReturnCode],
|
|
142
144
|
correlation_id: Union[str, bytes, None] = None,
|
|
143
145
|
debug_info: Optional[str] = None,
|
|
144
146
|
) -> Message:
|
|
145
147
|
"""
|
|
146
148
|
Creates a message representing a response to a property update request.
|
|
147
149
|
"""
|
|
150
|
+
rc = return_code.value if isinstance(return_code, MethodReturnCode) else return_code
|
|
148
151
|
msg_obj = Message(
|
|
149
152
|
topic=response_topic,
|
|
150
153
|
payload=property_obj.model_dump_json(by_alias=True).encode("utf-8"),
|
|
@@ -156,7 +159,7 @@ class MessageCreator:
|
|
|
156
159
|
else correlation_id
|
|
157
160
|
),
|
|
158
161
|
user_properties={
|
|
159
|
-
"ReturnCode": str(
|
|
162
|
+
"ReturnCode": str(rc),
|
|
160
163
|
"PropertyVersion": str(version),
|
|
161
164
|
},
|
|
162
165
|
)
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
stinger_python_utils/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU,7
|
|
2
|
+
stinger_python_utils/message_creator.py,sha256=KHiw7Zk2n8QI96Zv4dT2Isj8ZljwSKaVfyoOyIjlRCA,6529
|
|
3
|
+
stinger_python_utils/return_codes.py,sha256=AAwshvHu3SBoctwMX35k3j666J4a7DQ3V8AnR7QBjC8,5114
|
|
4
|
+
stinger_python_utils-0.1.5.dist-info/METADATA,sha256=6qVtX_zsa7TGr3Ny8myBxm0dhY2OSR_IP6xx5SB5Yog,2769
|
|
5
|
+
stinger_python_utils-0.1.5.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
stinger_python_utils-0.1.5.dist-info/licenses/LICENSE,sha256=_T-8ExmblJbhv-1AxC6XDVEHg1JdJA-126NvRiMqS-I,1070
|
|
7
|
+
stinger_python_utils-0.1.5.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
stinger_python_utils/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU,7
|
|
2
|
-
stinger_python_utils/message_creator.py,sha256=tsGmcw5-iC58lBq4aJQrI3IDZ3cE88C5FOT_5lHLvn0,6160
|
|
3
|
-
stinger_python_utils/return_codes.py,sha256=AAwshvHu3SBoctwMX35k3j666J4a7DQ3V8AnR7QBjC8,5114
|
|
4
|
-
stinger_python_utils-0.1.4.dist-info/METADATA,sha256=Ces8NRPz6g4Vuo2UYlG_3yMSmciZF9XuaAcJqfMHYFA,2769
|
|
5
|
-
stinger_python_utils-0.1.4.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
-
stinger_python_utils-0.1.4.dist-info/licenses/LICENSE,sha256=_T-8ExmblJbhv-1AxC6XDVEHg1JdJA-126NvRiMqS-I,1070
|
|
7
|
-
stinger_python_utils-0.1.4.dist-info/RECORD,,
|
|
File without changes
|
{stinger_python_utils-0.1.4.dist-info → stinger_python_utils-0.1.5.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|