(cli *cli)
| 105 | } |
| 106 | |
| 107 | func listCustomDomainsCmd(cli *cli) *cobra.Command { |
| 108 | var inputs struct { |
| 109 | filter string |
| 110 | sortBy string |
| 111 | } |
| 112 | |
| 113 | cmd := &cobra.Command{ |
| 114 | Use: "list", |
| 115 | Aliases: []string{"ls"}, |
| 116 | Args: cobra.NoArgs, |
| 117 | Short: "List your custom domains", |
| 118 | Long: "List your existing custom domains. To create one, run: `auth0 domains create`.", |
| 119 | Example: ` auth0 domains list |
| 120 | auth0 domains ls |
| 121 | auth0 domains ls --json |
| 122 | auth0 domains ls --json-compact |
| 123 | auth0 domains ls --csv |
| 124 | auth0 domains ls --filter "domain:demo* AND status:pending_verification"`, |
| 125 | RunE: func(cmd *cobra.Command, args []string) error { |
| 126 | // Validate EA-only flags. |
| 127 | if inputs.sortBy != "" && inputs.sortBy != "domain" { |
| 128 | return fmt.Errorf("sorting is only supported by domain at this time") |
| 129 | } |
| 130 | |
| 131 | var domains []*management.CustomDomain |
| 132 | var err error |
| 133 | |
| 134 | err = ansi.Waiting(func() error { |
| 135 | if inputs.filter != "" || inputs.sortBy != "" { |
| 136 | // EA-only path. |
| 137 | options := []management.RequestOption{ |
| 138 | management.Take(100), |
| 139 | } |
| 140 | if inputs.filter != "" { |
| 141 | options = append(options, management.Parameter("q", inputs.filter)) |
| 142 | } |
| 143 | |
| 144 | if inputs.sortBy != "" { |
| 145 | options = append(options, management.Parameter("q", inputs.sortBy)) |
| 146 | } |
| 147 | |
| 148 | result, e := cli.api.CustomDomain.ListWithPagination(cmd.Context(), options...) |
| 149 | if e != nil { |
| 150 | return fmt.Errorf("failed to list custom domains (EA-only): %w", e) |
| 151 | } |
| 152 | domains = result.CustomDomains |
| 153 | return nil |
| 154 | } |
| 155 | |
| 156 | // Non Paginated Path. |
| 157 | domains, err = cli.api.CustomDomain.List(cmd.Context()) |
| 158 | return err |
| 159 | }) |
| 160 | if err != nil { |
| 161 | return err |
| 162 | } |
| 163 | |
| 164 | cli.renderer.CustomDomainList(domains) |
no test coverage detected