from pyopenproject.api_connection.exceptions.request_exception import RequestError
from pyopenproject.api_connection.requests.get_request import GetRequest
from pyopenproject.business.exception.business_error import BusinessError
from pyopenproject.business.services.command.configuration.configuration_command import ConfigurationCommand
from pyopenproject.model.configuration import Configuration


class Find(ConfigurationCommand):

    def __init__(self, connection):
        """Constructor for class Find, from ConfigurationCommand.

        :param connection: The connection data
        """
        super().__init__(connection)

    def execute(self):
        try:
            json_obj = GetRequest(self.connection, f"{self.CONTEXT}").execute()
            return Configuration(json_obj)
        except RequestError as re:
            raise BusinessError("Error listing configuration") from re

[((771, 794), 'pyopenproject.model.configuration.Configuration', 'Configuration', (['json_obj'], {}), '(json_obj)\n', (784, 794), False, 'from pyopenproject.model.configuration import Configuration\n'), ((848, 892), 'pyopenproject.business.exception.business_error.BusinessError', 'BusinessError', (['"""Error listing configuration"""'], {}), "('Error listing configuration')\n", (861, 892), False, 'from pyopenproject.business.exception.business_error import BusinessError\n'), ((695, 741), 'pyopenproject.api_connection.requests.get_request.GetRequest', 'GetRequest', (['self.connection', 'f"""{self.CONTEXT}"""'], {}), "(self.connection, f'{self.CONTEXT}')\n", (705, 741), False, 'from pyopenproject.api_connection.requests.get_request import GetRequest\n')]