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

Method filteredAPIPickerOptions

internal/cli/apis.go:710–733  ·  view source on GitHub ↗
(ctx context.Context, include func(r *management.ResourceServer) bool)

Source from the content-addressed store, hash-verified

708}
709
710func (c *cli) filteredAPIPickerOptions(ctx context.Context, include func(r *management.ResourceServer) bool) (pickerOptions, error) {
711 list, err := c.api.ResourceServer.List(ctx)
712 if err != nil {
713 return nil, fmt.Errorf("failed to list APIs: %w", err)
714 }
715
716 // NOTE: because client names are not unique, we'll just number these
717 // labels.
718 var opts pickerOptions
719 for _, r := range list.ResourceServers {
720 if !include(r) {
721 continue
722 }
723 label := fmt.Sprintf("%s %s", r.GetName(), ansi.Faint("("+r.GetIdentifier()+")"))
724
725 opts = append(opts, pickerOption{value: r.GetID(), label: label})
726 }
727
728 if len(opts) == 0 {
729 return nil, errors.New("there are currently no APIs to choose from. Create one by running: `auth0 apis create`")
730 }
731
732 return opts, nil
733}

Callers 2

apiPickerOptionsMethod · 0.95

Calls 4

FaintFunction · 0.92
ErrorfMethod · 0.80
ListMethod · 0.65
GetNameMethod · 0.65

Tested by

no test coverage detected