def shareItemsToGroup(self, shareToGroupName, items=None, groups=None):
        """Share already published items with a group(s).
        
        Args:
            shareToGroupName (list): The name of the group(s) with which the item(s) will be shared.
            items (list): The item(s) that will be shared, referenced by their ID. Defaults to ``None``.
            groups (list): The group(s) whose content will be shared, referenced by their ID. Defaults to ``None``.            
        Notes:
            If you want to share with a single group, ``shareToGroupName`` can be passed as a ``str``.
        
        """
        admin = None
        userCommunity = None
        group_ids = None
        results = None
        item = None
        res = None
        group = None
        groupContent = None
        result = None
        try:
            admin = arcrest.manageorg.Administration(securityHandler=self._securityHandler)

            userCommunity = admin.community
            group_ids = userCommunity.getGroupIDs(groupNames=shareToGroupName)
            results = []
            if not items is None:
                for item in items:
                    item = admin.content.getItem(itemId = item)
                    res = item.shareItem(",".join(group_ids),everyone=False,org=False)
                    if 'error' in res:
                        print (res)
                    else:
                        print ("'%s' shared with '%s'" % (item.title,shareToGroupName))
                    results.append(res)
            if not groups is None:
                for groupId in groups:
                    group = admin.content.group(groupId=groupId)

                    if group is None:
                        print ("Group with ID {0} was not found".format(groupId))

                    elif group.hasError() == True:
                        print ("Group with ID {0} returned the following error {1}".format(groupId,group.error))
                    else:
                        for itemJSON in group.items:
                            if 'id' in itemJSON:
                                item = admin.content.getItem(itemId = itemJSON['id'])
                                res = item.shareItem(",".join(group_ids),everyone=False,org=False)
                                if 'error' in res:
                                    print (res)
                                elif res.get('notSharedWith', []):
                                    print ("'%s' shared with '%s', not Shared With '%s'" % \
                                          (item.title,shareToGroupName,",".join(res['notSharedWith'])))
                                else:
                                    print ("'%s' shared with '%s'" % (item.title,shareToGroupName))
                                results.append(res)

        except:
            line, filename, synerror = trace()
            raise common.ArcRestHelperError({
                        "function": "shareItemsToGroup",
                        "line": line,
                        "filename":  filename,
                        "synerror": synerror,
                                        }
                                        )
        finally:
            admin = None
            userCommunity = None
            group_ids = None

            item = None
            res = None
            group = None
            groupContent = None
            result = None

            del admin
            del userCommunity
            del group_ids

            del item
            del res
            del group
            del groupContent
            del result
            gc.collect()
def shareItemsToGroup ( self , shareToGroupName , items = None , groups = None ) : admin = None userCommunity = None group_ids = None results = None item = None res = None group = None groupContent = None result = None try : admin = arcrest . manageorg . Administration ( securityHandler = self . _securityHandler ) userCommunity = admin . community group_ids = userCommunity . getGroupIDs ( groupNames = shareToGroupName ) results = [ ] if not items is None : for item in items : item = admin . content . getItem ( itemId = item ) res = item . shareItem ( "," . join ( group_ids ) , everyone = False , org = False ) if 'error' in res : print ( res ) else : print ( "'%s' shared with '%s'" % ( item . title , shareToGroupName ) ) results . append ( res ) if not groups is None : for groupId in groups : group = admin . content . group ( groupId = groupId ) if group is None : print ( "Group with ID {0} was not found" . format ( groupId ) ) elif group . hasError ( ) == True : print ( "Group with ID {0} returned the following error {1}" . format ( groupId , group . error ) ) else : for itemJSON in group . items : if 'id' in itemJSON : item = admin . content . getItem ( itemId = itemJSON [ 'id' ] ) res = item . shareItem ( "," . join ( group_ids ) , everyone = False , org = False ) if 'error' in res : print ( res ) elif res . get ( 'notSharedWith' , [ ] ) : print ( "'%s' shared with '%s', not Shared With '%s'" % ( item . title , shareToGroupName , "," . join ( res [ 'notSharedWith' ] ) ) ) else : print ( "'%s' shared with '%s'" % ( item . title , shareToGroupName ) ) results . append ( res ) except : line , filename , synerror = trace ( ) raise common . ArcRestHelperError ( { "function" : "shareItemsToGroup" , "line" : line , "filename" : filename , "synerror" : synerror , } ) finally : admin = None userCommunity = None group_ids = None item = None res = None group = None groupContent = None result = None del admin del userCommunity del group_ids del item del res del group del groupContent del result gc . collect ( )
Share already published items with a group(s).
        
        Args:
            shareToGroupName (list): The name of the group(s) with which the item(s) will be shared.
            items (list): The item(s) that will be shared, referenced by their ID. Defaults to ``None``.
            groups (list): The group(s) whose content will be shared, referenced by their ID. Defaults to ``None``.            
        Notes:
            If you want to share with a single group, ``shareToGroupName`` can be passed as a ``str``.