Skip to content
This repository was archived by the owner on Jul 31, 2024. It is now read-only.

added pagination to Roles list #56

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 12 additions & 30 deletions cmd/roles.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,28 @@
rootCmd.AddCommand(idendityProvidersListCmd())
}

//
//
func roleListCmd() *cobra.Command {
options := searchOptions{}

cmd := &cobra.Command{
Use: "roles",
Short: "List and manage PrivX roles",
Long: `List and manage PrivX roles`,
Example: `
privx-cli roles [access flags]
privx-cli roles [access flags] --offset offset --limit limit
`,
SilenceUsage: true,
RunE: func(cmd *cobra.Command, args []string) error {
return roleList()
return roleList(options.offset, options.limit, options.sortdir, options.sortkey)
},
}

flags := cmd.Flags()
flags.IntVar(&options.offset, "offset", 0, "Offset where to start fetching the items")
flags.IntVar(&options.limit, "limit", 50, "Number of items to return")
flags.StringVar(&options.sortdir, "sortdir", "ASC", "Sort direction, ASC or DESC")
flags.StringVar(&options.sortkey, "sortkey", "name", "Sort by specific object property")

cmd.AddCommand(roleCreateCmd())
cmd.AddCommand(roleShowCmd())
cmd.AddCommand(roleDeleteCmd())
Expand All @@ -53,19 +59,17 @@
return cmd
}

func roleList() error {
func roleList(offset, limit int, sortdir, sortkey string) error {
api := rolestore.New(curl())

roles, err := api.Roles()
roles, err := api.Roles(offset, limit, sortkey, sortdir)

Check failure on line 65 in cmd/roles.go

View workflow job for this annotation

GitHub Actions / Build (ubuntu-latest)

too many arguments in call to api.Roles

Check failure on line 65 in cmd/roles.go

View workflow job for this annotation

GitHub Actions / Build (macos-latest)

too many arguments in call to api.Roles
if err != nil {
return err
}

return stdout(roles)
}

//
//
func roleCreateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Expand Down Expand Up @@ -101,8 +105,6 @@
return stdout(id)
}

//
//
func roleShowCmd() *cobra.Command {
options := roleOptions{}

Expand Down Expand Up @@ -137,8 +139,6 @@
return stdout(role)
}

//
//
func roleDeleteCmd() *cobra.Command {
options := roleOptions{}

Expand Down Expand Up @@ -177,8 +177,6 @@
return nil
}

//
//
func roleUpdateCmd() *cobra.Command {
options := roleOptions{}

Expand Down Expand Up @@ -220,8 +218,6 @@
return nil
}

//
//
func rolesMemberListCmd() *cobra.Command {
options := roleOptions{}

Expand Down Expand Up @@ -260,8 +256,6 @@
return stdout(members)
}

//
//
func roleResolveCmd() *cobra.Command {
options := roleOptions{}

Expand Down Expand Up @@ -296,8 +290,6 @@
return stdout(id)
}

//
//
func awsTokenShowCmd() *cobra.Command {
options := roleOptions{}

Expand Down Expand Up @@ -377,8 +369,6 @@
return stdout(idendity.Items)
}

//
//
func idendityCreateCmd() *cobra.Command {
cmd := &cobra.Command{
Use: "create",
Expand Down Expand Up @@ -414,8 +404,6 @@
return stdout(id)
}

//
//
func idendityShowCmd() *cobra.Command {
var ID string

Expand Down Expand Up @@ -450,8 +438,6 @@
return stdout(IDProvider)
}

//
//
func idendityDeleteCmd() *cobra.Command {
var IDs string

Expand Down Expand Up @@ -490,8 +476,6 @@
return nil
}

//
//
func idendityUpdateCmd() *cobra.Command {
var ID string
cmd := &cobra.Command{
Expand Down Expand Up @@ -532,8 +516,6 @@
return nil
}

//
//
func idenditySearchCmd() *cobra.Command {
searchParams := rolestore.Params{}
var keywords string
Expand Down
Loading