"""Lambda Invocation Response.""" from hooks.lambda_invoke.function_response import LambdaFunctionResponse class LambdaInvocationResponse: """Handles the parsing of a lambda invocation response.""" def __init__(self, response): """Parse response.""" self.status_code = response.get('StatusCode') self.error_message = response.get('errorMessage') self.function_response = LambdaFunctionResponse(response) if not self.function_response.succeeded: self.error_message = 'function error' def dump(self): """Return the response as a dict for testing and debugging.""" return { 'status_code': self.status_code, 'error_message': self.error_message, 'function_response': self.function_response.dump() }