https://github.com/libdns/transip
TransIP provider implementation for libdns
https://github.com/libdns/transip
Last synced: 4 months ago
JSON representation
TransIP provider implementation for libdns
- Host: GitHub
- URL: https://github.com/libdns/transip
- Owner: libdns
- License: mit
- Created: 2020-05-22T19:56:17.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2025-11-08T23:52:52.000Z (7 months ago)
- Last Synced: 2025-11-09T01:08:09.306Z (7 months ago)
- Language: Go
- Size: 37.1 KB
- Stars: 3
- Watchers: 2
- Forks: 10
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# TransIP for `libdns`
This package implements the libdns interfaces for the [TransIP API](https://api.transip.nl/rest/docs.html)
## Authenticating
To authenticate, you need to generate a key pair key [here](https://www.transip.nl/cp/account/api).
## Example
Here's a minimal example of how to get all your DNS records using this `libdns` provider
```go
package main
import (
"context"
"fmt"
"os"
"text/tabwriter"
"github.com/pbergman/provider"
"github.com/libdns/transip"
)
func main() {
var x = &transip.Provider{
AuthLogin: "user",
PrivateKey: "private.key",
}
zones, err := x.ListZones(context.Background())
if err != nil {
panic(err)
}
var writer = tabwriter.NewWriter(os.Stdout, 0, 0, 1, ' ', tabwriter.Debug)
for _, zone := range zones {
records, err := x.GetRecords(context.Background(), zone.Name)
if err != nil {
panic(err)
}
for _, record := range provider.RecordIterator(&records) {
_, _ = fmt.Fprintf(writer, "%s\t%v\t%s\t%s\n", record.Name, record.TTL.Seconds(), record.Type, record.Data)
}
}
_ = writer.Flush()
}
```
## Debugging
This library provides the ability to debug the request/response communication with the API server.
To enable debugging, simply set the `debugging` property to `true`:
```go
var x = &transip.Provider{
AuthLogin: "user",
PrivateKey: "private.key",
}
zones, err := provider.ListZones(context.Background())
if err != nil {
panic(err)
}
records, err := provider.GetRecords(context.Background(), "example.nl")
```
```shell
........................
[c] GET /v6/domains HTTP/1.1
[c] Host: api.transip.nl
[c] Accept: application/json
[c] Authorization: Bearer ********************
[c] Content-Type: application/json
[c]
[s] HTTP/2.0 200 OK
[s] Connection: close
[s] Content-Type: application/json
......
[s]
[s] {"domains":[{"name":"...
```
This will by default write to stdout but can set to any `io.Writer` by also setting the `DebugOut` property.
```go
var provider = &transip.Provider{
AuthLogin: "user",
PrivateKey: "private.key",
Debug: true,
DebugOut: log.Writer(),
}
```
## Testing
This library comes with a test suite that verifies the interface by creating a few test records, validating them, and then removing those records. To run the tests, you can use:
```shell
KEY= LOGIN= go test
```
Or run more verbose test to dump all api requests and responses:
```shell
KEY= LOGIN= DEBUG=1 go test -v
```