Skip to content

Commit 6e3edd5

Browse files
author
David Wihl
committed
Releasing v19.0.0
1 parent aa3b1b4 commit 6e3edd5

File tree

252 files changed

+15076
-24
lines changed

Some content is hidden

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

252 files changed

+15076
-24
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
19.0.0 -- 05/09/2019
2+
* Added support for Ad Manager v201905
3+
* Removed support for Ad Manager v201805
4+
* Removed examples for Ad Manager v201808
5+
16
18.1.0 -- 04/03/2018
27
* Upgrade PyYAML to 5.1 >= 6.0
38
* Update comment in get_all_images_and_videos examples
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2015 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: 71 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,71 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2015 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+
"""
27+
28+
29+
import uuid
30+
31+
# Import appropriate modules from the client library.
32+
from googleads import ad_manager
33+
34+
# Set the ID of the advertiser company this activity group is associated with.
35+
ADVERTISER_COMPANY_ID = 'INSERT_ADVERTISER_COMPANY_ID_HERE'
36+
37+
38+
def main(client, advertiser_company_id):
39+
# Initialize appropriate service.
40+
activity_group_service = client.GetService('ActivityGroupService',
41+
version='v201905')
42+
43+
# Create a short-term activity group.
44+
short_term_activity_group = {
45+
'name': 'Short-term activity group #%s' % uuid.uuid4(),
46+
'companyIds': [advertiser_company_id],
47+
'clicksLookback': '1',
48+
'impressionsLookback': '1'
49+
}
50+
51+
# Create a long-term activity group.
52+
long_term_activity_group = {
53+
'name': 'Long-term activity group #%s' % uuid.uuid4(),
54+
'companyIds': [advertiser_company_id],
55+
'clicksLookback': '30',
56+
'impressionsLookback': '30'
57+
}
58+
59+
# Create the activity groups on the server.
60+
activity_groups = activity_group_service.createActivityGroups([
61+
short_term_activity_group, long_term_activity_group])
62+
63+
# Display results.
64+
for activity_group in activity_groups:
65+
print ('Activity group with ID "%s" and name "%s" was created.'
66+
% (activity_group['id'], activity_group['name']))
67+
68+
if __name__ == '__main__':
69+
# Initialize client object.
70+
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
71+
main(ad_manager_client, ADVERTISER_COMPANY_ID)
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2016 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+
"""This example gets all active activity groups.
17+
"""
18+
19+
# Import appropriate modules from the client library.
20+
from googleads import ad_manager
21+
22+
23+
def main(client):
24+
# Initialize appropriate service.
25+
activity_group_service = client.GetService(
26+
'ActivityGroupService', version='v201905')
27+
# Create a statement to select activity groups.
28+
statement = (ad_manager.StatementBuilder(version='v201905')
29+
.Where('status = :status')
30+
.WithBindVariable('status', 'ACTIVE'))
31+
32+
# Retrieve a small amount of activity groups at a time, paging
33+
# through until all activity groups have been retrieved.
34+
while True:
35+
response = activity_group_service.getActivityGroupsByStatement(
36+
statement.ToStatement())
37+
if 'results' in response and len(response['results']):
38+
for activity_group in response['results']:
39+
# Print out some information for each activity group.
40+
print('Activity group with ID "%d" and name "%s" was found.\n' %
41+
(activity_group['id'], activity_group['name']))
42+
statement.offset += statement.limit
43+
else:
44+
break
45+
46+
print '\nNumber of results found: %s' % response['totalResultSetSize']
47+
48+
49+
if __name__ == '__main__':
50+
# Initialize client object.
51+
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
52+
main(ad_manager_client)
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2016 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+
"""This example gets all activity groups.
17+
"""
18+
19+
# Import appropriate modules from the client library.
20+
from googleads import ad_manager
21+
22+
23+
def main(client):
24+
# Initialize appropriate service.
25+
activity_group_service = client.GetService(
26+
'ActivityGroupService', version='v201905')
27+
28+
# Create a statement to select activity groups.
29+
statement = ad_manager.StatementBuilder(version='v201905')
30+
31+
# Retrieve a small amount of activity groups at a time, paging
32+
# through until all activity groups have been retrieved.
33+
while True:
34+
response = activity_group_service.getActivityGroupsByStatement(
35+
statement.ToStatement())
36+
if 'results' in response and len(response['results']):
37+
for activity_group in response['results']:
38+
# Print out some information for each activity group.
39+
print('Activity group with ID "%d" and name "%s" was found.\n' %
40+
(activity_group['id'], activity_group['name']))
41+
statement.offset += statement.limit
42+
else:
43+
break
44+
45+
print '\nNumber of results found: %s' % response['totalResultSetSize']
46+
47+
48+
if __name__ == '__main__':
49+
# Initialize client object.
50+
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
51+
main(ad_manager_client)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2015 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+
"""
27+
28+
29+
# Import appropriate modules from the client library.
30+
from googleads import ad_manager
31+
32+
# Set the ID of the activity group and the company to update it with.
33+
ACTIVITY_GROUP_ID = 'INSERT_ACTIVITY_GROUP_ID_HERE'
34+
ADVERTISER_COMPANY_ID = 'INSERT_ADVERTISER_COMPANY_ID_HERE'
35+
36+
37+
def main(client, activity_group_id, advertiser_company_id):
38+
# Initialize appropriate service.
39+
activity_group_service = client.GetService('ActivityGroupService',
40+
version='v201905')
41+
42+
# Create statement object to select a single activity groups by ID.
43+
statement = (ad_manager.StatementBuilder(version='v201905')
44+
.Where('id = :activityGroupId')
45+
.WithBindVariable('activityGroupId', long(activity_group_id))
46+
.Limit(1))
47+
48+
# Get activity groups by statement.
49+
response = activity_group_service.getActivityGroupsByStatement(
50+
statement.ToStatement())
51+
if 'results' in response and len(response['results']):
52+
updated_activity_groups = []
53+
for activity_group in response['results']:
54+
activity_group['companyIds'].append(advertiser_company_id)
55+
updated_activity_groups.append(activity_group)
56+
# Update the activity groups on the server.
57+
activity_groups = activity_group_service.updateActivityGroups(
58+
updated_activity_groups)
59+
60+
for activity_group in activity_groups:
61+
print (('Activity group with ID "%s" and name "%s" was updated.')
62+
% (activity_group['id'], activity_group['name']))
63+
else:
64+
print 'No activity groups found to update.'
65+
66+
67+
if __name__ == '__main__':
68+
# Initialize client object.
69+
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
70+
main(ad_manager_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/env python
2+
#
3+
# Copyright 2015 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: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2015 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 activities.
18+
19+
To determine which activities groups exist, run get_all_activities.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+
"""
27+
28+
29+
import uuid
30+
31+
# Import appropriate modules from the client library.
32+
from googleads import ad_manager
33+
34+
# Set the ID of the activity group this activity is associated with.
35+
ACTIVITY_GROUP_ID = 'INSERT_ACTIVITY_GROUP_ID_HERE'
36+
37+
38+
def main(client, activity_group_id):
39+
# Initialize appropriate service.
40+
activity_service = client.GetService('ActivityService', version='v201905')
41+
42+
# Create a daily visits activity.
43+
daily_visits_activity = {
44+
'name': 'Activity #%s' % uuid.uuid4(),
45+
'activityGroupId': activity_group_id,
46+
'type': 'DAILY_VISITS'
47+
}
48+
49+
# Create a custom activity.
50+
custom_activity = {
51+
'name': 'Activity #%s' % uuid.uuid4(),
52+
'activityGroupId': activity_group_id,
53+
'type': 'CUSTOM'
54+
}
55+
56+
# Create the activities on the server.
57+
activities = activity_service.createActivities([
58+
daily_visits_activity, custom_activity])
59+
60+
# Display results.
61+
for activity in activities:
62+
print ('An activity with ID "%s", name "%s", and type "%s" was '
63+
'created.' % (activity['id'], activity['name'], activity['type']))
64+
65+
if __name__ == '__main__':
66+
# Initialize client object.
67+
ad_manager_client = ad_manager.AdManagerClient.LoadFromStorage()
68+
main(ad_manager_client, ACTIVITY_GROUP_ID)

0 commit comments

Comments
 (0)