Skip to content

Commit 370455c

Browse files
committed
Releasing v20.0.0
1 parent 81742dc commit 370455c

File tree

736 files changed

+2601
-5390
lines changed

Some content is hidden

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

736 files changed

+2601
-5390
lines changed

ChangeLog

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
20.0.0 -- 06/11/2019
2+
* Updated examples to be Python 3 compatible
3+
* Removed suds dependency leaving zeep as the only supported SOAP client
4+
15
19.0.1 -- 05/22/2019
26
* Really removed examples for Ad Manager v201808
37

README.md

Lines changed: 5 additions & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ and DoubleClick for Publishers. The library provides easy ways to store your
99
authentication and create SOAP web service clients. It also contains example
1010
code to help you get started integrating with our APIs.
1111

12+
**NOTE**: As of v20.0.0 this library is _not_ compatible with Python versions less than Python 3.6.
13+
Also `suds` is no longer supported in this library, `zeep` is now the only supported SOAP client.
14+
1215
## Getting started
1316
1. Download and install the library
1417

@@ -112,12 +115,6 @@ can do the following:
112115
logging.basicConfig(level=logging.INFO, format=googleads.util.LOGGER_FORMAT)
113116
logging.getLogger('googleads.soap').setLevel(logging.DEBUG)
114117
```
115-
116-
If you are using suds, you can achieve the same like this:
117-
```python
118-
logging.basicConfig(level=logging.INFO, format=googleads.util.LOGGER_FORMAT)
119-
logging.getLogger('suds.transport').setLevel(logging.DEBUG)
120-
```
121118
If you wish to log to a file, you'll need to attach a log handler to this source
122119
which is configured to write the output to a file.
123120

@@ -138,68 +135,14 @@ class DangerousZeepLogger(zeep.Plugin):
138135
adwords_client.zeep_client.plugins.append(DangerousZeepLogger())
139136
```
140137

141-
When using suds, this library will apply log filters to the `googleads.common`,
142-
`suds.client`, and `suds.transport` loggers in order to omit sensitive data. If
143-
you need to see this data in your logs, you can disable the filters with the
144-
following:
145-
```python
146-
logging.getLogger('googleads.common').removeFilter(
147-
googleads.util.GetGoogleAdsCommonFilter())
148-
logging.getLogger('suds.client').removeFilter(
149-
googleads.util.GetSudsClientFilter())
150-
logging.getLogger('suds.mx.core').removeFilter(
151-
googleads.util.GetSudsMXCoreFilter())
152-
logging.getLogger('suds.mx.literal').removeFilter(
153-
googleads.util.GetSudsMXLiteralFilter())
154-
logging.getLogger('suds.transport').removeFilter(
155-
googleads.util.GetSudsTransportFilter())
156-
```
157-
158-
159-
## I'm familiar with suds/zeep. Can I use those features in the library?
160-
Yes, you can. The services returned by the `client.GetService()` functions all
161-
have a reference to the underlying client stored in the `zeep_client` or `suds_client`
162-
attributes. You can retrieve the client and use it in familiar ways:
163-
```python
164-
client = AdWordsClient.LoadFromStorage()
165-
campaign_service = client.GetService('CampaignService')
166-
suds_client = campaign_service.suds_client
167-
168-
campaign = suds_client.factory.create('Campaign')
169-
# Set any attributes on the campaign object which you need.
170-
campaign.name = 'My Campaign'
171-
campaign.status = 'PAUSED'
172-
173-
operation = suds_client.factory.create('CampaignOperation')
174-
operation.operator = 'ADD'
175-
operation.operand = campaign
176-
177-
# The service object returned from the client.GetService() call accepts suds
178-
# objects and will set the SOAP and HTTP headers for you.
179-
campaign_service.mutate([operation])
180-
181-
# Alternatively, if you wish to set the headers yourself, you can use the
182-
# suds_client.service directly.
183-
soap_header = suds_client.factory.create('SoapHeader')
184-
soap_header.clientCustomerId = client.client_customer_id
185-
soap_header.developerToken = client.developer_token
186-
soap_header.userAgent = client.user_agent
187-
188-
suds_client.set_options(
189-
soapheaders=soap_header,
190-
headers=client.oauth2_client.CreateHttpHeader())
191-
192-
suds_client.service.mutate([operation])
193-
```
194-
195138
## How can I configure or disable caching?
196139

