-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathprovider.go
56 lines (51 loc) · 1.58 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
51
52
53
54
55
56
package main
import (
"github.com/hashicorp/terraform/helper/schema"
"github.com/hashicorp/terraform/terraform"
twilioc "github.com/kevinburke/twilio-go"
)
func provider() terraform.ResourceProvider {
return &schema.Provider{
Schema: map[string]*schema.Schema{
"account_sid": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("TWILIO_SID", nil),
Description: "The SID (application ID) for the the Twilio API",
},
"auth_token": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("TWILIO_AUTH_TOKEN", nil),
Description: "Oauth token for the the Twilio API",
},
"workspace_sid": &schema.Schema{
Type: schema.TypeString,
Required: true,
DefaultFunc: schema.EnvDefaultFunc("TWILIO_WORKSPACE_SID", nil),
Description: "Workspace SID for Task Router",
},
},
ResourcesMap: map[string]*schema.Resource{
"twiliotaskrouter_activity": resourceTaskRouterActivity(),
"twiliotaskrouter_queue": resourceTaskRouterQueue(),
"twiliotaskrouter_workflow": resourceTaskRouterWorkflow(),
"twiliotaskrouter_worker": resourceTaskRouterWorker(),
},
ConfigureFunc: providerConfigure,
}
}
type twilioMeta struct {
Client *twilioc.Client
WorkspaceSid string
}
func providerConfigure(d *schema.ResourceData) (interface{}, error) {
return &twilioMeta{
Client: twilioc.NewClient(
d.Get("account_sid").(string),
d.Get("auth_token").(string),
nil,
),
WorkspaceSid: d.Get("workspace_sid").(string),
}, nil
}