-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
42 lines (36 loc) · 925 Bytes
/
main.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
package main
import (
"fmt"
"log"
"github.com/aptible/go-deploy/aptible"
"github.com/aptible/go-deploy/client/operations"
)
func main() {
ops, err := getOperations()
if err != nil {
log.Fatalf("couldn't do it: %s", err)
}
fmt.Println("Results:")
for _, op := range ops {
fmt.Println(op)
}
}
func getOperations() ([]string, error) {
c, err := aptible.SetUpClient()
if err != nil {
return []string{}, err
}
page := int64(1)
params := operations.NewGetAccountsAccountIDOperationsParams().WithAccountID(2).WithPage(&page)
resp, err := c.Client.Operations.GetAccountsAccountIDOperations(params, c.Token)
if err != nil {
return []string{}, err
}
var lines []string
for _, op := range resp.Payload.Embedded.Operations {
line := fmt.Sprintf("%v -- %v %s - %s -- %s (%s)",
op.CreatedAt, op.ID, op.Type, op.Status, op.UserName, op.UserEmail)
lines = append(lines, line)
}
return lines, nil
}