197140
By default, clients are cached because reading and digesting the WSDL
198141
can be expensive. However, the default caching method requires permission to
199142
access a local file system that may not be available in certain hosting
200143
environments such as App Engine.
201144

202-
You can pass an implementation of `suds.cache.Cache` or `zeep.cache.Base` to the `AdWordsClient` or
145+
You can pass an implementation of `zeep.cache.Base` to the `AdWordsClient` or
203146
`AdManagerClient` initializer to modify the default caching behavior.
204147

205148
For example, configuring a different location and duration of the cache file with zeep
@@ -210,14 +153,6 @@ adwords_client = adwords.AdWordsClient(
210153
client_customer_id=client_customer_id, cache=doc_cache)
211154
```
212155

213-
And with suds:
214-
```python
215-
doc_cache = suds.cache.DocumentCache(location=cache_path, days=2)
216-
adwords_client = adwords.AdWordsClient(
217-
developer_token, oauth2_client, user_agent,
218-
client_customer_id=client_customer_id, cache=doc_cache)
219-
```
220-
221156
You can also disable caching in similar fashion with zeep
222157
```python
223158
adwords_client = adwords.AdWordsClient(
@@ -226,26 +161,16 @@ adwords_client = adwords.AdWordsClient(
226161
cache=googleads.common.ZeepServiceProxy.NO_CACHE)
227162
```
228163

229-
And with suds:
230-
```python
231-
adwords_client = adwords.AdWordsClient(
232-
developer_token, oauth2_client, user_agent,
233-
client_customer_id=client_customer_id, cache=suds.cache.NoCache())
234-
```
235-
236-
237164
## Requirements
238165

239166
### Python Versions
240167

241-
This library supports both Python 2 and 3. To use this library, you will need to
242-
have Python 2.7.9 (or higher) or Python 3.4 (or higher) installed.
168+
This library only supports Python 3.6+.
243169

244170
### External Dependencies:
245171

246172
- httplib2 -- https://pypi.python.org/pypi/httplib2/
247173
- oauth2client -- https://pypi.python.org/pypi/oauth2client/
248-
- suds-jurko -- https://pypi.python.org/pypi/suds-jurko/
249174
- pysocks -- https://pypi.python.org/pypi/PySocks/
250175
- pytz -- https://pypi.python.org/pypi/pytz
251176
- pyYAML -- https://pypi.python.org/pypi/pyYAML/

examples/ad_manager/authentication/create_ad_manager_client_with_access_token.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,8 @@ def main(access_token, token_expiry, application_name):
6161

6262
networks = ad_manager_client.GetService('NetworkService').getAllNetworks()
6363
for network in networks:
64-
print ('Network with network code "%s" and display name "%s" was found.'
65-
% (network['networkCode'], network['displayName']))
64+
print('Network with network code "%s" and display name "%s" was found.'
65+
% (network['networkCode'], network['displayName']))
6666

6767

6868
if __name__ == '__main__':

examples/ad_manager/authentication/create_ad_manager_client_with_refresh_token.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ def main(client_id, client_secret, refresh_token, application_name):
4545

4646
networks = ad_manager_client.GetService('NetworkService').getAllNetworks()
4747
for network in networks:
48-
print ('Network with network code "%s" and display name "%s" was found.'
49-
% (network['networkCode'], network['displayName']))
48+
print('Network with network code "%s" and display name "%s" was found.'
49+
% (network['networkCode'], network['displayName']))
5050

5151

5252
if __name__ == '__main__':

examples/ad_manager/authentication/create_ad_manager_client_with_service_account.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,8 @@ def main(key_file, application_name):
3737

3838
networks = ad_manager_client.GetService('NetworkService').getAllNetworks()
3939
for network in networks:
40-
print ('Network with network code "%s" and display name "%s" was found.'
41-
% (network['networkCode'], network['displayName']))
40+
print('Network with network code "%s" and display name "%s" was found.'
41+
% (network['networkCode'], network['displayName']))
4242

4343

4444
if __name__ == '__main__':

examples/ad_manager/authentication/generate_refresh_token.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -95,19 +95,19 @@ def main(client_id, client_secret, scopes):
9595

9696
auth_url, _ = flow.authorization_url(prompt='consent')
9797

98-
print ('Log into the Google Account you use to access your Ad Manager account'
99-
'and go to the following URL: \n%s\n' % (auth_url))
100-
print 'After approving the token enter the verification code (if specified).'
98+
print('Log into the Google Account you use to access your Ad Manager account'
99+
'and go to the following URL: \n%s\n' % (auth_url))
100+
print('After approving the token enter the verification code (if specified).')
101101
code = raw_input('Code: ').strip()
102102

103103
try:
104104
flow.fetch_token(code=code)
105105
except InvalidGrantError as ex:
106-
print 'Authentication has failed: %s' % ex
106+
print('Authentication has failed: %s' % ex)
107107
sys.exit(1)
108108

109-
print 'Access token: %s' % flow.credentials.token
110-
print 'Refresh token: %s' % flow.credentials.refresh_token
109+
print('Access token: %s' % flow.credentials.token)
110+
print('Refresh token: %s' % flow.credentials.refresh_token)
111111

112112

113113
if __name__ == '__main__':

examples/ad_manager/v201811/activity_group_service/create_activity_groups.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,8 @@ def main(client, advertiser_company_id):
6262

6363
# Display results.
6464
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']))
65+
print('Activity group with ID "%s" and name "%s" was created.'
66+
% (activity_group['id'], activity_group['name']))
6767

6868
if __name__ == '__main__':
6969
# Initialize client object.

examples/ad_manager/v201811/activity_group_service/get_active_activity_groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def main(client):
4343
else:
4444
break
4545

46-
print '\nNumber of results found: %s' % response['totalResultSetSize']
46+
print('\nNumber of results found: %s' % response['totalResultSetSize'])
4747

4848

4949
if __name__ == '__main__':

examples/ad_manager/v201811/activity_group_service/get_all_activity_groups.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def main(client):
4242
else:
4343
break
4444

45-
print '\nNumber of results found: %s' % response['totalResultSetSize']
45+
print('\nNumber of results found: %s' % response['totalResultSetSize'])
4646

4747

4848
if __name__ == '__main__':

examples/ad_manager/v201811/activity_group_service/update_activity_groups.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ def main(client, activity_group_id, advertiser_company_id):
4242
# Create statement object to select a single activity groups by ID.
4343
statement = (ad_manager.StatementBuilder(version='v201811')
4444
.Where('id = :activityGroupId')
45-
.WithBindVariable('activityGroupId', long(activity_group_id))
45+
.WithBindVariable('activityGroupId', int(activity_group_id))
4646
.Limit(1))
4747

4848
# Get activity groups by statement.
@@ -58,10 +58,10 @@ def main(client, activity_group_id, advertiser_company_id):
5858
updated_activity_groups)
5959

6060
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']))
61+
print(('Activity group with ID "%s" and name "%s" was updated.')
62+
% (activity_group['id'], activity_group['name']))
6363
else:
64-
print 'No activity groups found to update.'
64+
print('No activity groups found to update.')
6565

6666

6767
if __name__ == '__main__':

0 commit comments

Comments
 (0)