Skip to content

Commit e8c9664

Browse files
committed
Committing latest changes.
1 parent 18c083c commit e8c9664

File tree

262 files changed

+3169
-1607
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

262 files changed

+3169
-1607
lines changed

ChangeLog

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,11 @@
1+
9.0.0 -- 11/14/17
2+
* Added support and examples for DFP v201711
3+
* Removed support and examples for DFP v201611
4+
* DFP PQL queries can now accept simple python dicts for variable substitution.
5+
* Resolved issues:
6+
- Issue 230: https://github.com/googleads/googleads-python-lib/issues/230
7+
8+
19
8.1.0 -- 10/11/17
210
* Added support for AdWords v201710.
311
* Resolved issues:

examples/adwords/v201708/reporting/download_criteria_report_as_stream_with_awql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ def main(client):
4747
report_downloader = client.GetReportDownloader(version='v201708')
4848

4949
# Create report query.
50-
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
51-
'FinalUrls, Impressions, Clicks, Cost '
52-
'FROM CRITERIA_PERFORMANCE_REPORT '
53-
'WHERE Status IN [ENABLED, PAUSED] '
54-
'DURING LAST_7_DAYS')
50+
report_query = (adwords.ReportQueryBuilder()
51+
.Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',
52+
'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',
53+
'Cost')
54+
.From('CRITERIA_PERFORMANCE_REPORT')
55+
.Where('Status').In('ENABLED', 'PAUSED')
56+
.During('LAST_7_DAYS')
57+
.Build())
5558

5659
print report_downloader.DownloadReportAsStringWithAwql(
5760
report_query, 'CSV', skip_report_header=False, skip_column_header=False,

examples/adwords/v201708/reporting/download_criteria_report_as_string_with_awql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ def main(client):
3737
report_downloader = client.GetReportDownloader(version='v201708')
3838

3939
# Create report query.
40-
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
41-
'FinalUrls, Impressions, Clicks, Cost '
42-
'FROM CRITERIA_PERFORMANCE_REPORT '
43-
'WHERE Status IN [ENABLED, PAUSED] '
44-
'DURING LAST_7_DAYS')
40+
report_query = (adwords.ReportQueryBuilder()
41+
.Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',
42+
'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',
43+
'Cost')
44+
.From('CRITERIA_PERFORMANCE_REPORT')
45+
.Where('Status').In('ENABLED', 'PAUSED')
46+
.During('LAST_7_DAYS')
47+
.Build())
4548

4649
print report_downloader.DownloadReportAsStringWithAwql(
4750
report_query, 'CSV', skip_report_header=False, skip_column_header=False,

examples/adwords/v201708/reporting/download_criteria_report_with_awql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ def main(client):
3434
report_downloader = client.GetReportDownloader(version='v201708')
3535

3636
# Create report query.
37-
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
38-
'FinalUrls, Impressions, Clicks, Cost '
39-
'FROM CRITERIA_PERFORMANCE_REPORT '
40-
'WHERE Status IN [ENABLED, PAUSED] '
41-
'DURING LAST_7_DAYS')
37+
report_query = (adwords.ReportQueryBuilder()
38+
.Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',
39+
'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',
40+
'Cost')
41+
.From('CRITERIA_PERFORMANCE_REPORT')
42+
.Where('Status').In('ENABLED', 'PAUSED')
43+
.During('LAST_7_DAYS')
44+
.Build())
4245

4346
# You can provide a file object to write the output to. For this
4447
# demonstration we use sys.stdout to write the report to the screen.

examples/adwords/v201710/basic_operations/get_campaigns_with_awql.py

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -38,13 +38,14 @@ def main(client):
3838
campaign_service = client.GetService('CampaignService', version='v201710')
3939

4040
# Construct query and get all campaigns.
41-
offset = 0
42-
query = 'SELECT Id, Name, Status ORDER BY Name'
43-
44-
more_pages = True
45-
while more_pages:
46-
page = campaign_service.query(query + ' LIMIT %s, %s' % (offset, PAGE_SIZE))
47-
41+
query = (adwords.ServiceQueryBuilder()
42+
.Select('Id', 'Name', 'Status')
43+
.Where('Status').EqualTo('ENABLED')
44+
.OrderBy('Name')
45+
.Limit(0, PAGE_SIZE)
46+
.Build())
47+
48+
for page in query.Pager(campaign_service):
4849
# Display results.
4950
if 'entries' in page:
5051
for campaign in page['entries']:
@@ -53,8 +54,6 @@ def main(client):
5354
campaign['status']))
5455
else:
5556
print 'No campaigns were found.'
56-
offset += PAGE_SIZE
57-
more_pages = offset < int(page['totalNumEntries'])
5857
time.sleep(1)
5958

6059

examples/adwords/v201710/campaign_management/get_all_disapproved_ads_with_awql.py

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -38,17 +38,18 @@ def main(client, ad_group_id):
3838
version='v201710')
3939

