Members to add to a team.

        :param members: list of members, either `User` objects or usernames
        :type members: List of `User` or List of pk
        :param role: (optional) role of the users to add (default `TeamRoles.MEMBER`)
        :type role: basestring
        :raises IllegalArgumentError: when providing incorrect roles

        Example
        -------
        >>> my_team = client.team(name='My own team')
        >>> other_user = client.users(name='That other person')
        >>> myself = client.users(name='myself')
        >>> my_team.add_members([myself], role=TeamRoles.MANAGER)
        >>> my_team.add_members([other_user], role=TeamRoles.MEMBER)

def add_members(self, users=None, role=TeamRoles.MEMBER):
        """Members to add to a team.

        :param members: list of members, either `User` objects or usernames
        :type members: List of `User` or List of pk
        :param role: (optional) role of the users to add (default `TeamRoles.MEMBER`)
        :type role: basestring
        :raises IllegalArgumentError: when providing incorrect roles

        Example
        -------
        >>> my_team = client.team(name='My own team')
        >>> other_user = client.users(name='That other person')
        >>> myself = client.users(name='myself')
        >>> my_team.add_members([myself], role=TeamRoles.MANAGER)
        >>> my_team.add_members([other_user], role=TeamRoles.MEMBER)

        """
        if role and role not in TeamRoles.values():
            raise IllegalArgumentError("role should be one of `TeamRoles` {}, got '{}'".format(TeamRoles.values(),
                                                                                               role))

        if not users or not isinstance(users, (list, tuple, set)):
            raise IllegalArgumentError("users should be a list of user_ids or `User` objects, got '{}'".
                                       format(users))

        update_dict = dict(role=role)

        if all(isinstance(user, int) for user in users):
            update_dict['users'] = users
        elif all(isinstance(user, User) for user in users):
            update_dict['users'] = [user.id for user in users]
        else:
            raise IllegalArgumentError("All users should be a list of user_ids or `User` objects, got '{}'".
                                       format(users))

        self._update('team_add_members', team_id=self.id, update_dict=update_dict)