def main(client):
  # Initialize appropriate service.
  user_service = client.GetService('UserService', version='v201508')

  # Create a filter statement.
  statement = dfp.FilterStatement()

  # Get users by statement.
  while True:
    response = user_service.getUsersByStatement(statement.ToStatement())
    if 'results' in response:
      # Display results.
      for user in response['results']:
        print ('User with id \'%s\', email \'%s\', and role \'%s\' was found.'
               % (user['id'], user['email'], user['roleName']))
      statement.offset += dfp.SUGGESTED_PAGE_LIMIT
    else:
      break

  print '\nNumber of results found: %s' % response['totalResultSetSize']
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201508/user_service/get_all_users.py/main/original