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