-
Notifications
You must be signed in to change notification settings - Fork 0
/
gamelift.go
38 lines (32 loc) · 802 Bytes
/
gamelift.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 resource
import (
"os"
"github.com/chronojam/aws-pricing-api/types/schema"
"github.com/olekukonko/tablewriter"
)
func GetGameLift() {
gamelift := &schema.AmazonGameLift{}
err := gamelift.Refresh()
if err != nil {
panic(err)
}
table := tablewriter.NewWriter(os.Stdout)
table.SetHeader([]string{"Description", "USD", "Unit"})
table.SetRowLine(true)
data := []*schema.AmazonGameLift_Product{}
for _, price := range gamelift.Products {
data = append(data, price)
}
for _, p := range data {
for _, term := range gamelift.Terms {
if term.Sku == p.Sku {
for _, priceData := range term.PriceDimensions {
x := []string{}
v := append(x, priceData.Description, priceData.PricePerUnit.USD, priceData.Unit)
table.Append(v)
}
}
}
}
table.Render()
}