-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CLI-80: user-blocks commands with user_id #201
Conversation
|
||
func userBlocksCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "user-blocks", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please put it under users
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As a subcommand: auth0 users blocks
|
||
var ( | ||
userID = Argument{ | ||
Name: "user_id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Name: "user_id", | |
Name: "User ID", |
var ( | ||
userID = Argument{ | ||
Name: "user_id", | ||
Help: "user_id of the user.", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Help: "user_id of the user.", | |
Help: "Id of the user.", |
|
||
func listUserBlocksByUserIdCmd(cli *cli) *cobra.Command { | ||
var inputs struct { | ||
user_id string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use snake_case
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "listByUserId", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please use list
. Entire command should be auth0 users blocks list
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we can list by user_id
or list by email / phonenumber / user_identifier
. It's a different API call, what would a good way to name the handle the two different input types?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The command should accept any of these as a single argument, and then disambiguate. It's the easiest for the user, that remains unaware (as they should) of those implementation details.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
e.g. auth0 apis show
accepts an API id or the audience.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For the end user, there's no difference.
cmd := &cobra.Command{ | ||
Use: "listByUserId", | ||
Args: cobra.MaximumNArgs(1), | ||
Short: "List user-blocks by user_id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not include the API2 entities as-is, instead describe what the command does in the context of a single user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assume the user knows nothing about API2.
Use: "listByUserId", | ||
Args: cobra.MaximumNArgs(1), | ||
Short: "List user-blocks by user_id", | ||
Long: `List user-blocks by user_id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
|
||
func deleteUserBlocksByUserIdCmd(cli *cli) *cobra.Command { | ||
var inputs struct { | ||
user_id string |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not use snake_case.
} | ||
|
||
cmd := &cobra.Command{ | ||
Use: "deleteByUserId", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please usedelete
. Entire command should be auth0 users blocks delete
.
cmd := &cobra.Command{ | ||
Use: "deleteByUserId", | ||
Args: cobra.MaximumNArgs(1), | ||
Short: "Delete all user-blocks by user_id", |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please do not include the API2 entities as-is, instead describe what the command does in the context of a single user.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Assume the user knows nothing about API2.
Use: "deleteByUserId", | ||
Args: cobra.MaximumNArgs(1), | ||
Short: "Delete all user-blocks by user_id", | ||
Long: `Delete all user-blocks by user_id: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same as above.
} | ||
|
||
func (r *Renderer) UserBlocksList(userBlocks []*management.UserBlock) { | ||
resource := "userBlocks" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
resource := "userBlocks" | |
resource := "user blocks" |
|
||
if len(userBlocks) == 0 { | ||
r.EmptyState(resource) | ||
r.Infof("No blocks for user.") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r.EmptyState(resource)
and r.Infof("No blocks for user.")
do the same thing, please remove the last one.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please refactor to fit in with the rest of the CLI. Please use the apps
, apis
, and rules
commands as a reference.
moving to branch on main repo |
Description
Add commands for managing user-blocks by user_id
References
https://auth0team.atlassian.net/browse/CLI-80
https://auth0.com/docs/api/management/v2#!/User_Blocks/delete_user_blocks
https://github.com/go-auth0/auth0/blob/master/management/user.go#L423-L449