Skip to content
This repository was archived by the owner on Jul 31, 2024. It is now read-only.
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 @@ func init() {
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 @@ func roleListCmd() *cobra.Command {
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)
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 @@ func roleCreate(args []string) error {
return stdout(id)
}

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

Expand Down Expand Up @@ -137,8 +139,6 @@ func roleShow(options roleOptions) error {
return stdout(role)
}

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

Expand Down Expand Up @@ -177,8 +177,6 @@ func roleDelete(options roleOptions) error {
return nil
}

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

Expand Down Expand Up @@ -220,8 +218,6 @@ func roleUpdate(options roleOptions, args []string) error {
return nil
}

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

Expand Down Expand Up @@ -260,8 +256,6 @@ func roleMemberList(options roleOptions) error {
return stdout(members)
}

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

Expand Down Expand Up @@ -296,8 +290,6 @@ func roleResolve(options roleOptions) error {
return stdout(id)
}

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

Expand Down Expand Up @@ -377,8 +369,6 @@ func idendityProvidersList(offset, limit int) error {
return stdout(idendity.Items)
}

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

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

Expand Down Expand Up @@ -450,8 +438,6 @@ func idendityShow(ID string) error {
return stdout(IDProvider)
}

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

Expand Down Expand Up @@ -490,8 +476,6 @@ func idendityDelete(IDs string) error {
return nil
}

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

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