'Returns a CQL query that can be used to recreate this index.'

def as_cql_query(self):

    options = dict(self.index_options)
    index_target = options.pop('target')
    if (self.kind != 'CUSTOM'):
        return ('CREATE    INDEX    %s    ON    %s.%s    (%s)' % (protect_name(self.name), protect_name(self.keyspace_name), protect_name(self.table_name), index_target))
    else:
        class_name = options.pop('class_name')
        ret = ("CREATE    CUSTOM    INDEX    %s    ON    %s.%s    (%s)    USING    '%s'" % (protect_name(self.name), protect_name(self.keyspace_name), protect_name(self.table_name), index_target, class_name))
        if options:
            ret += ('    WITH    OPTIONS    =    %s' % Encoder().cql_encode_all_types(options))
        return ret
