stinger-python-utils 0.1.1__py3-none-any.whl → 0.1.3__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 → message_creator.py} +13 -9
- {stinger_python_utils-0.1.1.dist-info → stinger_python_utils-0.1.3.dist-info}/METADATA +1 -1
- stinger_python_utils-0.1.3.dist-info/RECORD +7 -0
- stinger_python_utils-0.1.1.dist-info/RECORD +0 -7
- {stinger_python_utils-0.1.1.dist-info → stinger_python_utils-0.1.3.dist-info}/WHEEL +0 -0
- {stinger_python_utils-0.1.1.dist-info → stinger_python_utils-0.1.3.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,15 +1,13 @@
|
|
|
1
|
-
|
|
2
1
|
from pyqttier.message import Message
|
|
3
2
|
from pydantic import BaseModel
|
|
4
3
|
from typing import Union, Optional
|
|
5
4
|
import uuid
|
|
6
5
|
|
|
6
|
+
|
|
7
7
|
class MessageCreator:
|
|
8
8
|
|
|
9
9
|
@classmethod
|
|
10
|
-
def signal_message(
|
|
11
|
-
cls, topic: str, payload: BaseModel
|
|
12
|
-
) -> Message:
|
|
10
|
+
def signal_message(cls, topic: str, payload: BaseModel) -> Message:
|
|
13
11
|
return Message(
|
|
14
12
|
topic=topic,
|
|
15
13
|
payload=payload.model_dump_json(by_alias=True).encode("utf-8"),
|
|
@@ -34,7 +32,7 @@ class MessageCreator:
|
|
|
34
32
|
cls,
|
|
35
33
|
topic: str,
|
|
36
34
|
return_code: int,
|
|
37
|
-
correlation_id: Union[str, bytes],
|
|
35
|
+
correlation_id: Union[str, bytes, None] = None,
|
|
38
36
|
debug_info: Optional[str] = None,
|
|
39
37
|
) -> Message:
|
|
40
38
|
"""
|
|
@@ -62,14 +60,19 @@ class MessageCreator:
|
|
|
62
60
|
def response_message(
|
|
63
61
|
cls,
|
|
64
62
|
response_topic: str,
|
|
65
|
-
response_obj: BaseModel|str|bytes,
|
|
63
|
+
response_obj: BaseModel | str | bytes,
|
|
66
64
|
return_code: int,
|
|
67
|
-
correlation_id: Union[str, bytes],
|
|
65
|
+
correlation_id: Union[str, bytes, None] = None,
|
|
68
66
|
) -> Message:
|
|
69
67
|
"""
|
|
70
68
|
This could be used for a successful response to a request.
|
|
71
69
|
"""
|
|
72
|
-
|
|
70
|
+
if isinstance(response_obj, BaseModel):
|
|
71
|
+
payload = response_obj.model_dump_json(by_alias=True).encode("utf-8")
|
|
72
|
+
elif isinstance(response_obj, str):
|
|
73
|
+
payload = response_obj.encode("utf-8")
|
|
74
|
+
else:
|
|
75
|
+
payload = response_obj
|
|
73
76
|
msg_obj = Message(
|
|
74
77
|
topic=response_topic,
|
|
75
78
|
payload=payload,
|
|
@@ -96,6 +99,7 @@ class MessageCreator:
|
|
|
96
99
|
payload=state_obj.model_dump_json(by_alias=True).encode("utf-8"),
|
|
97
100
|
qos=1,
|
|
98
101
|
retain=True,
|
|
102
|
+
content_type="application/json",
|
|
99
103
|
)
|
|
100
104
|
if state_version is not None:
|
|
101
105
|
msg_obj.user_properties = {"PropertyVersion": str(state_version)}
|
|
@@ -135,7 +139,7 @@ class MessageCreator:
|
|
|
135
139
|
property_obj: BaseModel,
|
|
136
140
|
version: str,
|
|
137
141
|
return_code: int,
|
|
138
|
-
correlation_id: Union[str, bytes],
|
|
142
|
+
correlation_id: Union[str, bytes, None] = None,
|
|
139
143
|
debug_info: Optional[str] = None,
|
|
140
144
|
) -> Message:
|
|
141
145
|
"""
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
stinger_python_utils/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU,7
|
|
2
|
+
stinger_python_utils/message_creator.py,sha256=hTGXbVIuvc_7pzP73N0z2VzvRiNYFKNwNKLbvh4Kw14,6155
|
|
3
|
+
stinger_python_utils/return_codes.py,sha256=AAwshvHu3SBoctwMX35k3j666J4a7DQ3V8AnR7QBjC8,5114
|
|
4
|
+
stinger_python_utils-0.1.3.dist-info/METADATA,sha256=TKdZvY9ZQZ0X3j97eLRj_jpYV9L0eSp8a7tH6WaHbh8,364
|
|
5
|
+
stinger_python_utils-0.1.3.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
+
stinger_python_utils-0.1.3.dist-info/licenses/LICENSE,sha256=_T-8ExmblJbhv-1AxC6XDVEHg1JdJA-126NvRiMqS-I,1070
|
|
7
|
+
stinger_python_utils-0.1.3.dist-info/RECORD,,
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
stinger_python_utils/__init__.py,sha256=IjHRV0k2DNwvFrEHebmsXiBvmITE8nQUnsR07h9tVkU,7
|
|
2
|
-
stinger_python_utils/message_creator,sha256=Tho68dvdCje0a4DELlbzH2C9fhEqg7s2TkdBDohoON0,5942
|
|
3
|
-
stinger_python_utils/return_codes.py,sha256=AAwshvHu3SBoctwMX35k3j666J4a7DQ3V8AnR7QBjC8,5114
|
|
4
|
-
stinger_python_utils-0.1.1.dist-info/METADATA,sha256=QbLI1Q4u5TfM4X40JYKi-7W-_0etQNNRkbjFW-O7LZQ,364
|
|
5
|
-
stinger_python_utils-0.1.1.dist-info/WHEEL,sha256=WLgqFyCfm_KASv4WHyYy0P3pM_m7J5L9k2skdKLirC8,87
|
|
6
|
-
stinger_python_utils-0.1.1.dist-info/licenses/LICENSE,sha256=_T-8ExmblJbhv-1AxC6XDVEHg1JdJA-126NvRiMqS-I,1070
|
|
7
|
-
stinger_python_utils-0.1.1.dist-info/RECORD,,
|
|
File without changes
|
{stinger_python_utils-0.1.1.dist-info → stinger_python_utils-0.1.3.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|