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

  # Create statement object to only select system defined creative templates.
  values = [{
      'key': 'creativeTemplateType',
      'value': {
          'xsi_type': 'TextValue',
          'value': 'SYSTEM_DEFINED'
      }
  }]
  query = 'WHERE type = :creativeTemplateType'
  statement = dfp.FilterStatement(query, values)

  # Get creative templates by statement.
  while True:
    response = creative_template_service.getCreativeTemplatesByStatement(
        statement.ToStatement())
    if 'results' in response:
      # Display results.
      for template in response['results']:
        print ('Creative template with id \'%s\', name \'%s\', and type \'%s\' '
               'was found.' % (template['id'],
                               template['name'],
                               template['type']))
      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/creative_template_service/get_creative_templates_by_statement.py/main/original