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

Function deleteRoleCmd

internal/cli/roles.go:291–339  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

289}
290
291func deleteRoleCmd(cli *cli) *cobra.Command {
292 cmd := &cobra.Command{
293 Use: "delete",
294 Aliases: []string{"rm"},
295 Short: "Delete a role",
296 Long: "Delete a role.\n\n" +
297 "To delete interactively, use `auth0 roles delete`.\n\n" +
298 "To delete non-interactively, supply the role id and the `--force` flag to skip confirmation.",
299 Example: ` auth0 roles delete
300 auth0 roles rm
301 auth0 roles delete <role-id>
302 auth0 roles delete <role-id> --force
303 auth0 roles delete <role-id> <role-id2> <role-idn>
304 auth0 roles delete <role-id> <role-id2> <role-idn> --force`,
305 RunE: func(cmd *cobra.Command, args []string) error {
306 var ids []string
307 if len(args) == 0 {
308 if err := roleID.PickMany(cmd, &ids, cli.rolePickerOptions); err != nil {
309 return err
310 }
311 } else {
312 ids = args
313 }
314
315 if !cli.force && canPrompt(cmd) {
316 if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed {
317 return nil
318 }
319 }
320
321 return ansi.ProgressBar("Deleting Role(s)", ids, func(_ int, id string) error {
322 if id != "" {
323 if _, err := cli.api.Role.Read(cmd.Context(), id); err != nil {
324 return fmt.Errorf("failed to delete role with ID %q: %w", id, err)
325 }
326
327 if err := cli.api.Role.Delete(cmd.Context(), id); err != nil {
328 return fmt.Errorf("failed to delete role with ID %q: %w", id, err)
329 }
330 }
331 return nil
332 })
333 },
334 }
335
336 cmd.Flags().BoolVar(&cli.force, "force", false, "Skip confirmation.")
337
338 return cmd
339}
340
341func (c *cli) rolePickerOptions(ctx context.Context) (pickerOptions, error) {
342 list, err := c.api.Role.List(ctx)

Callers 1

rolesCmdFunction · 0.85

Calls 7

ConfirmFunction · 0.92
ProgressBarFunction · 0.92
canPromptFunction · 0.85
ErrorfMethod · 0.80
ReadMethod · 0.65
DeleteMethod · 0.65
PickManyMethod · 0.45

Tested by

no test coverage detected