def _write_status_response(self, status_code: int, response: Dict[str, Any]) -> None:
        """Write an HTTP response with Patroni/Postgres status in JSON format.

        Modifies *response* before sending it to the client. Defines the ``patroni`` key, which is a
        dictionary that contains the mandatory keys:

            * ``version``: Patroni version, e.g. ``3.0.2``;
            * ``scope``: value of ``scope`` setting from Patroni configuration.

        May also add the following optional keys, depending on the status of this Patroni/PostgreSQL node:

            * ``tags``: tags that were set through Patroni configuration merged with dynamically applied tags;
            * ``database_system_identifier``: ``Database system identifier`` from ``pg_controldata`` output;
            * ``pending_restart``: ``True`` if PostgreSQL is pending to be restarted;
            * ``pending_restart_reason``: dictionary where each key is the parameter that caused "pending restart" flag
                to be set and the value is a dictionary with the old and the new value.
            * ``scheduled_restart``: a dictionary with a single key ``schedule``, which is the timestamp for the
                scheduled restart;
            * ``watchdog_failed``: ``True`` if watchdog device is unhealthy;
            * ``logger_queue_size``: log queue length if it is longer than expected;
            * ``logger_records_lost``: number of log records that have been lost while the log queue was full.

        :param status_code: response HTTP status code.
        :param response: represents the status of the PostgreSQL node, and is used as a basis for the HTTP response.
            This dictionary is built through :func:`get_postgresql_status`.
        """
        patroni = self.server.patroni
        tags = patroni.ha.get_effective_tags()
        if tags:
            response['tags'] = tags
        if patroni.postgresql.sysid:
            response['database_system_identifier'] = patroni.postgresql.sysid
        if patroni.postgresql.pending_restart_reason:
            response['pending_restart'] = True
            response['pending_restart_reason'] = dict(patroni.postgresql.pending_restart_reason)
        response['patroni'] = {
            'version': patroni.version,
            'scope': patroni.postgresql.scope,
            'name': patroni.postgresql.name
        }
        if patroni.scheduled_restart:
            response['scheduled_restart'] = patroni.scheduled_restart.copy()
            del response['scheduled_restart']['postmaster_start_time']
            response['scheduled_restart']['schedule'] = (response['scheduled_restart']['schedule']).isoformat()
        if not patroni.ha.watchdog.is_healthy:
            response['watchdog_failed'] = True
        qsize = patroni.logger.queue_size
        if qsize > patroni.logger.NORMAL_LOG_QUEUE_SIZE:
            response['logger_queue_size'] = qsize
            lost = patroni.logger.records_lost
            if lost:
                response['logger_records_lost'] = lost
        self._write_json_response(status_code, response)
Write an HTTP response with Patroni/Postgres status in JSON format.

        Modifies *response* before sending it to the client. Defines the ``patroni`` key, which is a
        dictionary that contains the mandatory keys:

            * ``version``: Patroni version, e.g. ``3.0.2``;
            * ``scope``: value of ``scope`` setting from Patroni configuration.

        May also add the following optional keys, depending on the status of this Patroni/PostgreSQL node:

            * ``tags``: tags that were set through Patroni configuration merged with dynamically applied tags;
            * ``database_system_identifier``: ``Database system identifier`` from ``pg_controldata`` output;
            * ``pending_restart``: ``True`` if PostgreSQL is pending to be restarted;
            * ``pending_restart_reason``: dictionary where each key is the parameter that caused "pending restart" flag
                to be set and the value is a dictionary with the old and the new value.
            * ``scheduled_restart``: a dictionary with a single key ``schedule``, which is the timestamp for the
                scheduled restart;
            * ``watchdog_failed``: ``True`` if watchdog device is unhealthy;
            * ``logger_queue_size``: log queue length if it is longer than expected;
            * ``logger_records_lost``: number of log records that have been lost while the log queue was full.

        :param status_code: response HTTP status code.
        :param response: represents the status of the PostgreSQL node, and is used as a basis for the HTTP response.
            This dictionary is built through :func:`get_postgresql_status`.
        
patroni/api.py