forked from transip/gotransip
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vps.go
38 lines (33 loc) · 908 Bytes
/
vps.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
package main
import (
"fmt"
"github.com/assi010/gotransip/v6"
"github.com/assi010/gotransip/v6/vps"
"log"
)
func main() {
// Create a new client with the default demo client config, using the demo token
client, err := gotransip.NewClient(gotransip.DemoClientConfiguration)
if err != nil {
panic(err)
}
vpsRepo := vps.Repository{Client: client}
log.Println("Getting a list of vpses")
vpss, err := vpsRepo.GetAll()
if err != nil {
panic(err)
}
// Simple loop to print vpses with their ip addresses
// Check out the vps structs to learn more about which data you can use
// For more info about the vps api, see: https://api.transip.nl/rest/docs.html#vps-vps-get
for _, v := range vpss {
ips, err := vpsRepo.GetIPAddresses(v.Name)
if err != nil {
panic(err)
}
fmt.Printf("Vps '%s' with ips:\n", v.Name)
for _, ip := range ips {
fmt.Printf("- %s\n", ip.Address)
}
}
}