Пример #1
0
func listMembers(cmd *cobra.Command, args []string) (err error) {
	dbx := team.New(config)
	arg := team.NewMembersListArg()
	res, err := dbx.MembersList(arg)
	if err != nil {
		return err
	}

	if len(res.Members) == 0 {
		return
	}

	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 4, 8, 1, ' ', 0)
	fmtStr := "%s\t%s\t%s\t%s\t%s\n"
	fmt.Fprintf(w, fmtStr, "Name", "Id", "Status", "Email", "Role")
	for _, member := range res.Members {
		fmt.Fprintf(w, fmtStr,
			member.Profile.Name.DisplayName,
			member.Profile.TeamMemberId,
			member.Profile.Status.Tag,
			member.Profile.Email,
			member.Role.Tag)
	}
	w.Flush()
	return
}
Пример #2
0
func info(cmd *cobra.Command, args []string) (err error) {
	dbx := team.New(config)
	res, err := dbx.GetInfo()
	if err != nil {
		return err
	}

	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 4, 8, 1, ' ', 0)
	fmt.Fprintf(w, "Name:\t%s\n", res.Name)
	fmt.Fprintf(w, "Team Id:\t%s\n", res.TeamId)
	fmt.Fprintf(w, "Licensed Users:\t%d\n", res.NumLicensedUsers)
	fmt.Fprintf(w, "Provisioned Users:\t%d\n", res.NumProvisionedUsers)
	w.Flush()
	return
}
Пример #3
0
func removeMember(cmd *cobra.Command, args []string) (err error) {
	if len(args) != 1 {
		return errors.New("`remove-member` requires an `email` argument")
	}

	dbx := team.New(config)
	email := args[0]
	selector := &team.UserSelectorArg{Email: email}
	selector.Tag = "email"
	arg := team.NewMembersRemoveArg(selector)
	res, err := dbx.MembersRemove(arg)
	if err != nil {
		return err
	}
	if res.Tag == "complete" {
		fmt.Printf("User successfully removed from team.\n")
	}
	return
}
Пример #4
0
func addMember(cmd *cobra.Command, args []string) (err error) {
	if len(args) != 3 {
		return errors.New("`add-member` requires `email`, `first`, and `last` arguments")
	}
	dbx := team.New(config)

	email := args[0]
	firstName := args[1]
	lastName := args[2]
	member := team.NewMemberAddArg(email, firstName, lastName)
	arg := team.NewMembersAddArg([]*team.MemberAddArg{member})
	res, err := dbx.MembersAdd(arg)
	if err != nil {
		return err
	}
	if res.Tag == "complete" {
		fmt.Printf("User successfully added to the team.\n")
	}
	return
}
Пример #5
0
func listGroups(cmd *cobra.Command, args []string) (err error) {
	dbx := team.New(config)
	arg := team.NewGroupsListArg()
	res, err := dbx.GroupsList(arg)
	if err != nil {
		return err
	}

	if len(res.Groups) == 0 {
		return
	}

	w := new(tabwriter.Writer)
	w.Init(os.Stdout, 4, 8, 1, ' ', 0)
	fmt.Fprintf(w, "Name\tId\t# Members\tExternal Id\n")
	for _, group := range res.Groups {
		fmt.Fprintf(w, "%s\t%s\t%d\t%s\n", group.GroupName, group.GroupId, group.MemberCount, group.GroupExternalId)
	}
	w.Flush()
	return
}