def _ensure_api_ok(self) -> None:
        """Ensure ``pg-backup-api`` is reachable and ``OK``.

        :raises:
            :exc:`ApiNotOk`: if ``pg-backup-api`` status is not ``OK``.
        """
        response = self._get_request("status")

        if response != "OK":
            msg = (
                "pg-backup-api is currently not up and running at "
                f"{self.api_url}: {response}"
            )

            raise ApiNotOk(msg)
Ensure ``pg-backup-api`` is reachable and ``OK``.

        :raises:
            :exc:`ApiNotOk`: if ``pg-backup-api`` status is not ``OK``.
        
patroni/scripts/barman/utils.py