-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
c3ef3f6
commit 8ee3885
Showing
1 changed file
with
33 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package main | ||
|
||
import ( | ||
"fmt" | ||
"github.com/transip/gotransip/v6" | ||
"github.com/transip/gotransip/v6/vps" | ||
"log" | ||
"time" | ||
) | ||
|
||
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} | ||
|
||
// Create a usage period with which you can query Vps usage for the last 10 minutes | ||
log.Println("Getting a list of cpu usage for the last 10 minutes") | ||
period := vps.UsagePeriod{ | ||
TimeStart: time.Now().Unix() - 600, | ||
TimeEnd: time.Now().Unix(), | ||
} | ||
|
||
// Query with our usage period for the Vps 'transipdemo-vps4' | ||
usage, err := vpsRepo.GetUsage("transipdemo-vps4", []vps.UsageType{vps.UsageTypeCPU}, period) | ||
if err != nil { | ||
panic(err) | ||
} | ||
fmt.Printf("%+v\n", usage) | ||
} |