-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
81 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
func apisCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "apis", | ||
Short: "manage resources for APIs.", | ||
} | ||
|
||
cmd.SetUsageTemplate(resourceUsageTemplate()) | ||
cmd.AddCommand(listApisCmd(cli)) | ||
|
||
return cmd | ||
} | ||
|
||
func listApisCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "Lists your existing APIs", | ||
Long: `$ auth0 apis list | ||
Lists your existing APIs. To create one try: | ||
$ auth0 apis create | ||
`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
list, err := cli.api.ResourceServer.List(management.IncludeTotals(false)) | ||
|
||
if err != nil { | ||
return err | ||
} | ||
|
||
cli.renderer.ApisList(list.ResourceServers) | ||
return nil | ||
}, | ||
} | ||
|
||
return cmd | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
package display | ||
|
||
import ( | ||
"github.com/auth0/auth0-cli/internal/ansi" | ||
"gopkg.in/auth0.v5" | ||
"gopkg.in/auth0.v5/management" | ||
) | ||
|
||
type apiView struct { | ||
ID string | ||
Name string | ||
Identifier string | ||
} | ||
|
||
func (v *apiView) AsTableHeader() []string { | ||
return []string{"ID", "Name", "Identifier"} | ||
} | ||
|
||
func (v *apiView) AsTableRow() []string { | ||
return []string{v.ID, v.Name, ansi.Faint(v.Identifier)} | ||
} | ||
|
||
func (r *Renderer) ApisList(apis []*management.ResourceServer) { | ||
r.Heading(ansi.Bold(r.Tenant), "APIs\n") | ||
|
||
var res []View | ||
|
||
for _, api := range apis { | ||
res = append(res, &apiView{ | ||
ID: auth0.StringValue(api.ID), | ||
Name: appTypeFor(api.Name), | ||
Identifier: auth0.StringValue(api.Identifier), | ||
}) | ||
} | ||
|
||
r.Results(res) | ||
} |