Skip to content

Commit ce296d7

Browse files
committed
Adding support for DFP v201405, fixing App Engine bugs.
1 parent 433e00b commit ce296d7

File tree

161 files changed

+10020
-37
lines changed

Some content is hidden

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

161 files changed

+10020
-37
lines changed

ChangeLog

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,9 @@
1+
1.0.6 - 05/29/2014
2+
==================
3+
* Add support for v201405 for DFP client library.
4+
15
1.0.5 - 05/07/2014
6+
==================
27
* Fixed an issue where PQL fields weren't encoding properly / not handling None
38
responses correctly. This resolves issue #9.
49
* Fixed an issue where the AdWords ReportDownloader would fail when downloading
@@ -8,6 +13,7 @@
813
retrieving the WSDL.
914

1015
1.0.4 - 04/22/2014
16+
==================
1117
* Fixed a bug where https_proxy wasn't set for retrieving the API WSDL. This
1218
resolves issue #5.
1319

examples/adwords/authentication/generate_refresh_token.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
# See the License for the specific language governing permissions and
1515
# limitations under the License.
1616

17-
"""Generates a refresh token for use with AdWords."""
17+
"""Generates refresh token for AdWords using the Installed Application flow."""
1818

1919
__author__ = 'Joseph DiLallo'
2020

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
Lines changed: 74 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,74 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This code example creates new activity groups.
18+
19+
To determine which activity groups exist, run get_all_activity_groups.py.
20+
21+
The LoadFromStorage method is pulling credentials and properties from a
22+
"googleads.yaml" file. By default, it looks for this file in your home
23+
directory. For more information, see the "Caching authentication information"
24+
section of our README.
25+
26+
Tags: ActivityGroupService.createActivityGroups
27+
"""
28+
29+
__author__ = ('Vincent Tsao',
30+
'Joseph DiLallo')
31+
32+
import uuid
33+
34+
# Import appropriate modules from the client library.
35+
from googleads import dfp
36+
37+
# Set the ID of the advertiser company this activity group is associated with.
38+
ADVERTISER_COMPANY_ID = 'INSERT_ADVERTISER_COMPANY_ID_HERE'
39+
40+
41+
def main(client, advertiser_company_id):
42+
# Initialize appropriate service.
43+
activity_group_service = client.GetService('ActivityGroupService',
44+
version='v201405')
45+
46+
# Create a short-term activity group.
47+
short_term_activity_group = {
48+
'name': 'Short-term activity group #%s' % uuid.uuid4(),
49+
'companyIds': [advertiser_company_id],
50+
'clicksLookback': '1',
51+
'impressionsLookback': '1'
52+
}
53+
54+
# Create a long-term activity group.
55+
long_term_activity_group = {
56+
'name': 'Long-term activity group #%s' % uuid.uuid4(),
57+
'companyIds': [advertiser_company_id],
58+
'clicksLookback': '30',
59+
'impressionsLookback': '30'
60+
}
61+
62+
# Create the activity groups on the server.
63+
activity_groups = activity_group_service.createActivityGroups([
64+
short_term_activity_group, long_term_activity_group])
65+
66+
# Display results.
67+
for activity_group in activity_groups:
68+
print ('Activity group with ID \'%s\' and name \'%s\' was created.'
69+
% (activity_group['id'], activity_group['name']))
70+
71+
if __name__ == '__main__':
72+
# Initialize client object.
73+
dfp_client = dfp.DfpClient.LoadFromStorage()
74+
main(dfp_client, ADVERTISER_COMPANY_ID)
Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,72 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This code example gets all active activity groups.
18+
19+
To create activity groups, run create_activity_groups.py.
20+
21+
The LoadFromStorage method is pulling credentials and properties from a
22+
"googleads.yaml" file. By default, it looks for this file in your home
23+
directory. For more information, see the "Caching authentication information"
24+
section of our README.
25+
26+
Tags: ActivityGroupService.getActivityGroupsByStatement
27+
"""
28+
29+
__author__ = ('Nicholas Chen',
30+
'Joseph DiLallo')
31+
32+
# Import appropriate modules from the client library.
33+
from googleads import dfp
34+
35+
36+
def main(client):
37+
# Initialize appropriate service.
38+
activity_group_service = client.GetService('ActivityGroupService',
39+
version='v201405')
40+
41+
# Create statement object to only select active activity groups.
42+
values = [{
43+
'key': 'status',
44+
'value': {
45+
'xsi_type': 'TextValue',
46+
'value': 'ACTIVE'
47+
}
48+
}]
49+
query = 'WHERE status = :status'
50+
51+
# Create a filter statement.
52+
statement = dfp.FilterStatement(query, values)
53+
54+
# Get activity groups by statement.
55+
while True:
56+
response = activity_group_service.getActivityGroupsByStatement(
57+
statement.ToStatement())
58+
if 'results' in response:
59+
# Display results.
60+
for activity_group in response['results']:
61+
print ('Activity group with ID \'%s\' and name \'%s\' was found.'
62+
% (activity_group['id'], activity_group['name']))
63+
statement.offset += dfp.SUGGESTED_PAGE_LIMIT
64+
else:
65+
break
66+
67+
print '\nNumber of results found: %s' % response['totalResultSetSize']
68+
69+
if __name__ == '__main__':
70+
# Initialize client object.
71+
dfp_client = dfp.DfpClient.LoadFromStorage()
72+
main(dfp_client)
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This code example gets all activity groups.
18+
19+
To create activity groups, run create_activity_groups.py.
20+
21+
The LoadFromStorage method is pulling credentials and properties from a
22+
"googleads.yaml" file. By default, it looks for this file in your home
23+
directory. For more information, see the "Caching authentication information"
24+
section of our README.
25+
26+
Tags: ActivityGroupService.getActivityGroupsByStatement
27+
"""
28+
29+
__author__ = ('Nicholas Chen',
30+
'Joseph DiLallo')
31+
32+
# Import appropriate modules from the client library.
33+
from googleads import dfp
34+
35+
36+
def main(client):
37+
# Initialize appropriate service.
38+
activity_group_service = client.GetService('ActivityGroupService',
39+
version='v201405')
40+
41+
# Create a filter statement.
42+
statement = dfp.FilterStatement()
43+
44+
# Get activity groups by statement.
45+
while True:
46+
response = activity_group_service.getActivityGroupsByStatement(
47+
statement.ToStatement())
48+
if 'results' in response:
49+
# Display results.
50+
for activity_group in response['results']:
51+
print ('Activity group with ID \'%s\' and name \'%s\' was found.'
52+
% (activity_group['id'], activity_group['name']))
53+
statement.offset += dfp.SUGGESTED_PAGE_LIMIT
54+
else:
55+
break
56+
57+
print '\nNumber of results found: %s' % response['totalResultSetSize']
58+
59+
60+
if __name__ == '__main__':
61+
# Initialize client object.
62+
dfp_client = dfp.DfpClient.LoadFromStorage()
63+
main(dfp_client)
Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
"""This code example updates activity groups.
18+
19+
To determine which activity groups exist, run get_all_activity_groups.py.
20+
21+
The LoadFromStorage method is pulling credentials and properties from a
22+
"googleads.yaml" file. By default, it looks for this file in your home
23+
directory. For more information, see the "Caching authentication information"
24+
section of our README.
25+
26+
Tags: ActivityGroupService.getActivityGroup
27+
Tags: ActivityGroupService.updateActivityGroups
28+
"""
29+
30+
__author__ = ('Nicholas Chen',
31+
'Joseph DiLallo')
32+
33+
# Import appropriate modules from the client library.
34+
from googleads import dfp
35+
36+
# Set the ID of the activity group and the company to update it with.
37+
ACTIVITY_GROUP_ID = 'INSERT_ACTIVITY_GROUP_ID_HERE'
38+
ADVERTISER_COMPANY_ID = 'INSERT_ADVERTISER_COMPANY_ID_HERE'
39+
40+
41+
def main(client, activity_group_id, advertiser_company_id):
42+
# Initialize appropriate service.
43+
activity_group_service = client.GetService('ActivityGroupService',
44+
version='v201405')
45+
46+
# Create statement object to select a single activity groups by ID.
47+
values = [{
48+
'key': 'activityGroupId',
49+
'value': {
50+
'xsi_type': 'NumberValue',
51+
'value': activity_group_id
52+
}
53+
}]
54+
query = 'WHERE id = :activityGroupId'
55+
56+
# Create a filter statement.
57+
statement = dfp.FilterStatement(query, values, 1)
58+
59+
# Get activity groups by statement.
60+
response = activity_group_service.getActivityGroupsByStatement(
61+
statement.ToStatement())
62+
if 'results' in response:
63+
updated_activity_groups = []
64+
for activity_group in response['results']:
65+
activity_group['companyIds'].append(advertiser_company_id)
66+
updated_activity_groups.append(activity_group)
67+
# Update the activity groups on the server.
68+
activity_groups = activity_group_service.updateActivityGroups(
69+
updated_activity_groups)
70+
71+
for activity_group in activity_groups:
72+
print (('Activity group with ID \'%s\' and name \'%s\' was updated.')
73+
% (activity_group['id'], activity_group['name']))
74+
else:
75+
print 'No activity groups found to update.'
76+
77+
if __name__ == '__main__':
78+
# Initialize client object.
79+
dfp_client = dfp.DfpClient.LoadFromStorage()
80+
main(dfp_client, ACTIVITY_GROUP_ID, ADVERTISER_COMPANY_ID)
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/python
2+
#
3+
# Copyright 2014 Google Inc. All Rights Reserved.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.

0 commit comments

Comments
 (0)