diff --git a/src/tgclients/config.py b/src/tgclients/config.py index a3d32fc9253d32c45f7c2ad6f1395c9e146cf2bf..d28a03b8d2723b390ae3413356049cdd4b479240 100644 --- a/src/tgclients/config.py +++ b/src/tgclients/config.py @@ -4,6 +4,7 @@ """Variable config options with defaults to be used with the TextGrid clients library.""" +import json import logging from typing import Optional @@ -163,3 +164,26 @@ class TextgridConfig: value (float): the timeout """ self._http_timeout = value + + def _to_dict(self): + return { + 'host': self.host, + 'auth_wsdl': self.auth_wsdl, + 'auth_address': self.auth_address, + 'extra_crud_wsdl': self.extra_crud_wsdl, + 'extra_crud_address': self.extra_crud_address, + 'search': self.search, + 'search_public': self.search_public, + 'crud': self.crud, + 'crud_public': self.crud_public, + 'aggregator': self.aggregator, + 'publish': self.publish, + 'http_timeout': self.http_timeout, + } + + def _to_json(self): + return json.dumps(self._to_dict()) + + def __str__(self): + """Return a string representation of the TextgridConfig object.""" + return self._to_json()