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, product_id):
# Initialize appropriate service.
product_service = client.GetService('ProductService', version='v201711')
# Create query.
statement = (dfp.StatementBuilder()
.Where('id = :id')
.WithBindVariable('id', long(product_id))
.Limit(1))
products_published = 0
# Get products by statement.
while True:
response = product_service.getProductsByStatement(
statement.ToStatement())
if 'results' in response:
for product in response['results']:
print ('Product with id "%s" and name "%s" will be '
'published.' % (product['id'],
product['name']))
def main(client, order_id):
# Initialize appropriate service.
line_item_service = client.GetService('LineItemService', version='v201802')
# Create statement object to only select line items with even delivery rates.
statement = (dfp.StatementBuilder()
.Where(('deliveryRateType = :deliveryRateType AND '
'orderId = :orderId'))
.WithBindVariable('orderId', long(order_id))
.WithBindVariable('deliveryRateType', 'EVENLY')
.Limit(500))
# Get line items by statement.
response = line_item_service.getLineItemsByStatement(
statement.ToStatement())
if 'results' in response and len(response['results']):
# Update each local line item by changing its delivery rate type.
updated_line_items = []
for line_item in response['results']:
if not line_item['isArchived']:
line_item['deliveryRateType'] = 'AS_FAST_AS_POSSIBLE'
def main(client, proposal_id):
# Initialize appropriate service.
workflow_request_service = client.GetService('WorkflowRequestService',
version='v201711')
# Create a filter statement.
statement = (dfp.StatementBuilder()
.Where(('entityId = :entityId and entityType = :entityType '
'and type = :type'))
.WithBindVariable('entityId', proposal_id)
.WithBindVariable('entityType', 'PROPOSAL')
.WithBindVariable('type', 'WORKFLOW_APPROVAL_REQUEST'))
workflow_approval_requests_approved = 0
# Get workflow approval requests by statement.
while True:
response = workflow_request_service.getWorkflowRequestsByStatement(
statement.ToStatement())
if 'results' in response and len(response['results']):
# Display results.
for workflow_approval_request in response['results']:
print ('Workflow approval request with id "%s" will be'
' approved.' % workflow_approval_request['id'])
def main(client):
# Initialize appropriate service.
reconciliation_line_item_report_service = (client.GetService(
'ReconciliationLineItemReportService', version='v201711'))
# Create a statement to select reconciliation line item reports.
statement = (dfp.StatementBuilder()
.Where(('reconciliationReportId = :reconciliationReportId AND '
'lineItemId != :lineItemId'))
.OrderBy('lineItemId', ascending=True)
.WithBindVariable('reconciliationReportId',
RECONCILIATION_REPORT_ID)
.WithBindVariable('lineItemId', 0))
# Retrieve a small amount of reconciliation line item reports at a time,
# paging through until all reconciliation line item reports have been
# retrieved.
result_set_size = 0
should_continue = True
while should_continue:
page = (reconciliation_line_item_report_service
.getReconciliationLineItemReportsByStatement(
def main(client):
# Initialize appropriate service.
custom_field_service = client.GetService(
'CustomFieldService', version='v201802')
# Create a statement to select custom fields.
statement = (dfp.StatementBuilder()
.Where('entityType = :entityType')
.WithBindVariable('entityType', 'LINE_ITEM'))
# Retrieve a small amount of custom fields at a time, paging
# through until all custom fields have been retrieved.
while True:
response = custom_field_service.getCustomFieldsByStatement(
statement.ToStatement())
if 'results' in response and len(response['results']):
for custom_field in response['results']:
# Print out some information for each custom field.
print('Custom field with ID "%d" and name "%s" was found.\n' %
(custom_field['id'], custom_field['name']))
statement.offset += statement.limit
else:
break
def main(client):
# Initialize appropriate service.
premium_rate_service = client.GetService(
'PremiumRateService', version='v201805')
# Create a statement to select premium rates.
statement = dfp.StatementBuilder()
# Retrieve a small amount of premium rates at a time, paging
# through until all premium rates have been retrieved.
while True:
response = premium_rate_service.getPremiumRatesByStatement(
statement.ToStatement())
if 'results' in response and len(response['results']):
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
def main(client):
# Initialize appropriate service.
audience_segment_service = client.GetService(
'AudienceSegmentService', version='v201805')
# Create a statement to select audience segments.
statement = (dfp.StatementBuilder()
.Where('type = :type')
.WithBindVariable('type', 'FIRST_PARTY'))
# Retrieve a small amount of audience segments at a time, paging
# through until all audience segments have been retrieved.
while True:
response = audience_segment_service.getAudienceSegmentsByStatement(
statement.ToStatement())
if 'results' in response and len(response['results']):
for audience_segment in response['results']:
# Print out some information for each audience segment.
print('Audience segment with ID "%d", name "%s", and size "%d" was '
'found.\n' % (audience_segment['id'], audience_segment['name'],
audience_segment['size']))
statement.offset += statement.limit
else:
def main(client):
# Initialize appropriate service.
user_team_association_service = client.GetService(
'UserTeamAssociationService', version='v201705')
# Create a statement to select user team associations.
statement = dfp.StatementBuilder()
# Retrieve a small amount of user team associations at a time, paging
# through until all user team associations have been retrieved.
while True:
response = user_team_association_service.getUserTeamAssociationsByStatement(
statement.ToStatement())
if 'results' in response:
for user_team_association in response['results']:
# Print out some information for each user team association.
print('User team association with team id "%d" and user id "%d" was '
'found.\n' % (user_team_association['teamId'],
user_team_association['userId']))
statement.offset += statement.limit
else:
break
def main(client, user_id):
# Initialize appropriate service.
user_team_association_service = client.GetService(
'UserTeamAssociationService', version='v201802')
# Create filter text to select user team associations by the user ID.
statement = (dfp.StatementBuilder()
.Where('userId = :userId')
.WithBindVariable('userId', long(user_id)))
# Get user team associations by statement.
response = user_team_association_service.getUserTeamAssociationsByStatement(
statement.ToStatement())
if 'results' in response and len(response['results']):
updated_user_team_associations = []
# Update each local user team association to read only access.
for user_team_association in response['results']:
user_team_association['overriddenTeamAccessType'] = 'READ_ONLY'
updated_user_team_associations.append(user_team_association)
# Update user team associations on the server.
user_team_associations = (
def main(client):
# Initialize appropriate service.
rate_card_service = client.GetService('RateCardService', version='v201805')
# Create a statement to select rate cards.
statement = (dfp.StatementBuilder()
.Where('forMarketplace = :forMarketplace')
.WithBindVariable('forMarketplace', True))
# Retrieve a small amount of rate cards at a time, paging
# through until all rate cards have been retrieved.
while True:
response = rate_card_service.getRateCardsByStatement(statement.ToStatement(
))
if 'results' in response and len(response['results']):
for rate_card in response['results']:
# Print out some information for each rate card.
print(
'Rate card with ID "%d", name "%s", and currency code "%s" was '
'found.\n'
% (rate_card['id'], rate_card['name'], rate_card['currencyCode']))
statement.offset += statement.limit