-
Notifications
You must be signed in to change notification settings - Fork 0
/
cartel_client.go
59 lines (49 loc) · 1.2 KB
/
cartel_client.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
57
58
59
package hsdp
import (
"github.com/cloudfoundry-community/gautocloud"
"github.com/cloudfoundry-community/gautocloud/connectors"
"github.com/philips-software/go-hsdp-api/cartel"
)
func init() {
gautocloud.RegisterConnector(NewCartelClientConnector())
}
type CartelClient struct {
cartel.Config
*cartel.Client
}
type CartelClientConnector struct {
wrapRawConn connectors.Connector
}
func (c CartelClientConnector) Id() string {
return "hsdp:cartel-client"
}
func (c CartelClientConnector) Name() string {
return c.wrapRawConn.Name()
}
func (c CartelClientConnector) Tags() []string {
return c.wrapRawConn.Tags()
}
func (c CartelClientConnector) Load(schema interface{}) (interface{}, error) {
schema, err := c.wrapRawConn.Load(schema)
if err != nil {
return nil, err
}
fSchema := schema.(CartelConfig)
config := cartel.Config(fSchema)
client, err := cartel.NewClient(nil, &config)
if err != nil {
return nil, err
}
return &CartelClient{
Client: client,
Config: config,
}, nil
}
func (c CartelClientConnector) Schema() interface{} {
return c.wrapRawConn.Schema()
}
func NewCartelClientConnector() connectors.Connector {
return &CartelClientConnector{
wrapRawConn: NewCartelRawConnector(),
}
}