-
Notifications
You must be signed in to change notification settings - Fork 2
/
client.go
44 lines (38 loc) · 885 Bytes
/
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
package amt
import (
"fmt"
"github.com/ammmze/go-amt/cim"
"github.com/ammmze/wsman"
)
// Client used to perform actions on the machine
type Client struct {
*cimClient
wsManClient *wsman.Client
}
type cimClient = cim.CimClient
// NewClient creates an amt client to use.
func NewClient(connection Connection) (*Client, error) {
port := int(connection.Port)
if port == 0 {
port = 16992
}
path := connection.Path
if path == "" {
path = "/wsman"
}
target := fmt.Sprintf("http://%s:%d%s", connection.Host, port, path)
wsmanClient, err := wsman.NewClient(target, connection.User, connection.Pass, true)
if err != nil {
return nil, err
}
wsmanClient.Debug = connection.Debug
cimClient := cim.NewClient(wsmanClient)
return &Client{
cimClient: cimClient,
wsManClient: wsmanClient,
}, nil
}
// Close the client.
func (c *Client) Close() error {
return nil
}