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

  # Create statement to get all labels
  statement = dfp.FilterStatement()

  # Get labels by statement.
  while True:
    response = label_service.getLabelsByStatement(statement.ToStatement())
    if 'results' in response:
      # Display results.
      for label in response['results']:
        print ('Label with id \'%s\' and name \'%s\' was found.'
               % (label['id'], label['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/v201508/label_service/get_all_labels.py/main/original