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

  # Create query.
  values = [{
      'key': 'today',
      'value': {
          'xsi_type': 'TextValue',
          'value': datetime.date.today().strftime('%Y-%m-%dT%H:%M:%S')
      }
  }]
  query = ('WHERE status in (\'DRAFT\', \'PENDING_APPROVAL\')'
           ' AND endDateTime >= :today AND isArchived = FALSE')

  # Create a filter statement.
  statement = dfp.FilterStatement(query, values)
  orders_approved = 0

  # Get orders by statement.
  while True:
    response = order_service.getOrdersByStatement(statement.ToStatement())
    if 'results' in response:
      # Display results.
      for order in response['results']:
        print ('Order with id \'%s\', name \'%s\', and status \'%s\' will be '
               'approved.' % (order['id'], order['name'], order['status']))
      # Perform action.
      result = order_service.performOrderAction(
          {'xsi_type': 'ApproveOrders'}, statement.ToStatement())
      if result and int(result['numChanges']) > 0:
        orders_approved += int(result['numChanges'])
      statement.offset += dfp.SUGGESTED_PAGE_LIMIT
    else:
      break

  # Display results.
  if orders_approved > 0:
    print 'Number of orders approved: %s' % orders_approved
  else:
    print 'No orders were approved.'
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201508/order_service/approve_orders.py/main/original