forked from hashicorp/terraform
-
Notifications
You must be signed in to change notification settings - Fork 0
/
config.go
39 lines (29 loc) · 883 Bytes
/
config.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
package softlayer
import (
"log"
slclient "github.com/maximilien/softlayer-go/client"
softlayer "github.com/maximilien/softlayer-go/softlayer"
)
type Config struct {
Username string
ApiKey string
}
type Client struct {
virtualGuestService softlayer.SoftLayer_Virtual_Guest_Service
sshKeyService softlayer.SoftLayer_Security_Ssh_Key_Service
productOrderService softlayer.SoftLayer_Product_Order_Service
}
func (c *Config) Client() (*Client, error) {
slc := slclient.NewSoftLayerClient(c.Username, c.ApiKey)
virtualGuestService, err := slc.GetSoftLayer_Virtual_Guest_Service()
if err != nil {
return nil, err
}
sshKeyService, err := slc.GetSoftLayer_Security_Ssh_Key_Service()
client := &Client{
virtualGuestService: virtualGuestService,
sshKeyService: sshKeyService,
}
log.Println("[INFO] Created SoftLayer client")
return client, nil
}