def add_to_groups(self, groups=None, all_groups=False, group_type=None):
if all_groups:<EOL><INDENT>if groups or group_type:<EOL><INDENT>raise ArgumentError("<STR_LIT>")<EOL><DEDENT>glist = "<STR_LIT:all>"<EOL><DEDENT>else:<EOL><INDENT>if not groups:<EOL><INDENT>groups = []<EOL><DEDENT>if not group_type:<EOL><INDENT>group_type = GroupTypes.product<EOL><DEDENT>elif group_type in GroupTypes.__members__:<EOL><INDENT>group_type = GroupTypes[group_type]<EOL><DEDENT>if group_type not in GroupTypes:<EOL><INDENT>raise ArgumentError("<STR_LIT>")<EOL><DEDENT>glist = {group_type.name: [group for group in groups]}<EOL><DEDENT>return self.append(add=glist)<EOL>
Add user to some (typically PLC) groups.  Note that, if you add to no groups, the effect
is simply to do an "add to organization Everybody group", so we let that be done.
:param groups: list of group names the user should be added to
:param all_groups: a boolean meaning add to all (don't specify groups or group_type in this case)
:param group_type: the type of group (defaults to "product")
:return: the User, so you can do User(...).add_to_groups(...).add_role(...)