This package implements the libdns interfaces for the IONOS DNS API
To authenticate you need to supply a IONOS API Key, as described on https://developer.hosting.ionos.de/docs/getstarted
Here's a minimal example of how to get all DNS records for zone.
package main
import (
"context""fmt""os""github.com/libdns/ionos"
)
funcmain() {
token:=os.Getenv("LIBDNS_IONOS_TOKEN")
iftoken=="" {
panic("LIBDNS_IONOS_TOKEN not set")
}
zone:=os.Getenv("LIBDNS_IONOS_ZONE")
ifzone=="" {
panic("LIBDNS_IONOS_ZONE not set")
}
p:=&ionos.Provider{
AuthAPIToken: token,
}
zones, err:=p.ListZones(context.TODO())
iferr!=nil {
panic(err)
}
fmt.Print("Zones:\n")
for_, z:=rangezones {
fmt.Printf("%+v\n", z)
}
fmt.Printf("\nRecord in Zone %s\n", zone)
records, err:=p.GetRecords(context.TODO(), zone)
iferr!=nil {
panic(err)
}
for_, r:=rangerecords {
fmt.Printf("%+v\n", r.RR())
}
}The file provisioner_test.go contains an end-to-end test suite, using the
original IONOS API service (i.e. no test doubles - be careful). To run the
tests:
$ export LIBDNS_IONOS_TEST_ZONE=mydomain.org
$ export LIBDNS_IONOS_TEST_TOKEN=aaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
$ go test -vgo test -v=== RUN Test_AppendRecords=== RUN Test_AppendRecords/testcase_0=== RUN Test_AppendRecords/testcase_1=== RUN Test_AppendRecords/testcase_2--- PASS: Test_AppendRecords (6.71s) --- PASS: Test_AppendRecords/testcase_0 (2.51s) --- PASS: Test_AppendRecords/testcase_1 (2.15s) --- PASS: Test_AppendRecords/testcase_2 (2.05s)=== RUN Test_DeleteRecords=== RUN Test_DeleteRecords/clear_record.ID=true=== RUN Test_DeleteRecords/clear_record.ID=false--- PASS: Test_DeleteRecords (9.62s) --- PASS: Test_DeleteRecords/clear_record.ID=true (4.81s) --- PASS: Test_DeleteRecords/clear_record.ID=false (4.80s)=== RUN Test_GetRecords--- PASS: Test_GetRecords (4.41s)=== RUN Test_UpdateRecords=== RUN Test_UpdateRecords/clear_record.ID=true=== RUN Test_UpdateRecords/clear_record.ID=false--- PASS: Test_UpdateRecords (10.14s) --- PASS: Test_UpdateRecords/clear_record.ID=true (5.84s) --- PASS: Test_UpdateRecords/clear_record.ID=false (4.30s)PASSok github.com/libdns/ionos 30.884sOriginal Work (C) Copyright 2020 by matthiasng (based on https://github.com/libdns/hetzner), this version (C) Copyright 2021 by Jan Delgado (github.com/jandelgado).
License: MIT