route53/xml_generators/change_resource_record_set.py
def write_change(change):
    """
    Creates an XML element for the change.

    :param tuple change: A change tuple from a ChangeSet. Comes in the form
        of ``(action, rrset)``.
    :rtype: lxml.etree._Element
    :returns: A fully baked Change tag.
    """

    action, rrset = change

    change_vals = get_change_values(change)

    e_change = etree.Element("Change")

    e_action = etree.SubElement(e_change, "Action")
    e_action.text = action

    e_rrset = etree.SubElement(e_change, "ResourceRecordSet")

    e_name = etree.SubElement(e_rrset, "Name")
    e_name.text = change_vals['name']

    e_type = etree.SubElement(e_rrset, "Type")
    e_type.text = rrset.rrset_type

    if change_vals.get('set_identifier'):
        e_set_id = etree.SubElement(e_rrset, "SetIdentifier")
        e_set_id.text = change_vals['set_identifier']

    if change_vals.get('weight'):
        e_weight = etree.SubElement(e_rrset, "Weight")
        e_weight.text = change_vals['weight']

    if change_vals.get('alias_hosted_zone_id') or change_vals.get('alias_dns_name'):
        e_alias_target = etree.SubElement(e_rrset, "AliasTarget")

        e_hosted_zone_id = etree.SubElement(e_alias_target, "HostedZoneId")
        e_hosted_zone_id.text = change_vals['alias_hosted_zone_id']
        e_dns_name = etree.SubElement(e_alias_target, "DNSName")
        e_dns_name.text = change_vals['alias_dns_name']

    if change_vals.get('region'):
        e_weight = etree.SubElement(e_rrset, "Region")
        e_weight.text = change_vals['region']

    e_ttl = etree.SubElement(e_rrset, "TTL")
    e_ttl.text = str(change_vals['ttl'])

    if rrset.is_alias_record_set():
        # A record sets in Alias mode don't have any resource records.
        return e_change

    e_resource_records = etree.SubElement(e_rrset, "ResourceRecords")

    for value in change_vals['records']:
        e_resource_record = etree.SubElement(e_resource_records, "ResourceRecord")
        e_value = etree.SubElement(e_resource_record, "Value")
        e_value.text = value

    return e_change
def write_change(change):
    action, rrset = change

    change_vals = get_change_values(change)

    e_change = etree.Element("Change")

    e_action = etree.SubElement(e_change, "Action")
    e_action.text = action

    e_rrset = etree.SubElement(e_change, "ResourceRecordSet")

    e_name = etree.SubElement(e_rrset, "Name")
    e_name.text = change_vals['name']

    e_type = etree.SubElement(e_rrset, "Type")
    e_type.text = rrset.rrset_type

    if change_vals.get('set_identifier'):
        e_set_id = etree.SubElement(e_rrset, "SetIdentifier")
        e_set_id.text = change_vals['set_identifier']

    if change_vals.get('weight'):
        e_weight = etree.SubElement(e_rrset, "Weight")
        e_weight.text = change_vals['weight']

    if change_vals.get('alias_hosted_zone_id') or change_vals.get('alias_dns_name'):
        e_alias_target = etree.SubElement(e_rrset, "AliasTarget")

        e_hosted_zone_id = etree.SubElement(e_alias_target, "HostedZoneId")
        e_hosted_zone_id.text = change_vals['alias_hosted_zone_id']
        e_dns_name = etree.SubElement(e_alias_target, "DNSName")
        e_dns_name.text = change_vals['alias_dns_name']

    if change_vals.get('region'):
        e_weight = etree.SubElement(e_rrset, "Region")
        e_weight.text = change_vals['region']

    e_ttl = etree.SubElement(e_rrset, "TTL")
    e_ttl.text = str(change_vals['ttl'])

    if rrset.is_alias_record_set():
        # A record sets in Alias mode don't have any resource records.
        return e_change

    e_resource_records = etree.SubElement(e_rrset, "ResourceRecords")

    for value in change_vals['records']:
        e_resource_record = etree.SubElement(e_resource_records, "ResourceRecord")
        e_value = etree.SubElement(e_resource_record, "Value")
        e_value.text = value

    return e_change
def write_change ( change ) : action , rrset = change change_vals = get_change_values ( change ) e_change = etree . Element ( "Change" ) e_action = etree . SubElement ( e_change , "Action" ) e_action . text = action e_rrset = etree . SubElement ( e_change , "ResourceRecordSet" ) e_name = etree . SubElement ( e_rrset , "Name" ) e_name . text = change_vals [ 'name' ] e_type = etree . SubElement ( e_rrset , "Type" ) e_type . text = rrset . rrset_type if change_vals . get ( 'set_identifier' ) : e_set_id = etree . SubElement ( e_rrset , "SetIdentifier" ) e_set_id . text = change_vals [ 'set_identifier' ] if change_vals . get ( 'weight' ) : e_weight = etree . SubElement ( e_rrset , "Weight" ) e_weight . text = change_vals [ 'weight' ] if change_vals . get ( 'alias_hosted_zone_id' ) or change_vals . get ( 'alias_dns_name' ) : e_alias_target = etree . SubElement ( e_rrset , "AliasTarget" ) e_hosted_zone_id = etree . SubElement ( e_alias_target , "HostedZoneId" ) e_hosted_zone_id . text = change_vals [ 'alias_hosted_zone_id' ] e_dns_name = etree . SubElement ( e_alias_target , "DNSName" ) e_dns_name . text = change_vals [ 'alias_dns_name' ] if change_vals . get ( 'region' ) : e_weight = etree . SubElement ( e_rrset , "Region" ) e_weight . text = change_vals [ 'region' ] e_ttl = etree . SubElement ( e_rrset , "TTL" ) e_ttl . text = str ( change_vals [ 'ttl' ] ) if rrset . is_alias_record_set ( ) : # A record sets in Alias mode don't have any resource records. return e_change e_resource_records = etree . SubElement ( e_rrset , "ResourceRecords" ) for value in change_vals [ 'records' ] : e_resource_record = etree . SubElement ( e_resource_records , "ResourceRecord" ) e_value = etree . SubElement ( e_resource_record , "Value" ) e_value . text = value return e_change
Creates an XML element for the change.

    :param tuple change: A change tuple from a ChangeSet. Comes in the form
        of ``(action, rrset)``.
    :rtype: lxml.etree._Element
    :returns: A fully baked Change tag.
Creates an XML element for the change .