# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# def string_keys_to_dict(key_string, callback):
#     return dict.fromkeys(key_string.split(), callback)
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)
# 
# def pairs_to_dict(response):
#     """Creates a dict given a list of key/value pairs"""
#     it = iter(response)
#     return dict(zip(it, it))
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'


import datetime
from aredis.exceptions import RedisError
from aredis.utils import (b, bool_ok,
                          nativestr, dict_merge,
                          string_keys_to_dict,
                          list_keys_to_dict,
                          pairs_to_dict,
                          NodeFlag)
        The command also returns additional information about the state of the replication
        (if the role is master or slave)
        or the list of monitored master names (if the role is sentinel).
        :return:
        """
        return await self.execute_command('ROLE')


class ClusterServerCommandMixin(ServerCommandMixin):
    NODES_FLAGS = dict_merge(
        list_keys_to_dict(
            ['SHUTDOWN', 'SLAVEOF', 'CLIENT SETNAME'],
            NodeFlag.BLOCKED
        ),
        list_keys_to_dict(
            ['FLUSHALL', 'FLUSHDB'],
            NodeFlag.ALL_MASTERS
        ),
        list_keys_to_dict(
            ['SLOWLOG LEN', 'SLOWLOG RESET', 'SLOWLOG GET',
             'TIME', 'SAVE', 'LASTSAVE', 'DBSIZE',
             'CONFIG RESETSTAT', 'CONFIG REWRITE',
             'CONFIG GET', 'CONFIG SET', 'CLIENT KILL',
             'CLIENT LIST', 'CLIENT GETNAME', 'INFO',
             'BGSAVE', 'BGREWRITEAOF'],
            NodeFlag.ALL_NODES
        )
    )

    RESULT_CALLBACKS = dict_merge(

# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# Path: aredis/utils.py
# def b(x):
#     return x.encode('latin-1') if not isinstance(x, bytes) else x
# 
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# def string_keys_to_dict(key_string, callback):
#     return dict.fromkeys(key_string.split(), callback)
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)
# 
# def pairs_to_dict(response):
#     """Creates a dict given a list of key/value pairs"""
#     it = iter(response)
#     return dict(zip(it, it))
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'


# Path: aredis/commands/server.py
import datetime
from aredis.exceptions import RedisError
from aredis.utils import (b, bool_ok,
                          nativestr, dict_merge,
                          string_keys_to_dict,
                          list_keys_to_dict,
                          pairs_to_dict,
                          NodeFlag)

        The command also returns additional information about the state of the replication
        (if the role is master or slave)
        or the list of monitored master names (if the role is sentinel).
        :return:
        """
        return await self.execute_command('ROLE')


class ClusterServerCommandMixin(ServerCommandMixin):
    NODES_FLAGS = dict_merge(
        list_keys_to_dict(
            ['SHUTDOWN', 'SLAVEOF', 'CLIENT SETNAME'],
            NodeFlag.BLOCKED
        ),
        list_keys_to_dict(
            ['FLUSHALL', 'FLUSHDB'],
            NodeFlag.ALL_MASTERS
        ),
        list_keys_to_dict(
            ['SLOWLOG LEN', 'SLOWLOG RESET', 'SLOWLOG GET',
             'TIME', 'SAVE', 'LASTSAVE', 'DBSIZE',
             'CONFIG RESETSTAT', 'CONFIG REWRITE',
             'CONFIG GET', 'CONFIG SET', 'CLIENT KILL',
             'CLIENT LIST', 'CLIENT GETNAME', 'INFO',
             'BGSAVE', 'BGREWRITEAOF'],
            NodeFlag.ALL_NODES
        )
    )

    RESULT_CALLBACKS = dict_merge(

        list_keys_to_dict(