def post()

in src/handlers/send_report_setting_handler.py [0:0]


    def post(self, event: ReportsSendingSettingPostModel):

        setting = self.settings_service.get_send_reports()
        if setting == event.enable:
            return build_response(
                code=HTTPStatus.OK,
                content=f'The SEND_REPORTS setting is already '
                        f'{"enabled" if event.enable else "disabled"}'
            )
        if event.enable:
            health_check_result = []
            instance = RabbitMQConnectionCheck.build()
            for customer in self.customer_service.i_get_customer():
                try:
                    result = instance.check(customer=customer.name)
                except Exception as e:
                    _LOG.exception(
                        f'An unknown exception occurred trying to execute '
                        f'check `{instance.identifier()}` for customer '
                        f'{customer.name}')
                    result = instance.unknown_result(details={'error': str(e)})
                _LOG.info(f'Check: {instance.identifier()} for customer '
                          f'{customer.name} has finished')
                health_check_result.append(result.is_ok())
            if not any(health_check_result):
                # for what?
                _LOG.warning(
                    'Could not enable reports sending system because ALL '
                    'customers have non-working RabbitMQ configuration.')
                return build_response(
                    code=HTTPStatus.OK,
                    content='Could not enable reports sending system.'
                )
            self.settings_service.enable_send_reports()
            self.step_function_client.invoke(
                RETRY_REPORT_STATE_MACHINE,
                event=self.build_retry_event()
            )
        else:
            self.settings_service.disable_send_reports()

        return build_response(
            code=HTTPStatus.OK,
            content=f'Value of SEND_REPORTS setting was changed to {event.enable}'
        )