-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add listing of organization members (#378)
* Add 'members' subcommand to 'orgs' to list organization members * Add support for pagination * Refactor pagination code for resuse * Switch from `orgs members` to `orgs members list` * Fix formatting of keys Co-authored-by: Rita Zerrizuela <[email protected]>
- Loading branch information
1 parent
bc63c3a
commit 1a646d4
Showing
5 changed files
with
201 additions
and
36 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
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
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
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
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,61 @@ | ||
package display | ||
|
||
import ( | ||
"io" | ||
|
||
"github.com/auth0/auth0-cli/internal/ansi" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
type membersView struct { | ||
ID string | ||
Name string | ||
Email string | ||
PictureURL string | ||
raw interface{} | ||
} | ||
|
||
func (v *membersView) AsTableHeader() []string { | ||
return []string{"ID", "Name", "Email", "Picture"} | ||
} | ||
|
||
func (v *membersView) AsTableRow() []string { | ||
return []string{ansi.Faint(v.ID), v.Name, v.Email, v.PictureURL} | ||
} | ||
|
||
func (v *membersView) KeyValues() [][]string { | ||
return [][]string{ | ||
{"ID", ansi.Faint(v.ID)}, | ||
{"NAME", v.Name}, | ||
{"EMAIL", v.Email}, | ||
{"PICTURE URL", v.PictureURL}, | ||
} | ||
} | ||
|
||
func (v *membersView) Object() interface{} { | ||
return v.raw | ||
} | ||
|
||
func (r *Renderer) MembersList(members []management.OrganizationMember) { | ||
resource := "members" | ||
|
||
r.Heading(resource) | ||
|
||
var res []View | ||
for _, m := range members { | ||
res = append(res, makeMembersView(&m, r.MessageWriter)) | ||
} | ||
|
||
r.Results(res) | ||
} | ||
|
||
func makeMembersView(member *management.OrganizationMember, w io.Writer) *membersView { | ||
|
||
return &membersView{ | ||
ID: member.GetUserID(), | ||
Name: member.GetName(), | ||
Email: member.GetEmail(), | ||
PictureURL: member.GetPicture(), | ||
raw: member, | ||
} | ||
} |