2015-02-26 00:54:22 +01:00
|
|
|
package dme
|
2015-01-23 05:38:37 +01:00
|
|
|
|
|
|
|
import (
|
|
|
|
"fmt"
|
|
|
|
"log"
|
2015-10-19 18:04:10 +02:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/soniah/dnsmadeeasy"
|
2015-01-23 05:38:37 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
// Config contains DNSMadeEasy provider settings
|
|
|
|
type Config struct {
|
|
|
|
AKey string
|
|
|
|
SKey string
|
|
|
|
UseSandbox bool
|
|
|
|
}
|
|
|
|
|
|
|
|
// Client returns a new client for accessing DNSMadeEasy
|
2015-02-26 00:54:22 +01:00
|
|
|
func (c *Config) Client() (*dnsmadeeasy.Client, error) {
|
|
|
|
client, err := dnsmadeeasy.NewClient(c.AKey, c.SKey)
|
2015-01-23 05:38:37 +01:00
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("Error setting up client: %s", err)
|
|
|
|
}
|
|
|
|
|
2015-10-19 18:04:10 +02:00
|
|
|
client.HTTP = &http.Client{}
|
|
|
|
|
2015-01-23 05:38:37 +01:00
|
|
|
if c.UseSandbox {
|
2015-02-26 00:54:22 +01:00
|
|
|
client.URL = dnsmadeeasy.SandboxURL
|
2015-01-23 05:38:37 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
log.Printf("[INFO] DNSMadeEasy Client configured for AKey: %s", client.AKey)
|
|
|
|
|
|
|
|
return client, nil
|
|
|
|
}
|