codecraftai-agent-kit 1.3.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.
Files changed (230) hide show
  1. ccai/agentkit/__init__.py +304 -0
  2. ccai/agentkit/addressresolver.py +177 -0
  3. ccai/agentkit/agent.py +2945 -0
  4. ccai/agentkit/agentaddress.py +187 -0
  5. ccai/agentkit/agentconfiguration.py +581 -0
  6. ccai/agentkit/agentidentity.py +152 -0
  7. ccai/agentkit/agentregistry.py +221 -0
  8. ccai/agentkit/agentstatemachine.py +134 -0
  9. ccai/agentkit/alternateproviderstrategy.py +36 -0
  10. ccai/agentkit/approvalgate.py +238 -0
  11. ccai/agentkit/approvalrequest.py +250 -0
  12. ccai/agentkit/asyncagent.py +187 -0
  13. ccai/agentkit/breakpoint.py +150 -0
  14. ccai/agentkit/builtinagentmetrics.py +114 -0
  15. ccai/agentkit/builtins/__init__.py +11 -0
  16. ccai/agentkit/builtins/filereadtool.py +90 -0
  17. ccai/agentkit/builtins/filewritetool.py +93 -0
  18. ccai/agentkit/builtins/httprequesttool.py +169 -0
  19. ccai/agentkit/builtins/shellcommandtool.py +190 -0
  20. ccai/agentkit/cachedresultstrategy.py +43 -0
  21. ccai/agentkit/checkpointmanager.py +219 -0
  22. ccai/agentkit/circuitbreaker.py +230 -0
  23. ccai/agentkit/circuitbreakerconfiguration.py +158 -0
  24. ccai/agentkit/circuitbreakerevent.py +158 -0
  25. ccai/agentkit/circuitbreakerhealthcheck.py +32 -0
  26. ccai/agentkit/circuitbreakerregistry.py +116 -0
  27. ccai/agentkit/circuitbreakerstate.py +44 -0
  28. ccai/agentkit/clearcacheaction.py +46 -0
  29. ccai/agentkit/concurrencybridge.py +143 -0
  30. ccai/agentkit/concurrencymodel.py +19 -0
  31. ccai/agentkit/conditionevaluator.py +594 -0
  32. ccai/agentkit/configurationchangeevent.py +179 -0
  33. ccai/agentkit/configurationerrors.py +152 -0
  34. ccai/agentkit/configurationlayer.py +160 -0
  35. ccai/agentkit/configurationlayersource.py +46 -0
  36. ccai/agentkit/configurationmanager.py +680 -0
  37. ccai/agentkit/configurationschema.py +224 -0
  38. ccai/agentkit/configurationschemafield.py +217 -0
  39. ccai/agentkit/configurationserializer.py +163 -0
  40. ccai/agentkit/configurationvalidationresult.py +118 -0
  41. ccai/agentkit/contextsummarizer.py +170 -0
  42. ccai/agentkit/contextwindow.py +264 -0
  43. ccai/agentkit/contextwindowstrategy.py +57 -0
  44. ccai/agentkit/correlationcontext.py +156 -0
  45. ccai/agentkit/costestimate.py +139 -0
  46. ccai/agentkit/costtracker.py +121 -0
  47. ccai/agentkit/deadletterentry.py +134 -0
  48. ccai/agentkit/deadletterquery.py +119 -0
  49. ccai/agentkit/deadletterqueue.py +123 -0
  50. ccai/agentkit/deadletterstore.py +86 -0
  51. ccai/agentkit/debuginspector.py +211 -0
  52. ccai/agentkit/debugsession.py +223 -0
  53. ccai/agentkit/defaultvaluestrategy.py +43 -0
  54. ccai/agentkit/degradationchangeevent.py +120 -0
  55. ccai/agentkit/degradationlevel.py +44 -0
  56. ccai/agentkit/degradationmanager.py +212 -0
  57. ccai/agentkit/degradationpolicy.py +130 -0
  58. ccai/agentkit/degradationstrategy.py +66 -0
  59. ccai/agentkit/embeddingprovider.py +106 -0
  60. ccai/agentkit/errors.py +95 -0
  61. ccai/agentkit/executionrecord.py +213 -0
  62. ccai/agentkit/executionrecorder.py +180 -0
  63. ccai/agentkit/executionrecording.py +230 -0
  64. ccai/agentkit/executionreplayer.py +187 -0
  65. ccai/agentkit/expirationpolicy.py +116 -0
  66. ccai/agentkit/fallbackchain.py +82 -0
  67. ccai/agentkit/featureflag.py +154 -0
  68. ccai/agentkit/featureflagevaluator.py +109 -0
  69. ccai/agentkit/featureflagregistry.py +258 -0
  70. ccai/agentkit/filedeadletterstore.py +112 -0
  71. ccai/agentkit/filememorystore.py +291 -0
  72. ccai/agentkit/healthcheck.py +46 -0
  73. ccai/agentkit/healthcheckregistry.py +51 -0
  74. ccai/agentkit/healthmonitor.py +258 -0
  75. ccai/agentkit/healthstatus.py +105 -0
  76. ccai/agentkit/hotreloadmonitor.py +214 -0
  77. ccai/agentkit/hotreloadpolicy.py +160 -0
  78. ccai/agentkit/inmemorydeadletterstore.py +61 -0
  79. ccai/agentkit/inmemorystore.py +173 -0
  80. ccai/agentkit/jsonmessageserializer.py +89 -0
  81. ccai/agentkit/jsonoutputparser.py +50 -0
  82. ccai/agentkit/lifecyclestate.py +22 -0
  83. ccai/agentkit/llmconversation.py +153 -0
  84. ccai/agentkit/llmerrors.py +193 -0
  85. ccai/agentkit/llmmessage.py +158 -0
  86. ccai/agentkit/llmprovider.py +158 -0
  87. ccai/agentkit/llmproviderregistry.py +200 -0
  88. ccai/agentkit/llmresponse.py +190 -0
  89. ccai/agentkit/llmstreamchunk.py +65 -0
  90. ccai/agentkit/llmstreamhandler.py +48 -0
  91. ccai/agentkit/llmtoolbridge.py +154 -0
  92. ccai/agentkit/logexporter.py +316 -0
  93. ccai/agentkit/logformatter.py +169 -0
  94. ccai/agentkit/memoryconfiguration.py +243 -0
  95. ccai/agentkit/memoryentry.py +254 -0
  96. ccai/agentkit/memoryerrors.py +135 -0
  97. ccai/agentkit/memoryindex.py +213 -0
  98. ccai/agentkit/memoryquery.py +248 -0
  99. ccai/agentkit/memoryqueryresult.py +86 -0
  100. ccai/agentkit/memoryscope.py +54 -0
  101. ccai/agentkit/memorystore.py +260 -0
  102. ccai/agentkit/memorystorehealthcheck.py +33 -0
  103. ccai/agentkit/memorystoreregistry.py +106 -0
  104. ccai/agentkit/message.py +310 -0
  105. ccai/agentkit/messageenvelope.py +144 -0
  106. ccai/agentkit/messagepattern.py +50 -0
  107. ccai/agentkit/messagerouter.py +290 -0
  108. ccai/agentkit/messageserializer.py +106 -0
  109. ccai/agentkit/messageserializerregistry.py +163 -0
  110. ccai/agentkit/messagingconfiguration.py +397 -0
  111. ccai/agentkit/messagingerrors.py +338 -0
  112. ccai/agentkit/metricdefinition.py +164 -0
  113. ccai/agentkit/metricmeasurement.py +178 -0
  114. ccai/agentkit/metricscollector.py +258 -0
  115. ccai/agentkit/metricsexporter.py +303 -0
  116. ccai/agentkit/metricsregistry.py +130 -0
  117. ccai/agentkit/metricssnapshot.py +155 -0
  118. ccai/agentkit/metrictype.py +51 -0
  119. ccai/agentkit/msgpackmessageserializer.py +97 -0
  120. ccai/agentkit/observabilityconfiguration.py +546 -0
  121. ccai/agentkit/observabilityerror.py +67 -0
  122. ccai/agentkit/observabilitypipeline.py +252 -0
  123. ccai/agentkit/outputparser.py +82 -0
  124. ccai/agentkit/outputschema.py +142 -0
  125. ccai/agentkit/parallelbranch.py +87 -0
  126. ccai/agentkit/platform/__init__.py +43 -0
  127. ccai/agentkit/platform/adapters/__init__.py +18 -0
  128. ccai/agentkit/platform/adapters/awsplatformadapter.py +1272 -0
  129. ccai/agentkit/platform/adapters/azureplatformadapter.py +1227 -0
  130. ccai/agentkit/platform/adapters/gcpplatformadapter.py +1257 -0
  131. ccai/agentkit/platform/adapters/localplatformadapter.py +956 -0
  132. ccai/agentkit/platform/adapters/platformadapter.py +139 -0
  133. ccai/agentkit/platform/deployment/__init__.py +15 -0
  134. ccai/agentkit/platform/deployment/deploymentdescriptor.py +234 -0
  135. ccai/agentkit/platform/deployment/deploymentdescriptorparser.py +178 -0
  136. ccai/agentkit/platform/deployment/deploymentdescriptorprinter.py +97 -0
  137. ccai/agentkit/platform/errors.py +224 -0
  138. ccai/agentkit/platform/platformconfiguration.py +412 -0
  139. ccai/agentkit/platform/platformdetector.py +125 -0
  140. ccai/agentkit/platform/platformruntime.py +331 -0
  141. ccai/agentkit/platform/platformserviceregistry.py +149 -0
  142. ccai/agentkit/platform/platformtype.py +60 -0
  143. ccai/agentkit/platform/services/__init__.py +19 -0
  144. ccai/agentkit/platform/services/computeservice.py +112 -0
  145. ccai/agentkit/platform/services/invocationresult.py +173 -0
  146. ccai/agentkit/platform/services/messagingservice.py +135 -0
  147. ccai/agentkit/platform/services/platformservice.py +111 -0
  148. ccai/agentkit/platform/services/queuemessage.py +193 -0
  149. ccai/agentkit/platform/services/storageobject.py +195 -0
  150. ccai/agentkit/platform/services/storageservice.py +159 -0
  151. ccai/agentkit/pluginconfiguration.py +241 -0
  152. ccai/agentkit/plugindependency.py +129 -0
  153. ccai/agentkit/plugindescriptor.py +225 -0
  154. ccai/agentkit/pluginlifecyclehook.py +41 -0
  155. ccai/agentkit/pluginmanager.py +360 -0
  156. ccai/agentkit/pluginstatus.py +47 -0
  157. ccai/agentkit/pooledagent.py +116 -0
  158. ccai/agentkit/prompttemplate.py +221 -0
  159. ccai/agentkit/prompttemplateregistry.py +145 -0
  160. ccai/agentkit/protobufmessageserializer.py +144 -0
  161. ccai/agentkit/pubsubbroker.py +311 -0
  162. ccai/agentkit/py.typed +0 -0
  163. ccai/agentkit/reconnecttransportaction.py +47 -0
  164. ccai/agentkit/regexoutputparser.py +68 -0
  165. ccai/agentkit/requestresponsehandler.py +274 -0
  166. ccai/agentkit/resetcircuitbreakeraction.py +48 -0
  167. ccai/agentkit/resilienceconfiguration.py +191 -0
  168. ccai/agentkit/resilienceerrors.py +103 -0
  169. ccai/agentkit/resiliencepipeline.py +201 -0
  170. ccai/agentkit/retryattempt.py +158 -0
  171. ccai/agentkit/retryexecutor.py +157 -0
  172. ccai/agentkit/retrypolicy.py +195 -0
  173. ccai/agentkit/retryresult.py +186 -0
  174. ccai/agentkit/selfhealingaction.py +42 -0
  175. ccai/agentkit/selfhealingpolicy.py +67 -0
  176. ccai/agentkit/selfhealingresult.py +130 -0
  177. ccai/agentkit/stepexecutionstatus.py +52 -0
  178. ccai/agentkit/stepresult.py +198 -0
  179. ccai/agentkit/steps/__init__.py +9 -0
  180. ccai/agentkit/steps/agentstep.py +247 -0
  181. ccai/agentkit/steps/approvalstep.py +276 -0
  182. ccai/agentkit/steps/llmstep.py +403 -0
  183. ccai/agentkit/steps/subworkflowstep.py +270 -0
  184. ccai/agentkit/steps/toolstep.py +265 -0
  185. ccai/agentkit/structuredlogentry.py +222 -0
  186. ccai/agentkit/structuredlogger.py +189 -0
  187. ccai/agentkit/subscription.py +141 -0
  188. ccai/agentkit/threadedagent.py +94 -0
  189. ccai/agentkit/tokenusage.py +136 -0
  190. ccai/agentkit/tool.py +203 -0
  191. ccai/agentkit/toolchain.py +268 -0
  192. ccai/agentkit/toolchainexecutor.py +134 -0
  193. ccai/agentkit/toolchainresult.py +166 -0
  194. ccai/agentkit/tooldescriptor.py +203 -0
  195. ccai/agentkit/toolerrors.py +160 -0
  196. ccai/agentkit/toolexecutor.py +168 -0
  197. ccai/agentkit/toolfactory.py +60 -0
  198. ccai/agentkit/toolregistry.py +184 -0
  199. ccai/agentkit/toolresult.py +142 -0
  200. ccai/agentkit/toolschema.py +197 -0
  201. ccai/agentkit/tracecontext.py +294 -0
  202. ccai/agentkit/traceevent.py +166 -0
  203. ccai/agentkit/traceexporter.py +305 -0
  204. ccai/agentkit/tracer.py +234 -0
  205. ccai/agentkit/tracespan.py +349 -0
  206. ccai/agentkit/transitionrecord.py +84 -0
  207. ccai/agentkit/transport.py +334 -0
  208. ccai/agentkit/transportconfiguration.py +436 -0
  209. ccai/agentkit/transporthealthcheck.py +36 -0
  210. ccai/agentkit/transportregistry.py +224 -0
  211. ccai/agentkit/transports/__init__.py +28 -0
  212. ccai/agentkit/transports/grpctransport.py +410 -0
  213. ccai/agentkit/transports/httptransport.py +423 -0
  214. ccai/agentkit/transports/messagequeuetransport.py +489 -0
  215. ccai/agentkit/transports/websockettransport.py +473 -0
  216. ccai/agentkit/workflowcheckpoint.py +208 -0
  217. ccai/agentkit/workflowconfiguration.py +295 -0
  218. ccai/agentkit/workflowcontext.py +249 -0
  219. ccai/agentkit/workflowdefinition.py +790 -0
  220. ccai/agentkit/workflowedge.py +128 -0
  221. ccai/agentkit/workflowerrors.py +295 -0
  222. ccai/agentkit/workflowexecutionstatus.py +48 -0
  223. ccai/agentkit/workflowexecutor.py +1121 -0
  224. ccai/agentkit/workflowregistry.py +185 -0
  225. ccai/agentkit/workflowresult.py +250 -0
  226. ccai/agentkit/workflowstep.py +195 -0
  227. codecraftai_agent_kit-1.3.0.dist-info/METADATA +99 -0
  228. codecraftai_agent_kit-1.3.0.dist-info/RECORD +230 -0
  229. codecraftai_agent_kit-1.3.0.dist-info/WHEEL +4 -0
  230. codecraftai_agent_kit-1.3.0.dist-info/licenses/LICENSE.md +204 -0
