Skip to content

Commit aeb1176

Browse files
committed
Committing latest changes.
1 parent b93ae8e commit aeb1176

22 files changed

+4276
-8
lines changed

ChangeLog

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
11.0.1 -- 04/06/18
2+
* Fixed bug related to creating types from services that
3+
contain multiple schemas.
4+
* Fixed bug in README.md related to zeep caching.
5+
16
11.0.0 -- 03/21/18
27
* Removed support and examples for AdWords v201705, and v201708.
38
* The default SOAP backend is now zeep. If you encounter any issues,

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -222,7 +222,8 @@ You can also disable caching in similar fashion with zeep
222222
```python
223223
adwords_client = adwords.AdWordsClient(
224224
developer_token, oauth2_client, user_agent,
225-
client_customer_id=client_customer_id, cache=None)
225+
client_customer_id=client_customer_id,
226+
cache=googleads.common.ZeepServiceProxy.NO_CACHE)
226227
```
227228

228229
And with suds:

examples/adwords/v201710/optimization/estimate_keyword_traffic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ def DisplayEstimate(message, min_estimate, max_estimate):
157157
# Find the mean of the min and max values.
158158
mean_avg_cpc = (_CalculateMean(min_estimate['averageCpc']['microAmount'],
159159
max_estimate['averageCpc']['microAmount'])
160-
if 'averageCpc' in min_estimate else None)
160+
if 'averageCpc' in min_estimate
161+
and min_estimate['averageCpc'] else None)
161162
mean_avg_pos = (_CalculateMean(min_estimate['averagePosition'],
162163
max_estimate['averagePosition'])
163-
if 'averagePosition' in min_estimate else None)
164+
if 'averagePosition' in min_estimate
165+
and min_estimate['averagePosition'] else None)
164166
mean_clicks = _CalculateMean(min_estimate['clicksPerDay'],
165167
max_estimate['clicksPerDay'])
166168
mean_total_cost = _CalculateMean(min_estimate['totalCost']['microAmount'],

examples/adwords/v201802/optimization/estimate_keyword_traffic.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -157,10 +157,12 @@ def DisplayEstimate(message, min_estimate, max_estimate):
157157
# Find the mean of the min and max values.
158158
mean_avg_cpc = (_CalculateMean(min_estimate['averageCpc']['microAmount'],
159159
max_estimate['averageCpc']['microAmount'])
160-
if 'averageCpc' in min_estimate else None)
160+
if 'averageCpc' in min_estimate
161+
and min_estimate['averageCpc'] else None)
161162
mean_avg_pos = (_CalculateMean(min_estimate['averagePosition'],
162163
max_estimate['averagePosition'])
163-
if 'averagePosition' in min_estimate else None)
164+
if 'averagePosition' in min_estimate
165+
and min_estimate['averagePosition'] else None)
164166
mean_clicks = _CalculateMean(min_estimate['clicksPerDay'],
165167
max_estimate['clicksPerDay'])
166168
mean_total_cost = _CalculateMean(min_estimate['totalCost']['microAmount'],
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 2018 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 activates paused live stream events."""
18+
19+
# Import appropriate modules from the client library.
20+
from googleads import dfp
21+
22+
# Set the id of the LiveStreamEvent to get live stream events from.
23+
LIVE_STREAM_EVENT_ID = 'INSERT_LIVE_STREAM_EVENT_ID_HERE'
24+
25+
26+
def main(client, live_stream_event_id):
27+
# Initialize appropriate service.
28+
live_stream_event_service = client.GetService(
29+
'LiveStreamEventService', version='v201708')
30+
31+
# Create query to find paused live stream events.
32+
statement = (dfp.StatementBuilder()
33+
.Where(('id = :id AND '
34+
'status = :status'))
35+
.WithBindVariable('status', 'PAUSED')
36+
.WithBindVariable('id', long(live_stream_event_id))
37+
.Limit(500))
38+
39+
live_stream_events_activated = 0
40+
41+
# Get live stream events by statement.
42+
while True:
43+
response = live_stream_event_service.getLiveStreamEventsByStatement(
44+
statement.ToStatement())
45+
if 'results' in response:
46+
for live_stream_event in response['results']:
47+
print('live stream event with id "%s" and name "%s" will be activated.'
48+
% (live_stream_event['id'], live_stream_event['name']))
49+
50+
# Perform action.
51+
result = live_stream_event_service.performLiveStreamEventAction({
52+
'xsi_type': 'ActivateLiveStreamEvents'
53+
}, statement.ToStatement())
54+
if result and int(result['numChanges']) > 0:
55+
live_stream_events_activated += int(result['numChanges'])
56+
statement.offset += dfp.SUGGESTED_PAGE_LIMIT
57+
else:
58+
break
59+
60+
# Display results.
61+
if live_stream_events_activated > 0:
62+
print '# of live stream events activated: %s' % (
63+
live_stream_events_activated)
64+
else:
65+
print 'No live stream events were activated.'
66+
67+
68+
if __name__ == '__main__':
69+
# Initialize client object.
70+
dfp_client = dfp.DfpClient.LoadFromStorage()
71+
main(dfp_client, LIVE_STREAM_EVENT_ID)
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 2018 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 live stream events.
18+
19+
To determine which live stream events exist, run get_all_live_stream_events.py.
20+
To determine which cdn configurations exist, run get_cdn_configurations.py.
21+
"""
22+
23+
import datetime
24+
import uuid
25+
26+
# Import appropriate modules from the client library.
27+
from googleads import dfp
28+
import pytz
29+
30+
# Set content urls and adTags to use
31+
CONTENT_URLS = ['INSERT_CONTENT_URLS_HERE']
32+
AD_TAGS = ['INSERT_AD_TAGS_HERE']
33+
34+
35+
def main(client, content_urls, ad_tags):
36+
# Initialize appropriate services.
37+
live_events_service = client.GetService(
38+
'LiveStreamEventService', version='v201708')
39+
40+
# Stream will play for 365 days
41+
start_datetime = datetime.datetime.now(tz=pytz.timezone('America/New_York'))
42+
end_datetime = start_datetime + datetime.timedelta(days=365)
43+
44+
# Create live stream event objects
45+
live_stream_events = [{
46+
'name': 'Live Stream Event #%s' % uuid.uuid4(),
47+
'startDateTime': start_datetime,
48+
'endDateTime': end_datetime,
49+
'contentUrls': content_urls,
50+
'adTags': ad_tags
51+
}]
52+
53+
# Add live stream events.
54+
live_stream_events = live_events_service.createLiveStreamEvents(
55+
live_stream_events)
56+
57+
# Display results.
58+
for live_stream_event in live_stream_events:
59+
print(
60+
'Live stream event with id "%s", named "%s" and status %s was created.'
61+
% (live_stream_event['id'], live_stream_event['name'],
62+
live_stream_event['status']))
63+
64+
65+
if __name__ == '__main__':
66+
# Initialize client object.
67+
dfp_client = dfp.DfpClient.LoadFromStorage()
68+
main(dfp_client, CONTENT_URLS, AD_TAGS)
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 2018 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 example gets all live stream events.
18+
"""
19+
20+
# Import appropriate modules from the client library.
21+
from googleads import dfp
22+
23+
24+
def main(client):
25+
# Initialize appropriate service.
26+
live_stream_event_service = client.GetService(
27+
'LiveStreamEventService', version='v201708')
28+
29+
# Create a statement to select live stream events.
30+
statement = dfp.StatementBuilder()
31+
32+
# Retrieve a small amount of live stream events at a time, paging
33+
# through until all live stream events have been retrieved.
34+
while True:
35+
response = live_stream_event_service.getLiveStreamEventsByStatement(
36+
statement.ToStatement())
37+
if 'results' in response:
38+
for live_stream_event in response['results']:
39+
# Print out some information for each live stream event.
40+
print('live stream event with id "%d" and name "%s" was found.' %
41+
(live_stream_event['id'], live_stream_event['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+
dfp_client = dfp.DfpClient.LoadFromStorage()
52+
main(dfp_client)
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2018 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 example registers all live stream event-sessions ids for monitoring."""
18+
19+
# Import appropriate modules from the client library.
20+
from googleads import dfp
21+
22+
# List of session ids
23+
SESSION_IDS = ['INSERT_SESSION_IDS_HERE']
24+
25+
26+
def main(client, session_ids):
27+
# Initialize appropriate service.
28+
live_stream_event_service = client.GetService(
29+
'LiveStreamEventService', version='v201708')
30+
31+
# Retrieve all sessions id that are being monitored
32+
session_ids = live_stream_event_service.registerSessionsForMonitoring(
33+
session_ids)
34+
if session_ids:
35+
for session_id in session_ids:
36+
# Print out some information for each live stream event.
37+
print 'Session with ID "%s" registered for monitoring.' % (session_id)
38+
39+
print '\nNumber of results found: %s' % session_ids.size
40+
41+
42+
if __name__ == '__main__':
43+
# Initialize client object.
44+
dfp_client = dfp.DfpClient.LoadFromStorage()
45+
main(dfp_client, SESSION_IDS)
Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
#!/usr/bin/env python
2+
#
3+
# Copyright 2018 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 live stream events.
18+
19+
To determine which live stream events exist, run get_all_live_stream_events.py.
20+
"""
21+
22+
# Import appropriate modules from the client library.
23+
from googleads import dfp
24+
25+
# Set ID of the LiveStreamEvent to get live stream events from.
26+
LIVE_STREAM_EVENT_ID = 'INSERT_LIVE_STREAM_EVENT_ID_HERE'
27+
28+
29+
def main(client, live_stream_event_id):
30+
# Initialize appropriate services.
31+
live_stream_events_service = client.GetService(
32+
'LiveStreamEventService', version='v201708')
33+
34+
# Create statement object to only select matching live stream event.
35+
statement = (dfp.StatementBuilder()
36+
.Where(('Id = :id'))
37+
.WithBindVariable('id', long(live_stream_event_id))
38+
.Limit(500))
39+
40+
# Get live stream events by statement.
41+
response = live_stream_events_service.getLiveStreamEventsByStatement(
42+
statement.ToStatement())
43+
44+
# Set adTags to be updated.
45+
new_ad_tags = ['INSERT_NEW_AD_TAGS_HERE']
46+
47+
if 'results' in response:
48+
# Update each local live stream event by changing its attributes.
49+
updated_live_stream_events = []
50+
for live_stream_event in response['results']:
51+
live_stream_event['startDateTimeType'] = 'IMMEDIATELY'
52+
live_stream_event['adTags'] = new_ad_tags
53+
updated_live_stream_events.append(live_stream_event)
54+
55+
# Update live stream events.
56+
live_stream_events = live_stream_events_service.updateLiveStreamEvents(
57+
updated_live_stream_events)
58+
59+
# Display results.
60+
for live_stream_event in live_stream_events:
61+
print('Live stream event with id "%s", named "%s" and status %s was '
62+
'updated.' % (live_stream_event['id'], live_stream_event['name'],
63+
live_stream_event['status']))
64+
65+
66+
if __name__ == '__main__':
67+
# Initialize client object.
68+
dfp_client = dfp.DfpClient.LoadFromStorage()
69+
main(dfp_client, LIVE_STREAM_EVENT_ID)

0 commit comments

Comments
 (0)