How to use the googleads.ad_manager 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 / ad_manager / v201811 / report_service / run_saved_query.py View on Github external
def main(client, saved_query_id):
  # Initialize appropriate service.
  report_service = client.GetService('ReportService', version='v201811')

  # Initialize a DataDownloader.
  report_downloader = client.GetDataDownloader(version='v201811')

  # Create statement object to filter for an order.
  statement = (ad_manager.StatementBuilder(version='v201811')
               .Where('id = :id')
               .WithBindVariable('id', int(saved_query_id))
               .Limit(1))

  response = report_service.getSavedQueriesByStatement(
      statement.ToStatement())

  if 'results' in response and len(response['results']):
    saved_query = response['results'][0]

    if saved_query['isCompatibleWithApiVersion']:
      report_job = {}

      # Set report query and optionally modify it.
      report_job['reportQuery'] = saved_query['reportQuery']
github googleads / googleads-python-lib / examples / ad_manager / v201905 / proposal_line_item_service / create_programmatic_proposal_line_items_for_non_sales_management.py View on Github external
# Add proposal line items.
  proposal_line_items = proposal_line_item_service.createProposalLineItems(
      [proposal_line_item])

  # Display results.
  for proposal_line_item in proposal_line_items:
    print('Programmatic proposal line item for non-sales management with id '
          '"%s", belonging to proposal id "%s", and named "%s" '
          'was created.' % (proposal_line_item['id'],
                            proposal_line_item['proposalId'],
                            proposal_line_item['name']))


if __name__ == '__main__':
  # Initialize client object.
  ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
  main(ad_manager_client, PROPOSAL_ID, PRODUCT_ID)
github googleads / googleads-python-lib / examples / ad_manager / v201808 / product_template_service / get_all_product_templates.py View on Github external
statement.ToStatement())
    if 'results' in response and len(response['results']):
      for product_template in response['results']:
        # Print out some information for each product template.
        print('Product template with ID "%d" and name "%s" was found.\n' %
              (product_template['id'], product_template['name']))
      statement.offset += statement.limit
    else:
      break

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


if __name__ == '__main__':
  # Initialize client object.
  ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
  main(ad_manager_client)
github googleads / googleads-python-lib / examples / ad_manager / v201908 / user_service / update_users.py View on Github external
users = response['results']
    for user in users:
      user['name'] += ' Sr.'

    # Update users on server.
    users = user_service.updateUsers(users)
    for user in users:
      print('User with id "%s" and name "%s" was updated.'
            % (user['id'], user['name']))
  else:
    print('No users found to update.')


if __name__ == '__main__':
  # Initialize client object.
  ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
  main(ad_manager_client, USER_ID)
github googleads / googleads-python-lib / examples / ad_manager / v201908 / label_service / get_active_labels.py View on Github external
response = label_service.getLabelsByStatement(statement.ToStatement())
    if 'results' in response and len(response['results']):
      for label in response['results']:
        # Print out some information for each label.
        print('Label with ID "%d" and name "%s" was found.\n' % (label['id'],
                                                                 label['name']))
      statement.offset += statement.limit
    else:
      break

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


if __name__ == '__main__':
  # Initialize client object.
  ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
  main(ad_manager_client)
github googleads / googleads-python-lib / examples / ad_manager / v201908 / activity_group_service / get_all_activity_groups.py View on Github external
statement.ToStatement())
    if 'results' in response and len(response['results']):
      for activity_group in response['results']:
        # Print out some information for each activity group.
        print('Activity group with ID "%d" and name "%s" was found.\n' %
              (activity_group['id'], activity_group['name']))
      statement.offset += statement.limit
    else:
      break

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


if __name__ == '__main__':
  # Initialize client object.
  ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
  main(ad_manager_client)
github googleads / googleads-python-lib / examples / ad_manager / v201808 / user_service / update_users.py View on Github external
def main(client, user_id):
  # Initialize appropriate service.
  user_service = client.GetService('UserService', version='v201808')

  # Create query.
  statement = (ad_manager.StatementBuilder(version='v201808')
               .Where('id = :userId')
               .WithBindVariable('userId', long(user_id)))

  # Get users by statement.
  response = user_service.getUsersByStatement(statement.ToStatement())

  if 'results' in response and len(response['results']):
    users = response['results']
    for user in users:
      user['name'] += ' Sr.'

    # Update users on server.
    users = user_service.updateUsers(users)
    for user in users:
      print ('User with id "%s" and name "%s" was updated.'
             % (user['id'], user['name']))
github googleads / googleads-python-lib / examples / ad_manager / v201905 / reconciliation_report_service / get_all_reconciliation_reports.py View on Github external
def main(client):
  # Initialize appropriate service.
  reconciliation_report_service = client.GetService(
      'ReconciliationReportService', version='v201905')

  # Create a statement to select reconciliation reports.
  statement = ad_manager.StatementBuilder(version='v201905')

  # Retrieve a small amount of reconciliation reports at a time, paging
  # through until all reconciliation reports have been retrieved.
  while True:
    response = (
        reconciliation_report_service
        .getReconciliationReportsByStatement(
            statement.ToStatement()))
    if 'results' in response and len(response['results']):
      for reconciliation_report in response['results']:
        # Print out some information for each reconciliation report.
        print(
            'Reconciliation report with ID "%d", month "%d", and year "%d" was'
            ' found.\n' % (reconciliation_report['id'],
                           reconciliation_report['startDate']['month'],
                           reconciliation_report['startDate']['year']))
github googleads / googleads-python-lib / examples / ad_manager / v201902 / user_service / get_all_users.py View on Github external
def main(client):
  # Initialize appropriate service.
  user_service = client.GetService('UserService', version='v201902')

  # Create a statement to select users.
  statement = ad_manager.StatementBuilder(version='v201902')

  # Retrieve a small amount of users at a time, paging
  # through until all users have been retrieved.
  while True:
    response = user_service.getUsersByStatement(statement.ToStatement())
    if 'results' in response and len(response['results']):
      for user in response['results']:
        # Print out some information for each user.
        print('User with ID "%d" and name "%s" was found.\n' % (user['id'],
                                                                user['name']))
      statement.offset += statement.limit
    else:
      break

  print('\nNumber of results found: %s' % response['totalResultSetSize'])
github googleads / googleads-python-lib / examples / ad_manager / v201902 / exchange_rate_service / get_exchange_rates_for_currency_code.py View on Github external
def main(client, currency_code):
  # Initialize appropriate service.
  exchange_rate_service = client.GetService(
      'ExchangeRateService', version='v201902')
  # Create a statement to select exchange rates.
  statement = (ad_manager.StatementBuilder(version='v201902')
               .Where('currencyCode = :currencyCode')
               .WithBindVariable('currencyCode', currency_code))

  # Retrieve a small amount of exchange rates at a time, paging
  # through until all exchange rates have been retrieved.
  while True:
    response = exchange_rate_service.getExchangeRatesByStatement(
        statement.ToStatement())
    if 'results' in response and len(response['results']):
      for exchange_rate in response['results']:
        # Print out some information for each exchange rate.
        print('Exchange rate with ID "%d", currency code "%s", and exchange '
              'rate "%.2f" was found.\n' %
              (exchange_rate['id'], exchange_rate['currencyCode'],
               float(exchange_rate['exchangeRate'] / 1000000)))
      statement.offset += statement.limit