-
Notifications
You must be signed in to change notification settings - Fork 0
/
containerstation_test.go
63 lines (53 loc) · 1.19 KB
/
containerstation_test.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
60
61
62
63
package containerstation_test
import (
"log"
"context"
"net/http"
cstation "github.com/iaburton/containerstation"
)
func ExampleNewClient() {
//nil or any custom client can be passed
cc := cstation.NewClient("https://Nasstorage", http.DefaultClient)
bg := context.Background()
log.Print("Login")
lr, err := cc.Login(bg, user, pass)
if err != nil {
log.Fatalf("%T %v", err, err)
}
log.Printf("%+v", lr)
defer func() {
log.Print("Logout")
outr, err := cc.Logout(bg)
if err != nil {
log.Fatalf("%T %v", err, err)
}
log.Printf("%+v", outr)
}()
log.Print("SystemInformation")
sr, err := cc.SystemInformation(bg)
if err != nil {
log.Panicf("%T %v", err, err)
}
log.Printf("%+v", sr)
log.Print("ResourceUsage")
ru, err := cc.ResourceUsage(bg)
if err != nil {
log.Panicf("%T %v", err, err)
}
log.Printf("%+v", ru)
log.Print("NetworkPort")
used, err := cc.NetworkPort(bg, cstation.TCP, 443)
if err != nil {
log.Panicf("%T %v", err, err)
}
log.Printf("Port 443 used: %v", used)
log.Print("ListContainers")
list, err := cc.ListContainers(bg)
if err != nil {
log.Panicf("%T %v", err, err)
}
for _, c := range list {
log.Printf("Container: %+v", c)
}
// Output:
}