MCPcopy Create free account
hub / github.com/auth0/auth0-cli / listUserBlocksCmd

Function listUserBlocksCmd

internal/cli/users_blocks.go:27–77  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

25}
26
27func listUserBlocksCmd(cli *cli) *cobra.Command {
28 var inputs struct {
29 userIdentifier string
30 }
31
32 cmd := &cobra.Command{
33 Use: "list",
34 Args: cobra.MaximumNArgs(1),
35 Short: "List brute-force protection blocks for a given user",
36 Long: "List brute-force protection blocks for a given user by user ID, username, phone number or email.",
37 Example: ` auth0 users blocks list <user-id|username|email|phone-number>
38 auth0 users blocks list <user-id|username|email|phone-number> --json
39 auth0 users blocks list <user-id|username|email|phone-number> --json-compact
40 auth0 users blocks list "auth0|61b5b6e90783fa19f7c57dad"
41 auth0 users blocks list "frederik@travel0.com"
42 auth0 users blocks list <user-id|username|email|phone-number> --csv`,
43 RunE: func(cmd *cobra.Command, args []string) error {
44 if len(args) == 0 {
45 if err := userIdentifier.Ask(cmd, &inputs.userIdentifier); err != nil {
46 return err
47 }
48 } else {
49 inputs.userIdentifier = args[0]
50 }
51
52 var userBlocks []*management.UserBlock
53 err := ansi.Waiting(func() (err error) {
54 userBlocks, err = cli.api.User.Blocks(cmd.Context(), inputs.userIdentifier)
55 if mErr, ok := err.(management.Error); ok && mErr.Status() != http.StatusBadRequest {
56 return err
57 }
58
59 userBlocks, err = cli.api.User.BlocksByIdentifier(cmd.Context(), inputs.userIdentifier)
60 return err
61 })
62 if err != nil {
63 return fmt.Errorf("failed to list user blocks for user with ID %q: %w", inputs.userIdentifier, err)
64 }
65
66 cli.renderer.UserBlocksList(userBlocks)
67 return nil
68 },
69 }
70
71 cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
72 cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.")
73 cmd.Flags().BoolVar(&cli.csv, "csv", false, "Output in csv format.")
74 cmd.MarkFlagsMutuallyExclusive("json", "json-compact", "csv")
75
76 return cmd
77}
78
79func deleteUserBlocksCmd(cli *cli) *cobra.Command {
80 cmd := &cobra.Command{

Callers 1

userBlocksCmdFunction · 0.85

Calls 7

WaitingFunction · 0.92
ErrorfMethod · 0.80
UserBlocksListMethod · 0.80
BlocksMethod · 0.65
BlocksByIdentifierMethod · 0.65
AskMethod · 0.45
StatusMethod · 0.45

Tested by

no test coverage detected