docs: def delete_group(group_id, purge_data,**kwargs):
      """
          Remove group from DB completely
          If there are attributes on the group, use purge_data to try to
          delete the data. If no other resources group to this data, it
          will be deleted.
      """
      user_id = kwargs.get('user_id')
      try:
          group_i = db.DBSession.query(ResourceGroup).filter(ResourceGroup.id == group_id).one()
      except NoResultFound:
          raise ResourceNotFoundError("Group %s not found"%(group_id))
  
      group_items = db.DBSession.query(ResourceGroupItem).filter(
                                                      ResourceGroupItem.group_id==group_id).all()
      for gi in group_items:
          db.DBSession.delete(gi)
  
      if purge_data == 'Y':
          _purge_datasets_unique_to_resource('GROUP', group_id)
  
      log.info("Deleting group %s, id=%s", group_i.name, group_id)
  
      group_i.network.check_write_permission(user_id)
      db.DBSession.delete(group_i)
      db.DBSession.flush()