How to use the googleads.dfp.DfpClient function in googleads

To help you get started, we’ve selected a few googleads examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github googleads / googleads-python-lib / examples / dfp / v201805 / proposal_service / create_programmatic_proposals_for_non_sales_management.py View on Github external
'type': 'ADVERTISER',
          'companyId': advertiser_id
      },
  }

  proposals = proposal_service.createProposals([proposal])

  # Display results.
  for proposal in proposals:
    print('Programmatic proposal with id "%s" and name "%s" was created.' %
          (proposal['id'], proposal['name']))


if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client, PROGRAMMATIC_BUYER_ID, PRIMARY_SALESPERSON_ID,
       PRIMARY_TRAFFICKER_ID, ADVERTISER_ID)
github googleads / googleads-python-lib / examples / dfp / v201705 / team_service / update_teams.py View on Github external
team['description'] = 'this team is great!'
      updated_teams.append(team)

    # Update teams on the server.
    teams = team_service.updateTeams(updated_teams)

    # Display results.
    for team in teams:
      print ('Team with id "%s" and name "%s" was updated.'
             % (team['id'], team['name']))
  else:
    print 'No teams found to update.'

if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client, TEAM_ID)
github googleads / googleads-python-lib / examples / dfp / v201802 / team_service / create_teams.py View on Github external
'hasAllInventory': 'false',
        'teamAccessType': 'READ_WRITE'
    }
    teams.append(team)

  # Add Teams.
  teams = team_service.createTeams(teams)

  # Display results.
  for team in teams:
    print ('Team with ID "%s" and name "%s" was created.'
           % (team['id'], team['name']))

if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client)
github googleads / googleads-python-lib / examples / dfp / v201511 / creative_service / update_creatives.py View on Github external
creative['destinationUrl'] = 'http://news.google.com'
      updated_creatives.append(creative)

    # Update creatives remotely.
    creatives = creative_service.updateCreatives(updated_creatives)

    # Display results.
    for creative in creatives:
      print ('Image creative with id \'%s\' and destination URL \'%s\' was '
             'updated.' % (creative['id'], creative['destinationUrl']))
  else:
    print 'No creatives found to update.'

if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client, IMAGE_CREATIVE_ID)
github googleads / googleads-python-lib / examples / dfp / v201511 / order_service / approve_orders.py View on Github external
{'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.'

if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client)
github googleads / googleads-python-lib / examples / dfp / v201802 / proposal_line_item_service / get_all_proposal_line_items.py View on Github external
statement.ToStatement())
    if 'results' in response and len(response['results']):
      for proposal_line_item in response['results']:
        # Print out some information for each proposal line item.
        print('Proposal line item with ID "%d" and name "%s" was found.\n' %
              (proposal_line_item['id'], proposal_line_item['name']))
      statement.offset += statement.limit
    else:
      break

  print '\nNumber of results found: %s' % response['totalResultSetSize']


if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client)
github googleads / googleads-python-lib / examples / dfp / v201705 / line_item_service / create_video_line_item.py View on Github external
'creativeRotationType': 'OPTIMIZED',
      'discountType': 'PERCENTAGE',
      'allowOverbook': 'true'
  }

  # Add line item.
  line_item = line_item_service.createLineItem(line_item)

  # Display results.
  print ('Video line item with id "%s", belonging to order id "%s", and '
         'named "%s" was created.' % (line_item['id'], line_item['orderId'],
                                      line_item['name']))

if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client, ORDER_ID, TARGETED_VIDEO_AD_UNIT_ID,
       CONTENT_CUSTOM_TARGETING_VALUE_ID)
github googleads / googleads-python-lib / examples / dfp / v201805 / exchange_rate_service / get_all_exchange_rates.py View on Github external
# Print out some information for each exchange rate.
        print(
            'Exchange rate with ID "%d", currency code "%s", direction "%s",  '
            'and exchange rate "%d" was found.\n' %
            (exchange_rate['id'], exchange_rate['currencyCode'],
             exchange_rate['direction'], exchange_rate['exchangeRate']))
      statement.offset += statement.limit
    else:
      break

  print '\nNumber of results found: %s' % response['totalResultSetSize']


if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client)
github googleads / googleads-python-lib / examples / dfp / v201805 / report_service / run_delivery_report.py View on Github external
report_file = tempfile.NamedTemporaryFile(suffix='.csv.gz', delete=False)

  # Download report data.
  report_downloader.DownloadReportToFile(
      report_job_id, export_format, report_file)

  report_file.close()

  # Display results.
  print 'Report job with id "%s" downloaded to:\n%s' % (
      report_job_id, report_file.name)

if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client, ORDER_ID)
github googleads / googleads-python-lib / examples / dfp / v201705 / premium_rate_service / get_all_premium_rates.py View on Github external
for premium_rate in response['results']:
        # Print out some information for each premium rate.
        print('Premium rate with ID "%d", premium feature "%s", and rate card '
              'id "%d" was found.\n' % (premium_rate['id'],
                                        dfp.DfpClassType(premium_rate),
                                        premium_rate['rateCardId']))
      statement.offset += statement.limit
    else:
      break

  print '\nNumber of results found: %s' % response['totalResultSetSize']


if __name__ == '__main__':
  # Initialize client object.
  dfp_client = dfp.DfpClient.LoadFromStorage()
  main(dfp_client)