@@ -0,0 +1,397 @@
1
+ """
2
+ Defines the MessagingConfiguration class for declarative messaging
3
+ system settings in the Communication & Messaging feature.
4
+
5
+ A MessagingConfiguration contains the default transport name, default
6
+ serialization format name, default request timeout, optional
7
+ transport configurations, pub/sub settings, credential references,
8
+ and additional options. The class provides JSON and YAML
9
+ serialization and deserialization, including file-based loading
10
+ with optional AppContext path resolution.
11
+
12
+ Credential reference values are excluded from serialized output
13
+ (as_dict, to_json) to prevent leaking secrets.
14
+
15
+ Requirements: 20.1-20.15, 26.23, 26.24
16
+ """
17
+
18
+ import json
19
+ import os
20
+
21
+ import yaml
22
+
23
+ from ccai.agentkit.errors import ConfigurationError
24
+
25
+
26
+ class MessagingConfiguration:
27
+ """
28
+ Configuration object defining default transport, serialization
29
+ format, request timeout, transport configurations, pub/sub
30
+ settings, credential references, and additional options for
31
+ an Agent's messaging system.
32
+
33
+ Validation is performed at construction time:
34
+ - default_transport must be provided and non-empty
35
+ - default_serialization_format must be provided and non-empty
36
+ - default_request_timeout must be provided
37
+
38
+ :param default_transport: The default transport name string.
39
+ :param default_serialization_format: The default serialization
40
+ format name string (e.g., "json").
41
+ :param default_request_timeout: The default timeout in seconds
42
+ for request/response exchanges as a float. Defaults to 30.0.
43
+ :param transport_configurations: An optional dictionary mapping
44
+ transport names to TransportConfiguration dictionaries.
45
+ Defaults to an empty dictionary.
46
+ :param pubsub_settings: An optional dictionary of pub/sub
47
+ configuration settings. Defaults to an empty dictionary.
48
+ :param credential_references: An optional dictionary of named
49
+ credential references for authentication. Defaults to an
50
+ empty dictionary.
51
+ :param options: An optional dictionary of additional
52
+ configuration options. Defaults to an empty dictionary.
53
+
54
+ :raises ConfigurationError: If required fields are missing.
55
+ """
56
+
57
+ REQUIRED_FIELDS = ["default_transport", "default_serialization_format", "default_request_timeout"]
58
+
59
+ def __init__(self, default_transport: str,
60
+ default_serialization_format: str,
61
+ default_request_timeout: float = 30.0,
62
+ transport_configurations: dict = None,
63
+ pubsub_settings: dict = None,
64
+ credential_references: dict = None,
65
+ options: dict = None) -> None:
66
+
67
+ self._validate_required_fields(
68
+ default_transport=default_transport,
69
+ default_serialization_format=default_serialization_format,
70
+ default_request_timeout=default_request_timeout
71
+ )
72
+
73
+ self._default_transport = default_transport
74
+ self._default_serialization_format = default_serialization_format
75
+ self._default_request_timeout = default_request_timeout
76
+ self._transport_configurations = dict(transport_configurations) if transport_configurations is not None else {}
77
+ self._pubsub_settings = dict(pubsub_settings) if pubsub_settings is not None else {}
78
+ self._credential_references = dict(credential_references) if credential_references is not None else {}
79
+ self._options = dict(options) if options is not None else {}
80
+
81
+ return
82
+
83
+ def _validate_required_fields(self, default_transport: str,
84
+ default_serialization_format: str,
85
+ default_request_timeout: float) -> None:
86
+ """
87
+ Validates that all required fields are present and non-empty.
88
+
89
+ :param default_transport: The default transport name to validate.
90
+ :param default_serialization_format: The default serialization
91
+ format name to validate.
92
+ :param default_request_timeout: The default request timeout
93
+ to validate.
94
+
95
+ :raises ConfigurationError: If any required field is missing
96
+ or empty.
97
+ """
98
+ missing_fields = []
99
+
100
+ if default_transport is None or (isinstance(default_transport, str) and len(default_transport.strip()) == 0):
101
+ missing_fields.append("default_transport")
102
+
103
+ if default_serialization_format is None or (isinstance(default_serialization_format, str) and len(default_serialization_format.strip()) == 0):
104
+ missing_fields.append("default_serialization_format")
105
+
106
+ if default_request_timeout is None:
107
+ missing_fields.append("default_request_timeout")
108
+
109
+ if len(missing_fields) > 0:
110
+ errmsg = "MessagingConfiguration is missing required field(s): {}.".format(
111
+ ", ".join(missing_fields)
112
+ )
113
+ raise ConfigurationError(errmsg)
114
+
115
+ return
116
+
117
+ @property
118
+ def default_transport(self) -> str:
119
+ """
120
+ The default transport name string.
121
+
122
+ :returns: The default transport name.
123
+ """
124
+ return self._default_transport
125
+
126
+ @property
127
+ def default_serialization_format(self) -> str:
128
+ """
129
+ The default serialization format name string.
130
+
131
+ :returns: The default serialization format name.
132
+ """
133
+ return self._default_serialization_format
134
+
135
+ @property
136
+ def default_request_timeout(self) -> float:
137
+ """
138
+ The default request/response timeout in seconds.
139
+
140
+ :returns: A float representing the timeout in seconds.
141
+ """
142
+ return self._default_request_timeout
143
+
144
+ @property
145
+ def transport_configurations(self) -> dict:
146
+ """
147
+ The transport configurations dictionary mapping transport
148
+ names to TransportConfiguration dictionaries.
149
+
150
+ :returns: A dictionary of transport configurations.
151
+ """
152
+ return dict(self._transport_configurations)
153
+
154
+ @property
155
+ def pubsub_settings(self) -> dict:
156
+ """
157
+ The pub/sub configuration settings dictionary.
158
+
159
+ :returns: A dictionary of pub/sub settings.
160
+ """
161
+ return dict(self._pubsub_settings)
162
+
163
+ @property
164
+ def credential_references(self) -> dict:
165
+ """
166
+ The named credential references dictionary.
167
+
168
+ :returns: A dictionary of credential reference names
169
+ to their reference data.
170
+ """
171
+ return dict(self._credential_references)
172
+
173
+ @property
174
+ def options(self) -> dict:
175
+ """
176
+ The additional configuration options dictionary.
177
+
178
+ :returns: A dictionary of option key-value pairs.
179
+ """
180
+ return dict(self._options)
181
+
182
+ def as_dict(self) -> dict:
183
+ """
184
+ Returns a dictionary representation of the configuration.
185
+
186
+ Credential reference values are excluded from the output
187
+ to prevent leaking secrets. Only the credential reference
188
+ names are included.
189
+
190
+ :returns: A dictionary containing all configuration fields
191
+ except resolved credential values.
192
+ """
193
+ rtnval = {
194
+ "default_transport": self._default_transport,
195
+ "default_serialization_format": self._default_serialization_format,
196
+ "default_request_timeout": self._default_request_timeout,
197
+ }
198
+
199
+ if len(self._transport_configurations) > 0:
200
+ rtnval["transport_configurations"] = dict(self._transport_configurations)
201
+
202
+ if len(self._pubsub_settings) > 0:
203
+ rtnval["pubsub_settings"] = dict(self._pubsub_settings)
204
+
205
+ if len(self._credential_references) > 0:
206
+ rtnval["credential_references"] = sorted(self._credential_references.keys())
207
+
208
+ if len(self._options) > 0:
209
+ rtnval["options"] = dict(self._options)
210
+
211
+ return rtnval
212
+
213
+ def to_json(self) -> str:
214
+ """
215
+ Returns a JSON string representation of the configuration.
216
+
217
+ Credential reference values are excluded from the output
218
+ to prevent leaking secrets.
219
+
220
+ :returns: A JSON string containing all configuration fields
221
+ except resolved credential values.
222
+ """
223
+ data = self.as_dict()
224
+ rtnval = json.dumps(data)
225
+ return rtnval
226
+
227
+ @classmethod
228
+ def from_dict(cls, config_data: dict,
229
+ app_context=None) -> "MessagingConfiguration":
230
+ """
231
+ Constructs a MessagingConfiguration from a dictionary.
232
+
233
+ :param config_data: A dictionary containing configuration
234
+ fields.
235
+ :param app_context: An optional AppContext for path
236
+ resolution. Currently unused for from_dict but
237
+ accepted for API consistency.
238
+
239
+ :returns: A MessagingConfiguration instance.
240
+
241
+ :raises ConfigurationError: If required fields are missing.
242
+ """
243
+ default_transport = config_data.get("default_transport", None)
244
+ default_serialization_format = config_data.get("default_serialization_format", None)
245
+ default_request_timeout = config_data.get("default_request_timeout", 30.0)
246
+ transport_configurations = config_data.get("transport_configurations", None)
247
+ pubsub_settings = config_data.get("pubsub_settings", None)
248
+ credential_references = config_data.get("credential_references", None)
249
+ if isinstance(credential_references, (list, tuple)):
250
+ reference_names = credential_references
251
+ credential_references = {name: None for name in reference_names}
252
+ options = config_data.get("options", None)
253
+
254
+ rtnval = cls(
255
+ default_transport=default_transport,
256
+ default_serialization_format=default_serialization_format,
257
+ default_request_timeout=default_request_timeout,
258
+ transport_configurations=transport_configurations,
259
+ pubsub_settings=pubsub_settings,
260
+ credential_references=credential_references,
261
+ options=options
262
+ )
263
+ return rtnval
264
+
265
+ @classmethod
266
+ def from_json(cls, json_str: str,
267
+ app_context=None) -> "MessagingConfiguration":
268
+ """
269
+ Deserializes a JSON string into a MessagingConfiguration
270
+ instance.
271
+
272
+ :param json_str: A JSON string containing configuration
273
+ fields.
274
+ :param app_context: An optional AppContext for path
275
+ resolution.
276
+
277
+ :returns: A MessagingConfiguration instance.
278
+
279
+ :raises ConfigurationError: If required fields are missing.
280
+ """
281
+ data = json.loads(json_str)
282
+ rtnval = cls.from_dict(config_data=data, app_context=app_context)
283
+ return rtnval
284
+
285
+ @classmethod
286
+ def from_json_file(cls, file_path: str,
287
+ app_context=None) -> "MessagingConfiguration":
288
+ """
289
+ Loads a MessagingConfiguration from a JSON file.
290
+
291
+ When an app_context is provided, the file path is
292
+ resolved relative to the AppContext directory.
293
+
294
+ :param file_path: The path to the JSON configuration
295
+ file.
296
+ :param app_context: An optional AppContext for path
297
+ resolution.
298
+
299
+ :returns: A MessagingConfiguration instance.
300
+
301
+ :raises ConfigurationError: If required fields are missing.
302
+ """
303
+ resolved_path = file_path
304
+
305
+ if app_context is not None:
306
+ base_dir = app_context.home_directory
307
+ resolved_path = os.path.join(base_dir, file_path)
308
+
309
+ with open(resolved_path, "r") as fh:
310
+ json_str = fh.read()
311
+
312
+ rtnval = cls.from_json(json_str=json_str, app_context=app_context)
313
+ return rtnval
314
+
315
+ @classmethod
316
+ def from_yaml(cls, yaml_str: str,
317
+ app_context=None) -> "MessagingConfiguration":
318
+ """
319
+ Deserializes a YAML string into a MessagingConfiguration
320
+ instance.
321
+
322
+ :param yaml_str: A YAML string containing configuration
323
+ fields.
324
+ :param app_context: An optional AppContext for path
325
+ resolution.
326
+
327
+ :returns: A MessagingConfiguration instance.
328
+
329
+ :raises ConfigurationError: If required fields are missing.
330
+ """
331
+ data = yaml.safe_load(yaml_str)
332
+ rtnval = cls.from_dict(config_data=data, app_context=app_context)
333
+ return rtnval
334
+
335
+ @classmethod
336
+ def from_yaml_file(cls, file_path: str,
337
+ app_context=None) -> "MessagingConfiguration":
338
+ """
339
+ Loads a MessagingConfiguration from a YAML file.
340
+
341
+ When an app_context is provided, the file path is
342
+ resolved relative to the AppContext directory.
343
+
344
+ :param file_path: The path to the YAML configuration
345
+ file.
346
+ :param app_context: An optional AppContext for path
347
+ resolution.
348
+
349
+ :returns: A MessagingConfiguration instance.
350
+
351
+ :raises ConfigurationError: If required fields are missing.
352
+ """
353
+ resolved_path = file_path
354
+
355
+ if app_context is not None:
356
+ base_dir = app_context.home_directory
357
+ resolved_path = os.path.join(base_dir, file_path)
358
+
359
+ with open(resolved_path, "r") as fh:
360
+ yaml_str = fh.read()
361
+
362
+ rtnval = cls.from_yaml(yaml_str=yaml_str, app_context=app_context)
363
+ return rtnval
364
+
365
+ def __repr__(self) -> str:
366
+ """
367
+ Returns a detailed string representation including the
368
+ class name, default transport name, and default
369
+ serialization format.
370
+
371
+ :returns: A repr string for debugging.
372
+ """
373
+ repr_str = "{}(default_transport={!r}, default_serialization_format={!r})".format(
374
+ self.__class__.__name__, self._default_transport,
375
+ self._default_serialization_format
376
+ )
377
+ return repr_str
378
+
379
+ def __str__(self) -> str:
380
+ """
381
+ Returns a human-readable summary including the default
382
+ transport name, default serialization format, and default
383
+ request timeout.
384
+
385
+ :returns: A human-readable string describing the
386
+ configuration.
387
+ """
388
+ str_val = (
389
+ "MessagingConfiguration: default_transport={}, "
390
+ "default_serialization_format={}, "
391
+ "default_request_timeout={}s"
392
+ ).format(
393
+ self._default_transport,
394
+ self._default_serialization_format,
395
+ self._default_request_timeout
396
+ )
397
+ return str_val