2014-07-25 11:21:15 -05:00
|
|
|
package cloudflare
|
|
|
|
|
|
|
|
import (
|
2016-06-06 14:57:26 -05:00
|
|
|
"fmt"
|
2014-07-25 11:21:15 -05:00
|
|
|
"log"
|
|
|
|
|
2016-06-06 14:48:03 -05:00
|
|
|
"github.com/cloudflare/cloudflare-go"
|
2014-07-25 11:21:15 -05:00
|
|
|
)
|
|
|
|
|
|
|
|
type Config struct {
|
2014-11-17 11:57:41 -06:00
|
|
|
Email string
|
|
|
|
Token string
|
2014-07-25 11:21:15 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
// Client() returns a new client for accessing cloudflare.
|
2016-05-03 11:43:08 -05:00
|
|
|
func (c *Config) Client() (*cloudflare.API, error) {
|
2016-06-06 14:57:26 -05:00
|
|
|
client, err := cloudflare.New(c.Token, c.Email)
|
|
|
|
if err != nil {
|
|
|
|
return nil, fmt.Errorf("Error creating new CloudFlare client: %s", err)
|
|
|
|
}
|
2016-04-27 12:04:07 -05:00
|
|
|
log.Printf("[INFO] CloudFlare Client configured for user: %s", c.Email)
|
2014-07-25 11:21:15 -05:00
|
|
|
return client, nil
|
|
|
|
}
|