def main(client, order_id):
  # Initialize appropriate service.
  line_item_service = client.GetService('LineItemService', version='v201511')

  # Create query.
  values = [{
      'key': 'orderId',
      'value': {
          'xsi_type': 'NumberValue',
          'value': order_id
      }
  }, {
      'key': 'status',
      'value': {
          'xsi_type': 'TextValue',
          'value': 'NEEDS_CREATIVES'
      }
  }]
  query = 'WHERE orderId = :orderId AND status = :status'
  statement = dfp.FilterStatement(query, values)

  line_items_activated = 0

  # Get line items by statement.
  while True:
    response = line_item_service.getLineItemsByStatement(
        statement.ToStatement())
    if 'results' in response:
      for line_item in response['results']:
        print ('Line item with id \'%s\', belonging to order id \'%s\', and '
               'name \'%s\' will be activated.' %
               (line_item['id'], line_item['orderId'], line_item['name']))

      # Perform action.
      result = line_item_service.performLineItemAction(
          {'xsi_type': 'ActivateLineItems'}, statement.ToStatement())
      if result and int(result['numChanges']) > 0:
        line_items_activated += int(result['numChanges'])
      statement.offset += dfp.SUGGESTED_PAGE_LIMIT
    else:
      break

  # Display results.
  if line_items_activated > 0:
    print 'Number of line items activated: %s' % line_items_activated
  else:
    print 'No line items were activated.'
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201511/line_item_service/activate_line_items.py/main/original