.. versionadded:: Fluorine

    Creates or updates a record set within a DNS zone.

    :param name: The name of the record set, relative to the name of the zone.

    :param zone_name: The name of the DNS zone (without a terminating dot).

    :param resource_group: The name of the resource group.

    :param record_type: The type of DNS record in this record set. Record sets of type SOA can be
    updated but not created (they are created when the DNS zone is created).
    Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT'

    CLI Example:

    .. code-block:: bash

        salt-call azurearm_dns.record_set_create_or_update myhost myzone testgroup A
            arecords='[{ipv4_address: 10.0.0.1}]' ttl=300

def record_set_create_or_update(name, zone_name, resource_group, record_type, **kwargs):
    '''
    .. versionadded:: Fluorine

    Creates or updates a record set within a DNS zone.

    :param name: The name of the record set, relative to the name of the zone.

    :param zone_name: The name of the DNS zone (without a terminating dot).

    :param resource_group: The name of the resource group.

    :param record_type: The type of DNS record in this record set. Record sets of type SOA can be
    updated but not created (they are created when the DNS zone is created).
    Possible values include: 'A', 'AAAA', 'CAA', 'CNAME', 'MX', 'NS', 'PTR', 'SOA', 'SRV', 'TXT'

    CLI Example:

    .. code-block:: bash

        salt-call azurearm_dns.record_set_create_or_update myhost myzone testgroup A
            arecords='[{ipv4_address: 10.0.0.1}]' ttl=300

    '''
    dnsconn = __utils__['azurearm.get_client']('dns', **kwargs)

    try:
        record_set_model = __utils__['azurearm.create_object_model']('dns', 'RecordSet', **kwargs)
    except TypeError as exc:
        result = {'error': 'The object model could not be built. ({0})'.format(str(exc))}
        return result

    try:
        record_set = dnsconn.record_sets.create_or_update(
            relative_record_set_name=name,
            zone_name=zone_name,
            resource_group_name=resource_group,
            record_type=record_type,
            parameters=record_set_model,
            if_match=kwargs.get('if_match'),
            if_none_match=kwargs.get('if_none_match')
        )
        result = record_set.as_dict()
    except CloudError as exc:
        __utils__['azurearm.log_cloud_error']('dns', str(exc), **kwargs)
        result = {'error': str(exc)}
    except SerializationError as exc:
        result = {'error': 'The object model could not be parsed. ({0})'.format(str(exc))}

    return result