Source code for worldline.connect.sdk.client
#
# This class was auto-generated from the API references found at
# https://apireference.connect.worldline-solutions.com/
#
from base64 import b64encode
from datetime import timedelta
from typing import Optional
from .api_resource import ApiResource
from .communicator import Communicator
from worldline.connect.sdk.log.body_obfuscator import BodyObfuscator
from worldline.connect.sdk.log.communicator_logger import CommunicatorLogger
from worldline.connect.sdk.log.header_obfuscator import HeaderObfuscator
from worldline.connect.sdk.log.logging_capable import LoggingCapable
from worldline.connect.sdk.log.obfuscation_capable import ObfuscationCapable
from worldline.connect.sdk.v1.v1_client import V1Client
[docs]
class Client(ApiResource, LoggingCapable, ObfuscationCapable):
"""
Worldline Global Collect platform client.
This client and all its child clients are bound to one specific value for the X-GCS-ClientMetaInfo header.
To get a new client with a different header value, use with_client_meta_info.
Thread-safe.
"""
[docs]
def __init__(self, communicator: Communicator, client_meta_info: Optional[str] = None):
"""
:param communicator: :class:`worldline.connect.sdk.communicator.Communicator`
:param client_meta_info: str
"""
super(Client, self).__init__(communicator=communicator,
client_meta_info=client_meta_info)
[docs]
def close_idle_connections(self, idle_time: timedelta) -> None:
"""
Utility method that delegates the call to this client's communicator.
:param idle_time: a datetime.timedelta object indicating the idle time
"""
self._communicator.close_idle_connections(idle_time)
[docs]
def close_expired_connections(self) -> None:
"""
Utility method that delegates the call to this client's communicator.
"""
self._communicator.close_expired_connections()
[docs]
def set_body_obfuscator(self, body_obfuscator: BodyObfuscator) -> None:
# delegate to the communicator
self._communicator.set_body_obfuscator(body_obfuscator)
[docs]
def enable_logging(self, communicator_logger: CommunicatorLogger) -> None:
# delegate to the communicator
self._communicator.enable_logging(communicator_logger)
[docs]
def disable_logging(self) -> None:
# delegate to the communicator
self._communicator.disable_logging()
[docs]
def close(self) -> None:
"""
Releases any system resources associated with this object.
"""
self._communicator.close()
[docs]
def __enter__(self):
return self
[docs]
def __exit__(self, exc_type, exc_val, exc_tb):
self.close()
[docs]
def v1(self) -> V1Client:
return V1Client(self, None)