# Path: aredis/utils.py
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ClusterError(RedisError):
#     pass


from aredis.utils import (bool_ok,
                          nativestr,
                          NodeFlag,
                          list_keys_to_dict,
                          dict_merge)
from aredis.exceptions import (RedisError,
                               ClusterError)
        return res

    async def cluster_save_config(self):
        """
        Forces the node to save cluster state on disk

        Sends to all nodes in the cluster
        """
        return await self.execute_command('CLUSTER SAVECONFIG')

    async def cluster_set_config_epoch(self, node_id, epoch):
        """
        Set the configuration epoch in a new node

        Sends to specefied node
        """
        return await self.execute_command('CLUSTER SET-CONFIG-EPOCH', epoch, node_id=node_id)


    async def cluster_setslot(self, node_id, slot_id, state):
        """
        Bind an hash slot to a specific node

        Sends to specified node
        """
        if state.upper() in {'IMPORTING', 'MIGRATING', 'NODE'} and node_id is not None:
            return await self.execute_command('CLUSTER SETSLOT', slot_id, state, node_id)
        elif state.upper() == 'STABLE':
            return await self.execute_command('CLUSTER SETSLOT', slot_id, 'STABLE')
        else:

# Path: aredis/utils.py
# def bool_ok(response):
#     return nativestr(response) == 'OK'
# 
# def nativestr(x):
#     return x if isinstance(x, str) else x.decode('utf-8', 'replace')
# 
# class NodeFlag:
#     BLOCKED = 'blocked'
#     ALL_NODES = 'all-nodes'
#     ALL_MASTERS = 'all-masters'
#     RANDOM = 'random'
#     SLOT_ID = 'slot-id'
# 
# def list_keys_to_dict(key_list, callback):
#     return dict.fromkeys(key_list, callback)
# 
# def dict_merge(*dicts):
#     merged = {}
#     for d in dicts:
#         merged.update(d)
#     return merged
# 
# Path: aredis/exceptions.py
# class RedisError(Exception):
#     pass
# 
# class ClusterError(RedisError):
#     pass


# Path: aredis/commands/cluster.py
from aredis.utils import (bool_ok,
                          nativestr,
                          NodeFlag,
                          list_keys_to_dict,
                          dict_merge)
from aredis.exceptions import (RedisError,
                               ClusterError)

        return res

    async def cluster_save_config(self):
        """
        Forces the node to save cluster state on disk

        Sends to all nodes in the cluster
        """
        return await self.execute_command('CLUSTER SAVECONFIG')

    async def cluster_set_config_epoch(self, node_id, epoch):
        """
        Set the configuration epoch in a new node

        Sends to specefied node
        """
        return await self.execute_command('CLUSTER SET-CONFIG-EPOCH', epoch, node_id=node_id)


    async def cluster_setslot(self, node_id, slot_id, state):
        """
        Bind an hash slot to a specific node

        Sends to specified node
        """
        if state.upper() in {'IMPORTING', 'MIGRATING', 'NODE'} and node_id is not None:
            return await self.execute_command('CLUSTER SETSLOT', slot_id, state, node_id)
        elif state.upper() == 'STABLE':
            return await self.execute_command('CLUSTER SETSLOT', slot_id, 'STABLE')
        else:

            raise RedisError('Invalid slot state: {0}'.format(state))