provider/ns1.go
func (p *NS1Provider) ns1SubmitChanges(changes []*ns1Change) error {
	// return early if there is nothing to change
	if len(changes) == 0 {
		return nil
	}

	zones, err := p.zonesFiltered()
	if err != nil {
		return err
	}

	// separate into per-zone change sets to be passed to the API.
	changesByZone := ns1ChangesByZone(zones, changes)
	for zoneName, changes := range changesByZone {
		for _, change := range changes {
			record := ns1BuildRecord(zoneName, change)
			logFields := log.Fields{
				"record": record.Domain,
				"type":   record.Type,
				"ttl":    record.TTL,
				"action": change.Action,
				"zone":   zoneName,
			}

			log.WithFields(logFields).Info("Changing record.")

			if p.dryRun {
				continue
			}

			switch change.Action {
			case ns1Create:
				_, err := p.client.CreateRecord(record)
				if err != nil {
					return err
				}
			case ns1Delete:
				_, err := p.client.DeleteRecord(zoneName, record.Domain, record.Type)
				if err != nil {
					return err
				}
			case ns1Update:
				_, err := p.client.UpdateRecord(record)
				if err != nil {
					return err
				}
			}
		}
	}
	return nil
}
func (p *NS1Provider) ns1SubmitChanges(changes []*ns1Change) error {
	// return early if there is nothing to change
	if len(changes) == 0 {
		return nil
	}

	zones, err := p.zonesFiltered()
	if err != nil {
		return err
	}

	// separate into per-zone change sets to be passed to the API.
	changesByZone := ns1ChangesByZone(zones, changes)
	for zoneName, changes := range changesByZone {
		for _, change := range changes {
			record := ns1BuildRecord(zoneName, change)
			logFields := log.Fields{
				"record": record.Domain,
				"type":   record.Type,
				"ttl":    record.TTL,
				"action": change.Action,
				"zone":   zoneName,
			}

			log.WithFields(logFields).Info("Changing record.")

			if p.dryRun {
				continue
			}

			switch change.Action {
			case ns1Create:
				_, err := p.client.CreateRecord(record)
				if err != nil {
					return err
				}
			case ns1Delete:
				_, err := p.client.DeleteRecord(zoneName, record.Domain, record.Type)
				if err != nil {
					return err
				}
			case ns1Update:
				_, err := p.client.UpdateRecord(record)
				if err != nil {
					return err
				}
			}
		}
	}
	return nil
}
func ( p * NS1Provider ) ns1SubmitChanges ( changes [ ] * ns1Change ) error { // return early if there is nothing to change if len ( changes ) == 0 { return nil } zones , err := p . zonesFiltered ( ) if err != nil { return err } // separate into per-zone change sets to be passed to the API. changesByZone := ns1ChangesByZone ( zones , changes ) for zoneName , changes := range changesByZone { for _ , change := range changes { record := ns1BuildRecord ( zoneName , change ) logFields := log . Fields { " " : record . Domain , " " : record . Type , " " : record . TTL , " " : change . Action , " " : zoneName , } log . WithFields ( logFields ) . Info ( " " ) if p . dryRun { continue } switch change . Action { case ns1Create : _ , err := p . client . CreateRecord ( record ) if err != nil { return err } case ns1Delete : _ , err := p . client . DeleteRecord ( zoneName , record . Domain , record . Type ) if err != nil { return err } case ns1Update : _ , err := p . client . UpdateRecord ( record ) if err != nil { return err } } } } return nil }
// ns1SubmitChanges takes an array of changes and sends them to NS1
ns1SubmitChanges takes an array of changes and sends them to NS1