github.com/vtorhonen/terraform@v0.9.0-beta2.0.20170307220345-5d894e4ffda7/builtin/providers/dnsimple/config.go (about)

     1  package dnsimple
     2  
     3  import (
     4  	"log"
     5  
     6  	"github.com/dnsimple/dnsimple-go/dnsimple"
     7  	"github.com/hashicorp/terraform/terraform"
     8  )
     9  
    10  type Config struct {
    11  	Email   string
    12  	Account string
    13  	Token   string
    14  }
    15  
    16  // Client represents the DNSimple provider client.
    17  // This is a convenient container for the configuration and the underlying API client.
    18  type Client struct {
    19  	client *dnsimple.Client
    20  	config *Config
    21  }
    22  
    23  // Client() returns a new client for accessing dnsimple.
    24  func (c *Config) Client() (*Client, error) {
    25  	client := dnsimple.NewClient(dnsimple.NewOauthTokenCredentials(c.Token))
    26  	client.UserAgent = "HashiCorp-Terraform/" + terraform.VersionString()
    27  
    28  	provider := &Client{
    29  		client: client,
    30  		config: c,
    31  	}
    32  
    33  	log.Printf("[INFO] DNSimple Client configured for account: %s", c.Account)
    34  
    35  	return provider, nil
    36  }