def main(client):
  # Initialize appropriate service.
  inventory_service = client.GetService('InventoryService', version='v201511')
  statement = dfp.FilterStatement()

  # Get ad units by statement.
  while True:
    response = inventory_service.getAdUnitsByStatement(
        statement.ToStatement())
    if 'results' in response:
      # Display results.
      for ad_unit in response['results']:
        print ('Ad unit with ID \'%s\' and name \'%s\' was found.'
               % (ad_unit['id'], ad_unit['name']))
      statement.offset += dfp.SUGGESTED_PAGE_LIMIT
    else:
      break

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