func (p *PDNSProvider) ApplyChanges(changes *plan.Changes) error {

	startTime := time.Now()

	// Create
	for _, change := range changes.Create {
		log.Debugf("CREATE: %+v", change)
	}
	// We only attempt to mutate records if there are any to mutate.  A
	// call to mutate records with an empty list of endpoints is still a
	// valid call and a no-op, but we might as well not make the call to
	// prevent unnecessary logging
	if len(changes.Create) > 0 {
		// "Replacing" non-existant records creates them
		err := p.mutateRecords(changes.Create, PdnsReplace)
		if err != nil {
			return err
		}
	}

	// Update
	for _, change := range changes.UpdateOld {
		// Since PDNS "Patches", we don't need to specify the "old"
		// record. The Update New change type will automatically take
		// care of replacing the old RRSet with the new one We simply
		// leave this logging here for information
		log.Debugf("UPDATE-OLD (ignored): %+v", change)
	}

	for _, change := range changes.UpdateNew {
		log.Debugf("UPDATE-NEW: %+v", change)
	}
	if len(changes.UpdateNew) > 0 {
		err := p.mutateRecords(changes.UpdateNew, PdnsReplace)
		if err != nil {
			return err
		}
	}

	// Delete
	for _, change := range changes.Delete {
		log.Debugf("DELETE: %+v", change)
	}
	if len(changes.Delete) > 0 {
		err := p.mutateRecords(changes.Delete, PdnsDelete)
		if err != nil {
			return err
		}
	}

	log.Debugf("Changes pushed out to PowerDNS in %s\n", time.Since(startTime))
	return nil
}
func (p *PDNSProvider) ApplyChanges(changes *plan.Changes) error {

	startTime := time.Now()

	
	for _, change := range changes.Create {
		log.Debugf("CREATE: %+v", change)
	}
	
	
	
	
	if len(changes.Create) > 0 {
		
		err := p.mutateRecords(changes.Create, PdnsReplace)
		if err != nil {
			return err
		}
	}

	
	for _, change := range changes.UpdateOld {
		
		
		
		
		log.Debugf("UPDATE-OLD (ignored): %+v", change)
	}

	for _, change := range changes.UpdateNew {
		log.Debugf("UPDATE-NEW: %+v", change)
	}
	if len(changes.UpdateNew) > 0 {
		err := p.mutateRecords(changes.UpdateNew, PdnsReplace)
		if err != nil {
			return err
		}
	}

	
	for _, change := range changes.Delete {
		log.Debugf("DELETE: %+v", change)
	}
	if len(changes.Delete) > 0 {
		err := p.mutateRecords(changes.Delete, PdnsDelete)
		if err != nil {
			return err
		}
	}

	log.Debugf("Changes pushed out to PowerDNS in %s\n", time.Since(startTime))
	return nil
}
func ( p * PDNSProvider ) ApplyChanges ( changes * plan . Changes ) error { startTime := time . Now ( ) // Create for _ , change := range changes . Create { log . Debugf ( " " , change ) } // We only attempt to mutate records if there are any to mutate.  A // call to mutate records with an empty list of endpoints is still a // valid call and a no-op, but we might as well not make the call to // prevent unnecessary logging if len ( changes . Create ) > 0 { // "Replacing" non-existant records creates them err := p . mutateRecords ( changes . Create , PdnsReplace ) if err != nil { return err } } // Update for _ , change := range changes . UpdateOld { // Since PDNS "Patches", we don't need to specify the "old" // record. The Update New change type will automatically take // care of replacing the old RRSet with the new one We simply // leave this logging here for information log . Debugf ( " " , change ) } for _ , change := range changes . UpdateNew { log . Debugf ( " " , change ) } if len ( changes . UpdateNew ) > 0 { err := p . mutateRecords ( changes . UpdateNew , PdnsReplace ) if err != nil { return err } } // Delete for _ , change := range changes . Delete { log . Debugf ( " " , change ) } if len ( changes . Delete ) > 0 { err := p . mutateRecords ( changes . Delete , PdnsDelete ) if err != nil { return err } } log . Debugf ( " \n " , time . Since ( startTime ) ) return nil }
// ApplyChanges takes a list of changes (endpoints) and updates the PDNS server
// by sending the correct HTTP PATCH requests to a matching zone
ApplyChanges takes a list of changes ( endpoints ) and updates the PDNS server by sending the correct HTTP PATCH requests to a matching zone