/
auth_groups_list.go
47 lines (38 loc) · 1.18 KB
/
auth_groups_list.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
package cmd
import (
"net/http"
"time"
"github.com/spf13/cobra"
"github.com/treeverse/lakefs/pkg/api/apigen"
"github.com/treeverse/lakefs/pkg/api/apiutil"
)
var authGroupsListCmd = &cobra.Command{
Use: "list",
Short: "List groups",
Run: func(cmd *cobra.Command, args []string) {
amount := Must(cmd.Flags().GetInt("amount"))
after := Must(cmd.Flags().GetString("after"))
clt := getClient()
resp, err := clt.ListGroupsWithResponse(cmd.Context(), &apigen.ListGroupsParams{
After: apiutil.Ptr(apigen.PaginationAfter(after)),
Amount: apiutil.Ptr(apigen.PaginationAmount(amount)),
})
DieOnErrorOrUnexpectedStatusCode(resp, err, http.StatusOK)
if resp.JSON200 == nil {
Die("Bad response from server", 1)
}
groups := resp.JSON200.Results
rows := make([][]interface{}, len(groups))
for i, group := range groups {
ts := time.Unix(group.CreationDate, 0).String()
rows[i] = []interface{}{group.Id, ts}
}
pagination := resp.JSON200.Pagination
PrintTable(rows, []interface{}{"Group ID", "Creation Date"}, &pagination, amount)
},
}
//nolint:gochecknoinits
func init() {
addPaginationFlags(authGroupsListCmd)
authGroupsCmd.AddCommand(authGroupsListCmd)
}