https://github.com/libdns/ionos
IONOS DNS libdns implementation
https://github.com/libdns/ionos
ionos libdns
Last synced: 4 months ago
JSON representation
IONOS DNS libdns implementation
- Host: GitHub
- URL: https://github.com/libdns/ionos
- Owner: libdns
- License: mit
- Created: 2021-08-02T20:18:54.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2025-05-04T19:39:51.000Z (about 1 year ago)
- Last Synced: 2025-05-04T20:18:59.467Z (about 1 year ago)
- Topics: ionos, libdns
- Language: Go
- Homepage:
- Size: 40 KB
- Stars: 7
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# IONOS DNS API for `libdns`
This package implements the libdns interfaces for the [IONOS DNS
API](https://developer.hosting.ionos.de/docs/dns)
## Authenticating
To authenticate you need to supply a IONOS API Key, as described on
https://developer.hosting.ionos.de/docs/getstarted
## Example
Here's a minimal example of how to get all DNS records for zone.
```go
package main
import (
"context"
"fmt"
"os"
"github.com/libdns/ionos"
)
func main() {
token := os.Getenv("LIBDNS_IONOS_TOKEN")
if token == "" {
panic("LIBDNS_IONOS_TOKEN not set")
}
zone := os.Getenv("LIBDNS_IONOS_ZONE")
if zone == "" {
panic("LIBDNS_IONOS_ZONE not set")
}
p := &ionos.Provider{
AuthAPIToken: token,
}
zones, err := p.ListZones(context.TODO())
if err != nil {
panic(err)
}
fmt.Print("Zones:\n")
for _, z := range zones {
fmt.Printf("%+v\n", z)
}
fmt.Printf("\nRecord in Zone %s\n", zone)
records, err := p.GetRecords(context.TODO(), zone)
if err != nil {
panic(err)
}
for _, r := range records {
fmt.Printf("%+v\n", r.RR())
}
}
```
## Test
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:
```console
$ export LIBDNS_IONOS_TEST_ZONE=mydomain.org
$ export LIBDNS_IONOS_TEST_TOKEN=aaaaaaaaaaa.bbbbbbbbbbbbbbbbbbbbbbbbbbbbbb
$ go test -v
go 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)
PASS
ok github.com/libdns/ionos 30.884s
```
## Author
Original 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