4040
# Construct query and get all ads for a given campaign.
41-
query = ('SELECT Id, PolicySummary '
42-
'WHERE AdGroupId = %s AND CombinedApprovalStatus = DISAPPROVED '
43-
'ORDER BY Id' % ad_group_id)
44-
more_pages = True
41+
query = (adwords.ServiceQueryBuilder()
42+
.Select('Id', 'PolicySummary')
43+
.Where('AdGroupId').EqualTo(ad_group_id)
44+
.Where('CombinedApprovalStatus').EqualTo('DISAPPROVED')
45+
.OrderBy('Id')
46+
.Limit(0, PAGE_SIZE)
47+
.Build())
4548
disapproved_count = 0
46-
offset = 0
4749

4850
# Display results.
49-
while more_pages:
50-
page = ad_group_ad_service.query(query + ' LIMIT %s, %s' % (
51-
offset, PAGE_SIZE))
51+
while True:
52+
page = ad_group_ad_service.query(query)
5253

5354
if 'entries' in page:
5455
for ad in page['entries']:
@@ -63,8 +64,8 @@ def main(client, ad_group_id):
6364
policy_topic_entry['policyTopicId'],
6465
policy_topic_entry['policyTopicName'])
6566
# Display the attributes and values that triggered the policy topic.
66-
policy_topic_evidences = policy_topic_entry['policyTopicEvidences']
67-
if policy_topic_evidences:
67+
if ('policyTopicEvidences' in policy_topic_entry
68+
and policy_topic_entry['policyTopicEvidences']):
6869
for evidence in policy_topic_entry['policyTopicEvidences']:
6970
print (' evidence type: %s'
7071
% evidence['policyTopicEvidenceType'])
@@ -73,8 +74,9 @@ def main(client, ad_group_id):
7374
for index, evidence_text in enumerate(evidence_text_list):
7475
print ' evidence text[%d]: %s' % (index, evidence_text)
7576

76-
offset += PAGE_SIZE
77-
more_pages = offset < int(page['totalNumEntries'])
77+
if not query.HasNext(page):
78+
break
79+
query.NextPage()
7880

7981
print '%d disapproved ads were found.' % disapproved_count
8082

examples/adwords/v201710/migration/migrate_to_extension_settings.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
'TRACKING_URL_TEMPLATE': 7
5353
}
5454

55-
5655
PAGE_SIZE = 500
5756

5857

examples/adwords/v201710/reporting/download_criteria_report_as_stream_with_awql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -47,11 +47,14 @@ def main(client):
4747
report_downloader = client.GetReportDownloader(version='v201710')
4848

4949
# Create report query.
50-
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
51-
'FinalUrls, Impressions, Clicks, Cost '
52-
'FROM CRITERIA_PERFORMANCE_REPORT '
53-
'WHERE Status IN [ENABLED, PAUSED] '
54-
'DURING LAST_7_DAYS')
50+
report_query = (adwords.ReportQueryBuilder()
51+
.Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',
52+
'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',
53+
'Cost')
54+
.From('CRITERIA_PERFORMANCE_REPORT')
55+
.Where('Status').In('ENABLED', 'PAUSED')
56+
.During('LAST_7_DAYS')
57+
.Build())
5558

5659
print report_downloader.DownloadReportAsStringWithAwql(
5760
report_query, 'CSV', skip_report_header=False, skip_column_header=False,

examples/adwords/v201710/reporting/download_criteria_report_as_string_with_awql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -37,11 +37,14 @@ def main(client):
3737
report_downloader = client.GetReportDownloader(version='v201710')
3838

3939
# Create report query.
40-
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
41-
'FinalUrls, Impressions, Clicks, Cost '
42-
'FROM CRITERIA_PERFORMANCE_REPORT '
43-
'WHERE Status IN [ENABLED, PAUSED] '
44-
'DURING LAST_7_DAYS')
40+
report_query = (adwords.ReportQueryBuilder()
41+
.Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',
42+
'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',
43+
'Cost')
44+
.From('CRITERIA_PERFORMANCE_REPORT')
45+
.Where('Status').In('ENABLED', 'PAUSED')
46+
.During('LAST_7_DAYS')
47+
.Build())
4548

4649
print report_downloader.DownloadReportAsStringWithAwql(
4750
report_query, 'CSV', skip_report_header=False, skip_column_header=False,

examples/adwords/v201710/reporting/download_criteria_report_with_awql.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -34,11 +34,14 @@ def main(client):
3434
report_downloader = client.GetReportDownloader(version='v201710')
3535

3636
# Create report query.
37-
report_query = ('SELECT CampaignId, AdGroupId, Id, Criteria, CriteriaType, '
38-
'FinalUrls, Impressions, Clicks, Cost '
39-
'FROM CRITERIA_PERFORMANCE_REPORT '
40-
'WHERE Status IN [ENABLED, PAUSED] '
41-
'DURING LAST_7_DAYS')
37+
report_query = (adwords.ReportQueryBuilder()
38+
.Select('CampaignId', 'AdGroupId', 'Id', 'Criteria',
39+
'CriteriaType', 'FinalUrls', 'Impressions', 'Clicks',
40+
'Cost')
41+
.From('CRITERIA_PERFORMANCE_REPORT')
42+
.Where('Status').In('ENABLED', 'PAUSED')
43+
.During('LAST_7_DAYS')
44+
.Build())
4245

4346
# You can provide a file object to write the output to. For this
4447
# demonstration we use sys.stdout to write the report to the screen.

0 commit comments

Comments
 (0)