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

Function deleteAPICmd

internal/cli/apis.go:536–582  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

534}
535
536func deleteAPICmd(cli *cli) *cobra.Command {
537 cmd := &cobra.Command{
538 Use: "delete",
539 Aliases: []string{"rm"},
540 Short: "Delete an API",
541 Long: "Delete an API.\n\n" +
542 "To delete interactively, use `auth0 apis delete` with no arguments.\n\n" +
543 "To delete non-interactively, supply the API id and the `--force` flag to skip confirmation.",
544 Example: ` auth0 apis delete
545 auth0 apis rm
546 auth0 apis delete <api-id|api-audience>
547 auth0 apis delete <api-id|api-audience> --force
548 auth0 apis delete <api-id|api-audience> <api-id2> <api-idn>
549 auth0 apis delete <api-id|api-audience> <api-id2> <api-idn> --force`,
550 RunE: func(cmd *cobra.Command, args []string) error {
551 var ids []string
552 if len(args) == 0 {
553 if err := apiID.PickMany(cmd, &ids, cli.apiPickerOptions); err != nil {
554 return err
555 }
556 } else {
557 ids = append(ids, args...)
558 }
559
560 if !cli.force && canPrompt(cmd) {
561 if confirmed := prompt.Confirm("Are you sure you want to proceed?"); !confirmed {
562 return nil
563 }
564 }
565
566 return ansi.ProgressBar("Deleting API(s)", ids, func(_ int, id string) error {
567 if _, err := cli.api.ResourceServer.Read(cmd.Context(), id); err != nil {
568 return fmt.Errorf("failed to delete API with ID %q: %w", id, err)
569 }
570
571 if err := cli.api.ResourceServer.Delete(cmd.Context(), id); err != nil {
572 return fmt.Errorf("failed to delete API with ID %q: %w", id, err)
573 }
574 return nil
575 })
576 },
577 }
578
579 cmd.Flags().BoolVar(&cli.force, "force", false, "Skip confirmation.")
580
581 return cmd
582}
583
584func openAPICmd(cli *cli) *cobra.Command {
585 var inputs struct {

Callers 1

apisCmdFunction · 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