2014-07-23 16:43:28 -05:00
|
|
|
package dnsimple
|
|
|
|
|
|
|
|
import (
|
2014-07-24 09:21:39 -05:00
|
|
|
"fmt"
|
2014-07-23 16:43:28 -05:00
|
|
|
"log"
|
|
|
|
|
2014-07-24 09:21:39 -05:00
|
|
|
"github.com/pearkes/dnsimple"
|
2014-07-23 16:43:28 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
|
|
|
Email string `mapstructure:"email"`
|
2014-11-17 07:01:00 -06:00
|
|
|
Token string `mapstructure:"token"`
|
2014-07-23 16:43:28 -05:00
|
|
|
}
|
|
|
|
|
2014-07-25 11:05:51 -05:00
|
|
|
// Client() returns a new client for accessing dnsimple.
|
2014-07-24 09:21:39 -05:00
|
|
|
func (c *Config) Client() (*dnsimple.Client, error) {
|
|
|
|
client, err := dnsimple.NewClient(c.Email, c.Token)
|
|
|
|
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("Error setting up client: %s", err)
|
|
|
|
}
|
2014-07-23 16:43:28 -05:00
|
|
|
|
|
|
|
log.Printf("[INFO] DNSimple Client configured for user: %s", client.Email)
|
|
|
|
|
|
|
|
return client, nil
|
|
|
|
}
|