github.com/simonswine/terraform@v0.9.0-beta2/builtin/providers/ns1/provider.go (about) 1 package ns1 2 3 import ( 4 "net/http" 5 6 "github.com/hashicorp/terraform/helper/schema" 7 "github.com/hashicorp/terraform/terraform" 8 9 ns1 "gopkg.in/ns1/ns1-go.v2/rest" 10 ) 11 12 // Provider returns a terraform.ResourceProvider. 13 func Provider() terraform.ResourceProvider { 14 return &schema.Provider{ 15 Schema: map[string]*schema.Schema{ 16 "apikey": &schema.Schema{ 17 Type: schema.TypeString, 18 Required: true, 19 DefaultFunc: schema.EnvDefaultFunc("NS1_APIKEY", nil), 20 Description: descriptions["api_key"], 21 }, 22 }, 23 ResourcesMap: map[string]*schema.Resource{ 24 "ns1_zone": zoneResource(), 25 "ns1_record": recordResource(), 26 "ns1_datasource": dataSourceResource(), 27 "ns1_datafeed": dataFeedResource(), 28 "ns1_monitoringjob": monitoringJobResource(), 29 "ns1_user": userResource(), 30 "ns1_apikey": apikeyResource(), 31 "ns1_team": teamResource(), 32 }, 33 ConfigureFunc: ns1Configure, 34 } 35 } 36 37 func ns1Configure(d *schema.ResourceData) (interface{}, error) { 38 httpClient := &http.Client{} 39 n := ns1.NewClient(httpClient, ns1.SetAPIKey(d.Get("apikey").(string))) 40 n.RateLimitStrategySleep() 41 return n, nil 42 } 43 44 var descriptions map[string]string 45 46 func init() { 47 descriptions = map[string]string{ 48 "api_key": "The ns1 API key, this is required", 49 } 50 }