stinger-python-utils 0.1.4__tar.gz → 0.1.6__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.
- stinger_python_utils-0.1.6/.vscode/settings.json +4 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/PKG-INFO +1 -1
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/pyproject.toml +1 -1
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/src/stinger_python_utils/message_creator.py +22 -6
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/uv.lock +1 -1
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/.github/workflows/python-tests.yml +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/.github/workflows/python37.yml +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/.gitignore +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/.python-version +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/LICENSE +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/README.md +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/src/stinger_python_utils/__init__.py +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/src/stinger_python_utils/return_codes.py +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/test/__init__.py +0 -0
- {stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/test/test_message_creator.py +0 -0
|
@@ -2,6 +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
|
+
from .return_codes import MethodReturnCode
|
|
5
6
|
|
|
6
7
|
|
|
7
8
|
class MessageCreator:
|
|
@@ -31,13 +32,18 @@ class MessageCreator:
|
|
|
31
32
|
def error_response_message(
|
|
32
33
|
cls,
|
|
33
34
|
topic: str,
|
|
34
|
-
return_code: int,
|
|
35
|
+
return_code: Union[int, MethodReturnCode],
|
|
35
36
|
correlation_id: Union[str, bytes, None] = None,
|
|
36
37
|
debug_info: Optional[str] = None,
|
|
37
38
|
) -> Message:
|
|
38
39
|
"""
|
|
39
40
|
This could be used for a response to a request, but where there was an error fulfilling the request.
|
|
40
41
|
"""
|
|
42
|
+
rc = (
|
|
43
|
+
return_code.value
|
|
44
|
+
if isinstance(return_code, MethodReturnCode)
|
|
45
|
+
else return_code
|
|
46
|
+
)
|
|
41
47
|
msg_obj = Message(
|
|
42
48
|
topic=topic,
|
|
43
49
|
payload=b"{}",
|
|
@@ -48,7 +54,7 @@ class MessageCreator:
|
|
|
48
54
|
if isinstance(correlation_id, str)
|
|
49
55
|
else correlation_id
|
|
50
56
|
),
|
|
51
|
-
user_properties={"ReturnCode": str(
|
|
57
|
+
user_properties={"ReturnCode": str(rc)},
|
|
52
58
|
)
|
|
53
59
|
if (
|
|
54
60
|
debug_info is not None and msg_obj.user_properties is not None
|
|
@@ -61,7 +67,7 @@ class MessageCreator:
|
|
|
61
67
|
cls,
|
|
62
68
|
response_topic: str,
|
|
63
69
|
response_obj: Union[BaseModel, str, bytes],
|
|
64
|
-
return_code: int,
|
|
70
|
+
return_code: Union[int, MethodReturnCode],
|
|
65
71
|
correlation_id: Union[str, bytes, None] = None,
|
|
66
72
|
) -> Message:
|
|
67
73
|
"""
|
|
@@ -73,6 +79,11 @@ class MessageCreator:
|
|
|
73
79
|
payload = response_obj.encode("utf-8")
|
|
74
80
|
else:
|
|
75
81
|
payload = response_obj
|
|
82
|
+
rc = (
|
|
83
|
+
return_code.value
|
|
84
|
+
if isinstance(return_code, MethodReturnCode)
|
|
85
|
+
else return_code
|
|
86
|
+
)
|
|
76
87
|
msg_obj = Message(
|
|
77
88
|
topic=response_topic,
|
|
78
89
|
payload=payload,
|
|
@@ -83,7 +94,7 @@ class MessageCreator:
|
|
|
83
94
|
if isinstance(correlation_id, str)
|
|
84
95
|
else correlation_id
|
|
85
96
|
),
|
|
86
|
-
user_properties={"ReturnCode": str(
|
|
97
|
+
user_properties={"ReturnCode": str(rc)},
|
|
87
98
|
)
|
|
88
99
|
return msg_obj
|
|
89
100
|
|
|
@@ -138,13 +149,18 @@ class MessageCreator:
|
|
|
138
149
|
response_topic: str,
|
|
139
150
|
property_obj: BaseModel,
|
|
140
151
|
version: str,
|
|
141
|
-
return_code: int,
|
|
152
|
+
return_code: Union[int, MethodReturnCode],
|
|
142
153
|
correlation_id: Union[str, bytes, None] = None,
|
|
143
154
|
debug_info: Optional[str] = None,
|
|
144
155
|
) -> Message:
|
|
145
156
|
"""
|
|
146
157
|
Creates a message representing a response to a property update request.
|
|
147
158
|
"""
|
|
159
|
+
rc = (
|
|
160
|
+
return_code.value
|
|
161
|
+
if isinstance(return_code, MethodReturnCode)
|
|
162
|
+
else return_code
|
|
163
|
+
)
|
|
148
164
|
msg_obj = Message(
|
|
149
165
|
topic=response_topic,
|
|
150
166
|
payload=property_obj.model_dump_json(by_alias=True).encode("utf-8"),
|
|
@@ -156,7 +172,7 @@ class MessageCreator:
|
|
|
156
172
|
else correlation_id
|
|
157
173
|
),
|
|
158
174
|
user_properties={
|
|
159
|
-
"ReturnCode": str(
|
|
175
|
+
"ReturnCode": str(rc),
|
|
160
176
|
"PropertyVersion": str(version),
|
|
161
177
|
},
|
|
162
178
|
)
|
|
@@ -1272,7 +1272,7 @@ wheels = [
|
|
|
1272
1272
|
|
|
1273
1273
|
[[package]]
|
|
1274
1274
|
name = "stinger-python-utils"
|
|
1275
|
-
version = "0.1.
|
|
1275
|
+
version = "0.1.6"
|
|
1276
1276
|
source = { editable = "." }
|
|
1277
1277
|
dependencies = [
|
|
1278
1278
|
{ name = "pydantic", version = "2.5.3", source = { registry = "https://pypi.org/simple" }, marker = "python_full_version < '3.8'" },
|
{stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/.github/workflows/python-tests.yml
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/src/stinger_python_utils/__init__.py
RENAMED
|
File without changes
|
{stinger_python_utils-0.1.4 → stinger_python_utils-0.1.6}/src/stinger_python_utils/return_codes.py
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|