mms-client 1.4.1__py3-none-any.whl → 1.5.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.
- mms_client/client.py +5 -0
- mms_client/services/base.py +20 -33
- mms_client/services/market.py +4 -0
- mms_client/services/omi.py +5 -0
- mms_client/services/registration.py +4 -0
- mms_client/services/report.py +5 -0
- mms_client/utils/auditing.py +4 -0
- mms_client/utils/errors.py +4 -0
- mms_client/utils/serialization.py +4 -0
- mms_client/utils/web.py +9 -9
- {mms_client-1.4.1.dist-info → mms_client-1.5.0.dist-info}/METADATA +1 -10
- {mms_client-1.4.1.dist-info → mms_client-1.5.0.dist-info}/RECORD +14 -14
- {mms_client-1.4.1.dist-info → mms_client-1.5.0.dist-info}/LICENSE +0 -0
- {mms_client-1.4.1.dist-info → mms_client-1.5.0.dist-info}/WHEEL +0 -0
mms_client/client.py
CHANGED
|
@@ -1,11 +1,16 @@
|
|
|
1
1
|
"""Contains the client layer for communicating with the MMS server."""
|
|
2
2
|
|
|
3
|
+
from logging import getLogger
|
|
4
|
+
|
|
3
5
|
from mms_client.services.base import BaseClient
|
|
4
6
|
from mms_client.services.market import MarketClientMixin
|
|
5
7
|
from mms_client.services.omi import OMIClientMixin
|
|
6
8
|
from mms_client.services.registration import RegistrationClientMixin
|
|
7
9
|
from mms_client.services.report import ReportClientMixin
|
|
8
10
|
|
|
11
|
+
# Set the default logger for the MMS client
|
|
12
|
+
logger = getLogger(__name__)
|
|
13
|
+
|
|
9
14
|
|
|
10
15
|
class MmsClient(BaseClient, MarketClientMixin, RegistrationClientMixin, ReportClientMixin, OMIClientMixin):
|
|
11
16
|
"""User client for the MMS server.
|
mms_client/services/base.py
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
"""Contains the client layer for communicating with the MMS server."""
|
|
2
2
|
|
|
3
3
|
from dataclasses import dataclass
|
|
4
|
-
from logging import Logger
|
|
5
4
|
from logging import getLogger
|
|
6
5
|
from typing import Dict
|
|
7
6
|
from typing import Generic
|
|
@@ -37,7 +36,7 @@ from mms_client.utils.web import Plugin
|
|
|
37
36
|
from mms_client.utils.web import ZWrapper
|
|
38
37
|
|
|
39
38
|
# Set the default logger for the MMS client
|
|
40
|
-
|
|
39
|
+
logger = getLogger(__name__)
|
|
41
40
|
|
|
42
41
|
|
|
43
42
|
@dataclass
|
|
@@ -85,10 +84,6 @@ class ClientProto(Protocol):
|
|
|
85
84
|
def user(self) -> str:
|
|
86
85
|
"""Return the user name of the person making the request."""
|
|
87
86
|
|
|
88
|
-
@property
|
|
89
|
-
def logger(self) -> Logger:
|
|
90
|
-
"""Return the logger for the client."""
|
|
91
|
-
|
|
92
87
|
def verify_audience(self, config: EndpointConfiguration) -> None:
|
|
93
88
|
"""Verify that the client type is allowed.
|
|
94
89
|
|
|
@@ -166,6 +161,7 @@ def mms_endpoint(
|
|
|
166
161
|
# Next, create a decorator that will add the endpoint configuration to the function
|
|
167
162
|
def decorator(func):
|
|
168
163
|
def wrapper(self: ClientProto, *args, **kwargs) -> Optional[P]:
|
|
164
|
+
logger.info(f"{config.name}: Called with args: {args[1:]}...")
|
|
169
165
|
|
|
170
166
|
# First, verify that the client type is allowed
|
|
171
167
|
self.verify_audience(config)
|
|
@@ -177,6 +173,7 @@ def mms_endpoint(
|
|
|
177
173
|
resp, _ = self.request_one(envelope, args[0], config)
|
|
178
174
|
|
|
179
175
|
# Finally, extract the data from the response and return it
|
|
176
|
+
logger.info(f"{config.name}: Returning {type(resp.data).__name__} data.")
|
|
180
177
|
return resp.data
|
|
181
178
|
|
|
182
179
|
return wrapper
|
|
@@ -221,7 +218,7 @@ def mms_multi_endpoint(
|
|
|
221
218
|
# Next, create a decorator that will add the endpoint configuration to the function
|
|
222
219
|
def decorator(func):
|
|
223
220
|
def wrapper(self: ClientProto, *args, **kwargs) -> List[P]:
|
|
224
|
-
|
|
221
|
+
logger.info(f"{config.name}: Called with args: {args[1:]}...")
|
|
225
222
|
|
|
226
223
|
# First, verify that the client type is allowed
|
|
227
224
|
self.verify_audience(config)
|
|
@@ -233,7 +230,7 @@ def mms_multi_endpoint(
|
|
|
233
230
|
resp, _ = self.request_many(envelope, args[0], config)
|
|
234
231
|
|
|
235
232
|
# Finally, extract the data from the response and return it
|
|
236
|
-
|
|
233
|
+
logger.info(f"{config.name}: Returning {len(resp.data)} item(s).")
|
|
237
234
|
return resp.data
|
|
238
235
|
|
|
239
236
|
return wrapper
|
|
@@ -254,7 +251,6 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
254
251
|
user: str,
|
|
255
252
|
client_type: ClientType,
|
|
256
253
|
cert: Certificate,
|
|
257
|
-
logger: Optional[Logger] = None,
|
|
258
254
|
plugins: Optional[List[Plugin]] = None,
|
|
259
255
|
is_admin: bool = False,
|
|
260
256
|
test: bool = False,
|
|
@@ -266,8 +262,6 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
266
262
|
user (str): The user name of the person making the request.
|
|
267
263
|
client_type (ClientType): The type of client to use for making requests to the MMS server.
|
|
268
264
|
cert (Certificate): The certificate to use for signing requests.
|
|
269
|
-
logger (Logger): The logger to use for instrumentation. If this is not provided, then the default
|
|
270
|
-
logger will be used.
|
|
271
265
|
plugins (List[Plugin]): A list of plugins to add to the Zeep client. This can be useful for auditing or
|
|
272
266
|
other purposes.
|
|
273
267
|
is_admin (bool): Whether the user is an admin (i.e. is a market operator).
|
|
@@ -284,8 +278,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
284
278
|
self._cert = cert
|
|
285
279
|
self._signer = CryptoWrapper(cert)
|
|
286
280
|
|
|
287
|
-
# Now, set
|
|
288
|
-
self._logger = logger or default_logger
|
|
281
|
+
# Now, set the plugins we'll inject into the Zeep client
|
|
289
282
|
self._plugins = plugins or []
|
|
290
283
|
|
|
291
284
|
# Finally, create a list of wrappers for the different interfaces
|
|
@@ -301,11 +294,6 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
301
294
|
"""Return the user name of the person making the request."""
|
|
302
295
|
return self._user
|
|
303
296
|
|
|
304
|
-
@property
|
|
305
|
-
def logger(self) -> Logger:
|
|
306
|
-
"""Return the logger for the client."""
|
|
307
|
-
return self._logger
|
|
308
|
-
|
|
309
297
|
def verify_audience(self, config: EndpointConfiguration) -> None:
|
|
310
298
|
"""Verify that the client type is allowed.
|
|
311
299
|
|
|
@@ -318,7 +306,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
318
306
|
Raises:
|
|
319
307
|
ValueError: If the client type is not allowed.
|
|
320
308
|
"""
|
|
321
|
-
|
|
309
|
+
logger.debug(
|
|
322
310
|
f"{config.name}: Verifying audience. Allowed clients: "
|
|
323
311
|
f"{config.allowed_clients if config.allowed_clients else 'Any'}."
|
|
324
312
|
)
|
|
@@ -341,7 +329,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
341
329
|
Returns: The response from the MMS server.
|
|
342
330
|
"""
|
|
343
331
|
# First, create the MMS request from the payload and data.
|
|
344
|
-
|
|
332
|
+
logger.debug(
|
|
345
333
|
f"{config.name}: Starting request. Envelope: {type(envelope).__name__}, Data: {type(payload).__name__}",
|
|
346
334
|
)
|
|
347
335
|
request = self._to_mms_request(config.request_type, config.service.serializer.serialize(envelope, payload))
|
|
@@ -360,7 +348,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
360
348
|
self._verify_response(data, config)
|
|
361
349
|
|
|
362
350
|
# Return the response data and any attachments
|
|
363
|
-
|
|
351
|
+
logger.debug(
|
|
364
352
|
f"{config.name}: Returning response. Envelope: {envelope_type.__name__}, Data: {data_type.__name__}",
|
|
365
353
|
)
|
|
366
354
|
return data, attachments
|
|
@@ -383,7 +371,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
383
371
|
# First, create the MMS request from the payload and data.
|
|
384
372
|
is_list = isinstance(payload, list)
|
|
385
373
|
data_type = type(payload[0]) if is_list else type(payload) # type: ignore[index]
|
|
386
|
-
|
|
374
|
+
logger.debug(
|
|
387
375
|
(
|
|
388
376
|
f"{config.name}: Starting multi-request. Envelope: {type(envelope).__name__}, "
|
|
389
377
|
f"Data: {data_type.__name__}"
|
|
@@ -414,7 +402,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
414
402
|
self._verify_multi_response(data, config)
|
|
415
403
|
|
|
416
404
|
# Return the response data and any attachments
|
|
417
|
-
|
|
405
|
+
logger.debug(
|
|
418
406
|
f"{config.name}: Returning multi-response. Envelope: {envelope_type.__name__}, Data: {data_type.__name__}",
|
|
419
407
|
)
|
|
420
408
|
return data, attachments
|
|
@@ -447,7 +435,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
447
435
|
)
|
|
448
436
|
|
|
449
437
|
# Embed the data and the attachments in the MMS request and return it
|
|
450
|
-
|
|
438
|
+
logger.debug(
|
|
451
439
|
f"Creating MMS request of type {req_type.name} to send {len(data)} bytes of data and "
|
|
452
440
|
f"{len(attachment_data)} attachments."
|
|
453
441
|
)
|
|
@@ -481,9 +469,9 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
481
469
|
|
|
482
470
|
# Check the response status flags and log any warnings or errors
|
|
483
471
|
if resp.warnings:
|
|
484
|
-
|
|
472
|
+
logger.warning(f"{config.name}: MMS response contained warnings.")
|
|
485
473
|
if not resp.success:
|
|
486
|
-
|
|
474
|
+
logger.error(f"{config.name}: MMS response was unsuccessful.")
|
|
487
475
|
|
|
488
476
|
def _verify_response(self, resp: Response[E, P], config: EndpointConfiguration) -> None:
|
|
489
477
|
"""Verify that the given response is valid.
|
|
@@ -544,7 +532,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
544
532
|
Returns: True to indicate that the response is valid, False otherwise.
|
|
545
533
|
"""
|
|
546
534
|
# Log the request's processing statistics
|
|
547
|
-
|
|
535
|
+
logger.info(
|
|
548
536
|
f"{config.name} ({resp.statistics.timestamp_xml}): Recieved {resp.statistics.received}, "
|
|
549
537
|
f"Valid: {resp.statistics.valid}, Invalid: {resp.statistics.invalid}, "
|
|
550
538
|
f"Successful: {resp.statistics.successful}, Unsuccessful: {resp.statistics.unsuccessful} "
|
|
@@ -566,11 +554,11 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
566
554
|
"""
|
|
567
555
|
for path, messages in resp.messages.items():
|
|
568
556
|
for info in messages.information:
|
|
569
|
-
|
|
557
|
+
logger.info(f"{config.name} - {path}: {info.code}")
|
|
570
558
|
for warning in messages.warnings:
|
|
571
|
-
|
|
559
|
+
logger.warning(f"{config.name} - {path}: {warning.code}")
|
|
572
560
|
for error in messages.errors:
|
|
573
|
-
|
|
561
|
+
logger.error(f"{config.name} - {path}: {error.code}")
|
|
574
562
|
|
|
575
563
|
def _verify_response_common(
|
|
576
564
|
self, config: EndpointConfiguration, payload_type: type, resp: ResponseCommon, index: Optional[int] = None
|
|
@@ -587,7 +575,7 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
587
575
|
Returns: True to indicate that the response is valid, False otherwise.
|
|
588
576
|
"""
|
|
589
577
|
# Log the status of the response validation
|
|
590
|
-
|
|
578
|
+
logger.info(
|
|
591
579
|
f"{config.name}: {payload_type.__name__}{f'[{index}]' if index is not None else ''} was valid? "
|
|
592
580
|
f"{resp.success} ({resp.validation.value})",
|
|
593
581
|
)
|
|
@@ -602,12 +590,11 @@ class BaseClient: # pylint: disable=too-many-instance-attributes
|
|
|
602
590
|
service (ServiceConfiguration): The service for which to get the wrapper.
|
|
603
591
|
"""
|
|
604
592
|
if service.interface not in self._wrappers:
|
|
605
|
-
|
|
593
|
+
logger.debug(f"Creating wrapper for {service.interface.name} interface.")
|
|
606
594
|
self._wrappers[service.interface] = ZWrapper(
|
|
607
595
|
self._client_type,
|
|
608
596
|
service.interface,
|
|
609
597
|
self._cert.to_adapter(),
|
|
610
|
-
self._logger,
|
|
611
598
|
self._plugins,
|
|
612
599
|
True,
|
|
613
600
|
self._test,
|
mms_client/services/market.py
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Contains the client layer for making market requests to the MMS server."""
|
|
2
2
|
|
|
3
3
|
from datetime import date as Date
|
|
4
|
+
from logging import getLogger
|
|
4
5
|
from typing import List
|
|
5
6
|
from typing import Optional
|
|
6
7
|
|
|
@@ -23,6 +24,9 @@ from mms_client.utils.serialization import Serializer
|
|
|
23
24
|
from mms_client.utils.web import ClientType
|
|
24
25
|
from mms_client.utils.web import Interface
|
|
25
26
|
|
|
27
|
+
# Set the default logger for the MMS client
|
|
28
|
+
logger = getLogger(__name__)
|
|
29
|
+
|
|
26
30
|
|
|
27
31
|
class MarketClientMixin: # pylint: disable=unused-argument
|
|
28
32
|
"""Market client for the MMS server."""
|
mms_client/services/omi.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"""Contains the client layer for making OMI requests to the MMS server."""
|
|
2
2
|
|
|
3
|
+
from logging import getLogger
|
|
4
|
+
|
|
3
5
|
from mms_client.services.base import ServiceConfiguration
|
|
4
6
|
from mms_client.utils.serialization import SchemaType
|
|
5
7
|
from mms_client.utils.serialization import Serializer
|
|
6
8
|
from mms_client.utils.web import Interface
|
|
7
9
|
|
|
10
|
+
# Set the default logger for the MMS client
|
|
11
|
+
logger = getLogger(__name__)
|
|
12
|
+
|
|
8
13
|
|
|
9
14
|
class OMIClientMixin: # pylint: disable=unused-argument
|
|
10
15
|
"""OMI client for the MMS server."""
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"""Contains the client layer for making registration requests to the MMS server."""
|
|
2
2
|
|
|
3
3
|
from datetime import date as Date
|
|
4
|
+
from logging import getLogger
|
|
4
5
|
from typing import List
|
|
5
6
|
from typing import Optional
|
|
6
7
|
|
|
@@ -20,6 +21,9 @@ from mms_client.utils.serialization import Serializer
|
|
|
20
21
|
from mms_client.utils.web import ClientType
|
|
21
22
|
from mms_client.utils.web import Interface
|
|
22
23
|
|
|
24
|
+
# Set the default logger for the MMS client
|
|
25
|
+
logger = getLogger(__name__)
|
|
26
|
+
|
|
23
27
|
|
|
24
28
|
class RegistrationClientMixin: # pylint: disable=unused-argument
|
|
25
29
|
"""Registration client for the MMS server."""
|
mms_client/services/report.py
CHANGED
|
@@ -1,10 +1,15 @@
|
|
|
1
1
|
"""Contains the client layer for making report requests to the MMS server."""
|
|
2
2
|
|
|
3
|
+
from logging import getLogger
|
|
4
|
+
|
|
3
5
|
from mms_client.services.base import ServiceConfiguration
|
|
4
6
|
from mms_client.utils.serialization import SchemaType
|
|
5
7
|
from mms_client.utils.serialization import Serializer
|
|
6
8
|
from mms_client.utils.web import Interface
|
|
7
9
|
|
|
10
|
+
# Set the default logger for the MMS client
|
|
11
|
+
logger = getLogger(__name__)
|
|
12
|
+
|
|
8
13
|
|
|
9
14
|
class ReportClientMixin: # pylint: disable=unused-argument
|
|
10
15
|
"""Report client for the MMS server."""
|
mms_client/utils/auditing.py
CHANGED
|
@@ -2,11 +2,15 @@
|
|
|
2
2
|
|
|
3
3
|
from abc import ABC
|
|
4
4
|
from abc import abstractmethod
|
|
5
|
+
from logging import getLogger
|
|
5
6
|
|
|
6
7
|
from lxml.etree import _Element as Element
|
|
7
8
|
from lxml.etree import tostring
|
|
8
9
|
from zeep import Plugin
|
|
9
10
|
|
|
11
|
+
# Set the default logger for the MMS client
|
|
12
|
+
logger = getLogger(__name__)
|
|
13
|
+
|
|
10
14
|
|
|
11
15
|
class AuditPlugin(ABC, Plugin):
|
|
12
16
|
"""Base class for audit plugins."""
|
mms_client/utils/errors.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"""Contains error classes for the MMS client."""
|
|
2
2
|
|
|
3
|
+
from logging import getLogger
|
|
3
4
|
from typing import Dict
|
|
4
5
|
from typing import List
|
|
5
6
|
from typing import Optional
|
|
@@ -10,6 +11,9 @@ from mms_client.types.base import Messages
|
|
|
10
11
|
from mms_client.types.base import P
|
|
11
12
|
from mms_client.utils.web import ClientType
|
|
12
13
|
|
|
14
|
+
# Set the default logger for the MMS client
|
|
15
|
+
logger = getLogger(__name__)
|
|
16
|
+
|
|
13
17
|
|
|
14
18
|
class AudienceError(ValueError):
|
|
15
19
|
"""Error raised when an invalid audience is provided."""
|
|
@@ -2,6 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
from functools import lru_cache
|
|
4
4
|
from io import BytesIO
|
|
5
|
+
from logging import getLogger
|
|
5
6
|
from pathlib import Path
|
|
6
7
|
from typing import Dict
|
|
7
8
|
from typing import List
|
|
@@ -32,6 +33,9 @@ from mms_client.types.base import SchemaType
|
|
|
32
33
|
# Directory containing all our XML schemas
|
|
33
34
|
XSD_DIR = Path(__file__).parent.parent / "schemas" / "xsd"
|
|
34
35
|
|
|
36
|
+
# Set the default logger for the MMS client
|
|
37
|
+
logger = getLogger(__name__)
|
|
38
|
+
|
|
35
39
|
|
|
36
40
|
class Serializer:
|
|
37
41
|
"""Contains methods for serializing and deserializing MMS data."""
|
mms_client/utils/web.py
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"""Contains the HTTP/web layer for communicating with the MMS server."""
|
|
2
2
|
|
|
3
3
|
from enum import StrEnum
|
|
4
|
-
from logging import
|
|
4
|
+
from logging import getLogger
|
|
5
5
|
from pathlib import Path
|
|
6
6
|
from typing import List
|
|
7
7
|
from typing import Optional
|
|
@@ -20,6 +20,9 @@ from zeep.xsd.valueobjects import CompoundValue
|
|
|
20
20
|
from mms_client.types.transport import MmsRequest
|
|
21
21
|
from mms_client.types.transport import MmsResponse
|
|
22
22
|
|
|
23
|
+
# Set the default logger for the MMS client
|
|
24
|
+
logger = getLogger(__name__)
|
|
25
|
+
|
|
23
26
|
|
|
24
27
|
class ClientType(StrEnum):
|
|
25
28
|
"""Identifies the type of client to use.
|
|
@@ -134,7 +137,6 @@ class ZWrapper:
|
|
|
134
137
|
client: ClientType,
|
|
135
138
|
interface: Interface,
|
|
136
139
|
adapter: Pkcs12Adapter,
|
|
137
|
-
logger: Logger,
|
|
138
140
|
plugins: Optional[List[Plugin]] = None,
|
|
139
141
|
cache: bool = True,
|
|
140
142
|
test: bool = False,
|
|
@@ -150,7 +152,6 @@ class ZWrapper:
|
|
|
150
152
|
as the service and port to use.
|
|
151
153
|
adapter (Pkcs12Adapter): The PKCS12 adapter containing the certificate and private key to use for
|
|
152
154
|
authenticating with the MMS server.
|
|
153
|
-
logger (Logger): The logger to use for instrumentation.
|
|
154
155
|
plugins (List[Plugin]): A list of Zeep plugins to use with the client. This is useful for adding additional
|
|
155
156
|
functionality to the client, such as auditing or logging.
|
|
156
157
|
cache (bool): If True, use a cache for the Zeep client. This is useful for avoiding repeated
|
|
@@ -190,7 +191,6 @@ class ZWrapper:
|
|
|
190
191
|
|
|
191
192
|
# Finally, we create the Zeep client with the given WSDL file location, session, and cache settings and then,
|
|
192
193
|
# from that client, we create the SOAP service with the given service binding and selected endpoint.
|
|
193
|
-
self._logger = logger
|
|
194
194
|
self._client = Client(
|
|
195
195
|
wsdl=str(location.resolve()),
|
|
196
196
|
transport=Transport(cache=SqliteCache() if cache else None, session=sess),
|
|
@@ -198,11 +198,11 @@ class ZWrapper:
|
|
|
198
198
|
)
|
|
199
199
|
self._create_service()
|
|
200
200
|
|
|
201
|
-
@on_exception(expo, TransportError, max_tries=3, giveup=fatal_code) # type: ignore[arg-type]
|
|
201
|
+
@on_exception(expo, TransportError, max_tries=3, giveup=fatal_code, logger=logger) # type: ignore[arg-type]
|
|
202
202
|
def submit(self, req: MmsRequest) -> MmsResponse:
|
|
203
203
|
"""Submit the given request to the MMS server and return the response."""
|
|
204
204
|
try:
|
|
205
|
-
|
|
205
|
+
logger.debug(f"Submitting MMS request request to {self._interface.name} service")
|
|
206
206
|
|
|
207
207
|
# Submit the request to the MMS server and retrieve the response
|
|
208
208
|
resp: CompoundValue = self._service["submitAttachment"](**req.to_arguments())
|
|
@@ -212,12 +212,12 @@ class ZWrapper:
|
|
|
212
212
|
except TransportError as e:
|
|
213
213
|
# If we got a server fault error, then we'll switch to the backup endpoint. In any case, we'll raise the
|
|
214
214
|
# exception so that our back-off can handle it or pass the exception up the stack.
|
|
215
|
-
|
|
215
|
+
logger.error(
|
|
216
216
|
f"MMS request to {self._interface.name} service failed with status code: {e.status_code}",
|
|
217
217
|
exc_info=e,
|
|
218
218
|
)
|
|
219
219
|
if e.status_code >= 500:
|
|
220
|
-
|
|
220
|
+
logger.warning(f"MMS server error, switching to backup endpoint: {self._endpoint.backup}")
|
|
221
221
|
self._endpoint.select(error=True)
|
|
222
222
|
self._create_service()
|
|
223
223
|
raise
|
|
@@ -227,5 +227,5 @@ class ZWrapper:
|
|
|
227
227
|
|
|
228
228
|
This is useful for switching between the main and backup endpoints in case of an error.
|
|
229
229
|
"""
|
|
230
|
-
|
|
230
|
+
logger.debug(f"Creating new {self._interface.name} service with endpoint: {self._endpoint.selected}")
|
|
231
231
|
self._service = self._client.create_service(SERVICE_BINDINGS[self._interface], self._endpoint.selected)
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: mms-client
|
|
3
|
-
Version: 1.
|
|
3
|
+
Version: 1.5.0
|
|
4
4
|
Summary: API client for accessing the MMS
|
|
5
5
|
Home-page: https://github.com/ElectroRoute-Japan/mms-client
|
|
6
6
|
Author: Ryan Wood
|
|
@@ -186,15 +186,6 @@ If you're connecting as a market operator (MO), you can connect in admin mode:
|
|
|
186
186
|
client = MmsClient(participant="F100", user="FAKEUSER", client_type=ClientType.BSP, cert, is_admin=True)
|
|
187
187
|
```
|
|
188
188
|
|
|
189
|
-
## Log Settings
|
|
190
|
-
The client also supports injection of a custom logger. The default logger is named "MMS Client".
|
|
191
|
-
|
|
192
|
-
```python
|
|
193
|
-
client = MmsClient(participant="F100", user="FAKEUSER", client_type=ClientType.BSP, cert, logger=my_logger)
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
The client currently logs a number of informational, debug and error messages. You can freely change the logging level yourself.
|
|
197
|
-
|
|
198
189
|
## Auditing XML Requests & Responses
|
|
199
190
|
A common requirement for this sort of library is recording or saving the raw XML requests and responses for audit/logging purposes. This library supports this workflow through the `mms_client.utils.auditing.AuditPlugin` object. This object intercepts the XML request at the Zeep client level right before it is sent to the MMS and, similarly, intercepts the XML response immediately after it is received from the MMS. Before passing these objects on, without modifying them, it records the XML data as a byte string and passes it to two methods: `audit_request` and `audit_response`. These can be overridden by any object that inherits from this class, allowing the user to direct this data to whatever store they prefer to use for auditing or logging.
|
|
200
191
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
mms_client/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
mms_client/client.py,sha256=
|
|
2
|
+
mms_client/client.py,sha256=qkLdhC8jXEvtXWKb-GsWJOCYoEjTtHp9x8q8eofkh78,676
|
|
3
3
|
mms_client/py.typed,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
4
4
|
mms_client/schemas/wsdl/mi-web-service-jbms.wsdl,sha256=4qSn52d-DF6COeI-53P85sSODQy-C4_yp30yYCjeI84,10702
|
|
5
5
|
mms_client/schemas/wsdl/omi-web-service.wsdl,sha256=pIEKcUWzyChzPJnQ6IpnZYyJJ0_0j3yt8M-1l_su5Q8,9894
|
|
@@ -12,11 +12,11 @@ mms_client/security/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSu
|
|
|
12
12
|
mms_client/security/certs.py,sha256=kNCUFmy18YIxkWKu3mdMmlxmHdft4a6BvtyJ46rA9I4,1489
|
|
13
13
|
mms_client/security/crypto.py,sha256=M7aIllM3_ZwZgm9nH6QQ6Ig14XCAd6e6WGwqqUbbI1Q,2149
|
|
14
14
|
mms_client/services/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
15
|
-
mms_client/services/base.py,sha256=
|
|
16
|
-
mms_client/services/market.py,sha256=
|
|
17
|
-
mms_client/services/omi.py,sha256=
|
|
18
|
-
mms_client/services/registration.py,sha256=
|
|
19
|
-
mms_client/services/report.py,sha256=
|
|
15
|
+
mms_client/services/base.py,sha256=kI--NGcxYP9-cF5PHolSGOT-XtBFcjmlsRLxpd48GVE,25897
|
|
16
|
+
mms_client/services/market.py,sha256=XCD49lILwf7_hpF54MpQFsO-NBK4PwmNznsoMyg23mo,7684
|
|
17
|
+
mms_client/services/omi.py,sha256=UG1zYkFz0sFsEbhE6P0CLoAOZZOyEshkZ_b7D_e3CjQ,626
|
|
18
|
+
mms_client/services/registration.py,sha256=ryj2WKJoBzRU1r6Svbl2MyGOG0H5aEYAK6HQWL9kYaA,3815
|
|
19
|
+
mms_client/services/report.py,sha256=ZXYDaknPCnSYZI857QHbkzst1Pez_PrKFudVF9bQB7Q,642
|
|
20
20
|
mms_client/types/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
21
21
|
mms_client/types/award.py,sha256=BWE9V_KHXpg_cW1LZsetVrPs2hZDOklvRpNnoZtmR3k,14139
|
|
22
22
|
mms_client/types/base.py,sha256=VQCr50CL1SnnPcO1EYGHa4rrkHBtXs-J8psWLJWoHJY,9710
|
|
@@ -28,11 +28,11 @@ mms_client/types/registration.py,sha256=Nir73S3ffpk0O_fnTD2alFaqV1k67_8dcyyduXvP
|
|
|
28
28
|
mms_client/types/resource.py,sha256=TQnY3JLHRgQhQrG6ISquw-BQgKSr8TGuqn9ItWxWz_w,65974
|
|
29
29
|
mms_client/types/transport.py,sha256=DPjWs34UW915GkUCJWKuDZmsjS6mRdRXgcGISduN_Bc,4399
|
|
30
30
|
mms_client/utils/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
31
|
-
mms_client/utils/auditing.py,sha256=
|
|
32
|
-
mms_client/utils/errors.py,sha256=
|
|
33
|
-
mms_client/utils/serialization.py,sha256=
|
|
34
|
-
mms_client/utils/web.py,sha256=
|
|
35
|
-
mms_client-1.
|
|
36
|
-
mms_client-1.
|
|
37
|
-
mms_client-1.
|
|
38
|
-
mms_client-1.
|
|
31
|
+
mms_client/utils/auditing.py,sha256=yb_8cdUeZkTCb2W48E0LLuJXv4m4SKjDH8jMX7rjNLk,1797
|
|
32
|
+
mms_client/utils/errors.py,sha256=ovoJjrvoVkbMRhHcq3HR9p1uH_65QicvaGy_7wNv7JI,2579
|
|
33
|
+
mms_client/utils/serialization.py,sha256=k0_fBm-yoRZV2AMiickSyauoDyA8i7uIPU6JjfQWx4Q,29638
|
|
34
|
+
mms_client/utils/web.py,sha256=kguQ4uDFpfw2dly89WXukkvJ8RMKTDIafWGUIpmPPJo,10033
|
|
35
|
+
mms_client-1.5.0.dist-info/LICENSE,sha256=awOCsWJ58m_2kBQwBUGWejVqZm6wuRtCL2hi9rfa0X4,1211
|
|
36
|
+
mms_client-1.5.0.dist-info/METADATA,sha256=RrGO-fZkJP0aHFEYOdT74lvi3Syzp1x9OeyhqdSsabA,15987
|
|
37
|
+
mms_client-1.5.0.dist-info/WHEEL,sha256=Zb28QaM1gQi8f4VCBhsUklF61CTlNYfs9YAZn-TOGFk,88
|
|
38
|
+
mms_client-1.5.0.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|