'Get a cursor over the index documents for this collection.
>>> for index in db.test.list_indexes():
...     print(index)
SON([(u\'v\', 1), (u\'key\', SON([(u\'_id\', 1)])),
(u\'name\', u\'_id_\'), (u\'ns\', u\'test.test\')])
:Returns:
An instance of :class:`~pymongo.command_cursor.CommandCursor`.
.. versionadded:: 3.0'

def list_indexes(self):

    codec_options = CodecOptions(SON)
    coll = self.with_options(codec_options)
    with self._socket_for_primary_reads() as (sock_info, slave_ok):
        cmd = SON([('listIndexes', self.__name), ('cursor', {})])
        if (sock_info.max_wire_version > 2):
            try:
                cursor = self._command(sock_info, cmd, slave_ok, ReadPreference.PRIMARY, codec_options)['cursor']
            except OperationFailure as exc:
                if (exc.code != 26):
                    raise
                cursor = {'id': 0, 'firstBatch': []}
            return CommandCursor(coll, cursor, sock_info.address)
        else:
            namespace = (_UJOIN % (self.__database.name, 'system.indexes'))
            res = helpers._first_batch(sock_info, self.__database.name, 'system.indexes', {'ns': self.__full_name}, 0, slave_ok, codec_options, ReadPreference.PRIMARY, cmd, self.database.client._event_listeners)
            data = res['data']
            cursor = {'id': res['cursor_id'], 'firstBatch': data, 'ns': namespace}
            return CommandCursor(coll, cursor, sock_info.address, len(data))
