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

[((20, 19, 20, 42), 'pyopenproject.model.configuration.Configuration', 'Configuration', ({(20, 33, 20, 41): 'json_obj'}, {}), '(json_obj)', False, 'from pyopenproject.model.configuration import Configuration\n'), ((22, 18, 22, 62), 'pyopenproject.business.exception.business_error.BusinessError', 'BusinessError', ({(22, 32, 22, 61): '"""Error listing configuration"""'}, {}), "('Error listing configuration')", False, 'from pyopenproject.business.exception.business_error import BusinessError\n'), ((19, 23, 19, 69), 'pyopenproject.api_connection.requests.get_request.GetRequest', 'GetRequest', ({(19, 34, 19, 49): 'self.connection', (19, 51, 19, 68): 'f"""{self.CONTEXT}"""'}, {}), "(self.connection, f'{self.CONTEXT}')", False, 'from pyopenproject.api_connection.requests.get_request import GetRequest\n')]