-
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.
Add
connections
and connections list
.
- Loading branch information
1 parent
e605506
commit 16400bd
Showing
3 changed files
with
78 additions
and
0 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
package cli | ||
|
||
import ( | ||
"github.com/spf13/cobra" | ||
) | ||
|
||
func connectionsCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "connections", | ||
Short: "manage resources for connections.", | ||
} | ||
|
||
cmd.SetUsageTemplate(resourceUsageTemplate()) | ||
cmd.AddCommand(listConnectionsCmd(cli)) | ||
|
||
return cmd | ||
} | ||
|
||
func listConnectionsCmd(cli *cli) *cobra.Command { | ||
cmd := &cobra.Command{ | ||
Use: "list", | ||
Short: "Lists your existing connections", | ||
Long: `$ auth0 connections list | ||
Lists your existing connections. To create one try: | ||
$ auth0 connections create | ||
`, | ||
RunE: func(cmd *cobra.Command, args []string) error { | ||
list, err := cli.api.Connection.List() | ||
if err != nil { | ||
return err | ||
} | ||
|
||
cli.renderer.ConnectionList(list.Connections) | ||
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 connectionView struct { | ||
Name string | ||
Strategy string | ||
ConnectionID string | ||
} | ||
|
||
func (v *connectionView) AsTableHeader() []string { | ||
return []string{"Name", "Type", "ClientID"} | ||
} | ||
|
||
func (v *connectionView) AsTableRow() []string { | ||
return []string{v.Name, v.Strategy, ansi.Faint(v.ConnectionID)} | ||
} | ||
|
||
func (r *Renderer) ConnectionList(connections []*management.Connection) { | ||
r.Heading(ansi.Bold(r.Tenant), "connections\n") | ||
|
||
var res []View | ||
for _, c := range connections { | ||
res = append(res, &connectionView{ | ||
Name: auth0.StringValue(c.Name), | ||
Strategy: auth0.StringValue(c.Strategy), | ||
ConnectionID: auth0.StringValue(c.ID), | ||
}) | ||
|
||
} | ||
|
||
r.Results(res) | ||
} |