/
organization_get.go
51 lines (45 loc) · 1.1 KB
/
organization_get.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
package commands
import (
"fmt"
"os"
"golang.org/x/net/context"
pb "github.com/jaypipes/procession/proto"
"github.com/spf13/cobra"
)
var orgGetCommand = &cobra.Command{
Use: "get <search>",
Short: "Get information for a single organization",
Run: orgGet,
}
func orgGet(cmd *cobra.Command, args []string) {
checkAuthUser(cmd)
if len(args) == 0 {
fmt.Println("Please specify a UUID, name or slug to search for.")
cmd.Usage()
os.Exit(1)
}
conn := connect()
defer conn.Close()
client := pb.NewIAMClient(conn)
req := &pb.OrganizationGetRequest{
Session: &pb.Session{User: authUser},
Search: args[0],
}
org, err := client.OrganizationGet(context.Background(), req)
exitIfError(err)
if org.Uuid == "" {
fmt.Printf("No organization found matching request\n")
os.Exit(1)
}
fmt.Printf("UUID: %s\n", org.Uuid)
fmt.Printf("Display name: %s\n", org.DisplayName)
fmt.Printf("Slug: %s\n", org.Slug)
fmt.Printf("Visibility: %s\n", org.Visibility)
if org.Parent != nil {
fmt.Printf(
"Parent: %s [%s]\n",
org.Parent.DisplayName,
org.Parent.Uuid,
)
}
}