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

Function enableRuleCmd

internal/cli/rules.go:425–480  ·  view source on GitHub ↗
(cli *cli)

Source from the content-addressed store, hash-verified

423}
424
425func enableRuleCmd(cli *cli) *cobra.Command {
426 var inputs struct {
427 ID string
428 Enabled bool
429 }
430
431 cmd := &cobra.Command{
432 Use: "enable",
433 Args: cobra.MaximumNArgs(1),
434 Short: "Enable a rule",
435 Long: rulesDeprecationDocumentationText + "Enable a rule.",
436 Example: ` auth0 rules enable
437 auth0 rules enable <rule-id>
438 auth0 rules enable <rule-id> --json
439 auth0 rules enable <rule-id> --json-compact`,
440 RunE: func(cmd *cobra.Command, args []string) error {
441 if len(args) > 0 {
442 inputs.ID = args[0]
443 } else {
444 if err := ruleID.Pick(cmd, &inputs.ID, cli.rulePickerOptions); err != nil {
445 return err
446 }
447 }
448
449 var rule *management.Rule
450 err := ansi.Waiting(func() error {
451 var err error
452 rule, err = cli.api.Rule.Read(cmd.Context(), inputs.ID)
453 return err
454 })
455 if err != nil {
456 return fmt.Errorf("failed to fetch rule with ID %q: %w", inputs.ID, err)
457 }
458
459 rule = &management.Rule{
460 Enabled: auth0.Bool(true),
461 }
462
463 if err = ansi.Waiting(func() error {
464 return cli.api.Rule.Update(cmd.Context(), inputs.ID, rule)
465 }); err != nil {
466 return fmt.Errorf("failed to update rule with ID %q: %w", inputs.ID, err)
467 }
468
469 cli.renderer.Warnf(rulesDeprecationLogText)
470 cli.renderer.RuleEnable(rule)
471
472 return nil
473 },
474 }
475
476 cmd.Flags().BoolVar(&cli.json, "json", false, "Output in json format.")
477 cmd.Flags().BoolVar(&cli.jsonCompact, "json-compact", false, "Output in compact json format.")
478
479 return cmd
480}
481
482func disableRuleCmd(cli *cli) *cobra.Command {

Callers 1

rulesCmdFunction · 0.85

Calls 7

WaitingFunction · 0.92
ErrorfMethod · 0.80
WarnfMethod · 0.80
RuleEnableMethod · 0.80
ReadMethod · 0.65
UpdateMethod · 0.65
PickMethod · 0.45

Tested by

no test coverage detected