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

  # Create statement object to select a single proposal by an ID.
  values = [{
      'key': 'status',
      'value': {
          'xsi_type': 'TextValue',
          'value': 'PENDING_APPROVAL'
      }
  }]
  query = 'WHERE status = :status ORDER BY id ASC'

  statement = dfp.FilterStatement(query, values)

  # Get proposals by statement.
  while True:
    response = proposal_service.getProposalsByStatement(statement.ToStatement())
    if 'results' in response:
      # Display results.
      for proposal in response['results']:
        print ('Proposal with id \'%s\' name \'%s\' was found.'
               % (proposal['id'], proposal['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/proposal_service/get_proposals_by_statement.py/main/original