Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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']
# 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)
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)
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)
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)
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)
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']))
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']))
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'])
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