def collection(name, options=None, **kwargs):
    '''
    Create collection and enforce options.

    Use the solrcloud module to get collection parameters.

    You can pass additional arguments that will be forwarded to http.query

    name
        The collection name
    options : {}
        options to ensure
    '''
    ret = {
        'name': name,
        'changes': {},
        'result': False,
        'comment': '',
    }

    if options is None:
        options = {}

    if __salt__["solrcloud.collection_exists"](name, **kwargs):

        diff = {}

        current_options = __salt__["solrcloud.collection_get_options"](name, **kwargs)

        # Filter options that can be updated
        updatable_options = [
            "maxShardsPerNode",
            "replicationFactor",
            "autoAddReplicas",
            "collection.configName",
            "rule",
            "snitch"]

        options = [k for k in six.iteritems(options) if k in updatable_options]

        for key, value in options:
            if key not in current_options or current_options[key] != value:
                diff[key] = value

        if not diff:
            ret['result'] = True
            ret['comment'] = 'Collection options are in desired state'
            return ret

        else:

            if __opts__['test']:
                ret['comment'] = 'Collection options "{0}" will be changed.'.format(name)
                ret['result'] = None
            else:
                __salt__['solrcloud.collection_set_options'](name, diff, **kwargs)
                ret['comment'] = 'Parameters were updated for collection "{0}".'.format(name)
                ret['result'] = True

            ret['changes'] = {
                'old': salt.utils.json.dumps(current_options, sort_keys=True, indent=4, separators=(',', ': ')),
                'new': salt.utils.json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))
            }
            return ret

    else:

        new_changes = salt.utils.json.dumps(options, sort_keys=True, indent=4, separators=(',', ': '))
        if __opts__['test']:
            ret['comment'] = 'The collection "{0}" will be created.'.format(name)
            ret['result'] = None
        else:
            __salt__["solrcloud.collection_create"](name, options, **kwargs)
            ret['comment'] = 'The collection "{0}" has been created.'.format(name)
            ret['result'] = True

        ret['changes'] = {
            'old': None,
            'new': str('options=') + new_changes  # future lint: disable=blacklisted-function
        }

    return ret
Create collection and enforce options.

    Use the solrcloud module to get collection parameters.

    You can pass additional arguments that will be forwarded to http.query

    name
        The collection name
    options : {}
        options to ensure