Example #1
0
// Show group details
// @client:    authenticated CLCv1 Client
// @uuid:      hardware group UUID to use
// @acctAlias: account alias to use (leave blank to use default)
// @location:  data centre location (needed to resolve @uuid)
func showGroup(client *clcv1.Client, uuid, acctAlias, location string) {
	if location == "" {
		exit.Errorf("Location is required in order to show the group hierarchy starting at %s", uuid)
	}
	root, err := client.GetGroupHierarchy(location, acctAlias, true)
	if err != nil {
		exit.Fatalf("Failed to look up groups at %s: %s", location, err)
	}
	start := root
	if uuid != "" {
		start = clcv1.FindGroupNode(root, func(g *clcv1.GroupNode) bool {
			return g.UUID == uuid
		})
		if start == nil {
			exit.Fatalf("Failed to look up UUID %s at %s", uuid, location)
		}
	}
	clcv1.PrintGroupHierarchy(start, "")
}