def main(client, product_template_id):
  # Initialize appropriate service.
  product_template_service = client.GetService(
      'ProductTemplateService', version='v201511')

  # Create query.
  values = [{
      'key': 'id',
      'value': {
          'xsi_type': 'NumberValue',
          'value': product_template_id
      }
  }]
  query = 'WHERE id = :id'
  statement = dfp.FilterStatement(query, values, 1)

  product_templates_activated = 0

  # Get product_templates by statement.
  while True:
    response = product_template_service.getProductTemplatesByStatement(
        statement.ToStatement())
    if 'results' in response:
      for product_template in response['results']:
        print ('Product template with id \'%s\' and name \'%s\' will be '
               'activated.' % (product_template['id'],
                               product_template['name']))

      # Perform action.
      result = product_template_service.performProductTemplateAction(
          {'xsi_type': 'ActivateProductTemplates'}, statement.ToStatement())
      if result and int(result['numChanges']) > 0:
        product_templates_activated += int(result['numChanges'])
      statement.offset += dfp.SUGGESTED_PAGE_LIMIT
    else:
      break

  # Display results.
  if product_templates_activated > 0:
    print ('Number of product templates '
           'activated: %s' % product_templates_activated)
  else:
    print 'No product templates were activated.'
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201511/product_template_service/activate_product_templates.py/main/original