Skip to content

Commit 1446a44

Browse files
committed
upgrade to version 11.5.8
1 parent fcea26d commit 1446a44

16 files changed

+9642
-9550
lines changed

HISTORY.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
.. :changelog:
22
33
Release History
4+
---------------
5+
11.5.8(2018-01-12)
6+
+++++++++++++++++++
7+
*The Bulk and Campaign Management proxies are updated to support [audience search size](https://docs.microsoft.com/en-us/bingads/guides/release-notes#audiencesearchsize-january2018). In addition the SDK supports audience search size via the BulkCustomAudience, BulkInMarketAudience, and BulkRemarketingList classes.
8+
9+
*Allow the Parent Id to be empty when deleting Bulk entities. Previously the Parent Id was required by the SDK although the Bulk service does not always require it.
10+
411
---------------
512
11.5.7(2017-12-12)
613
+++++++++++++++++++

bingads/headerplugin.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
from suds.plugin import MessagePlugin
2+
3+
class HeaderPlugin(MessagePlugin):
4+
def __init__(self):
5+
self.document = None
6+
7+
def parsed(self, context):
8+
self.document = context.reply
9+
10+
def get_headers(self, method):
11+
Result = {}
12+
method = method.method
13+
binding = method.binding.output
14+
SHeaderElem = binding.headpart_types(method, False)
15+
16+
envns = ('SOAP-ENV', 'http://schemas.xmlsoap.org/soap/envelope/')
17+
soapenv = self.document.getChild('Envelope', envns)
18+
soapheaders = soapenv.getChild('Header', envns)
19+
SHeaderNodes = soapheaders.children
20+
21+
for Elem in SHeaderElem:
22+
for Node in SHeaderNodes:
23+
if(Node.name == Elem.name):
24+
ElemRes = Elem.resolve(nobuiltin=True)
25+
NodeRes = binding.unmarshaller().process(Node, ElemRes)
26+
Result[Elem.name] = NodeRes
27+
return Result
28+
#

bingads/manifest.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import sys
2-
VERSION = '11.5.7'
3-
BULK_FORMAT_VERSION = '3.0'
4-
BULK_FORMAT_VERSION_4 = '4.0'
2+
VERSION = '11.5.8'
53
BULK_FORMAT_VERSION_5 = '5.0'
64
WORKING_NAME = 'BingAdsSDKPython'
75
USER_AGENT = '{0} {1} {2}'.format(WORKING_NAME, VERSION, sys.version_info[0:3])

bingads/service_client.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from suds.client import Client, Factory, WebFault, ObjectCache # noqa
22

3+
from .headerplugin import HeaderPlugin
34
from .authorization import *
45
from .service_info import SERVICE_INFO_DICT_V11
56
from .manifest import USER_AGENT
@@ -42,6 +43,8 @@ def __init__(self, service, authorization_data=None, environment='production', v
4243
self._service = ServiceClient._format_service(service)
4344
self._environment = ServiceClient._format_environment(environment)
4445

46+
self.hp=HeaderPlugin()
47+
suds_options['plugins'] = [self.hp]
4548
self._soap_client = Client(self.service_url, **suds_options)
4649

4750
def __getattr__(self, name):

bingads/v11/bulk/bulk_operation.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,12 +49,14 @@ def __init__(self,
4949
authorization_data,
5050
poll_interval_in_milliseconds=15000,
5151
environment='production',
52+
tracking_id=None,
5253
**suds_options):
5354
self._request_id = request_id
5455
self._service_client = ServiceClient('BulkService', authorization_data, environment, version='v11', **suds_options)
5556
self._authorization_data = authorization_data
5657
self._poll_interval_in_milliseconds = poll_interval_in_milliseconds
5758
self._final_status = None
59+
self.tracking_id=tracking_id
5860

5961
def download_result_file(self, result_file_directory, result_file_name, decompress, overwrite, timeout_in_milliseconds=None):
6062
""" Download file with specified URL and download parameters.
@@ -193,12 +195,14 @@ def __init__(self,
193195
authorization_data,
194196
poll_interval_in_milliseconds=15000,
195197
environment='production',
198+
tracking_id=None,
196199
**suds_options):
197200
super(BulkDownloadOperation, self).__init__(
198201
request_id=request_id,
199202
authorization_data=authorization_data,
200203
poll_interval_in_milliseconds=poll_interval_in_milliseconds,
201204
environment=environment,
205+
tracking_id=tracking_id,
202206
**suds_options
203207
)
204208

@@ -238,6 +242,8 @@ def get_status(self):
238242
if self.final_status is not None:
239243
return self.final_status
240244
response = self._get_status_with_retry(3)
245+
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkDownloadStatus)
246+
self.tracking_id = headers['TrackingId'] if 'TrackingId' in headers else None
241247
status = BulkOperationStatus(
242248
status=response.RequestStatus,
243249
percent_complete=int(response.PercentComplete),
@@ -285,12 +291,14 @@ def __init__(self,
285291
authorization_data,
286292
poll_interval_in_milliseconds=15000,
287293
environment='production',
294+
tracking_id=None,
288295
**suds_options):
289296
super(BulkUploadOperation, self).__init__(
290297
request_id=request_id,
291298
authorization_data=authorization_data,
292299
poll_interval_in_milliseconds=poll_interval_in_milliseconds,
293300
environment=environment,
301+
tracking_id=tracking_id,
294302
**suds_options
295303
)
296304

@@ -330,6 +338,8 @@ def get_status(self):
330338
if self.final_status is not None:
331339
return self.final_status
332340
response = self._get_status_with_retry(3)
341+
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkUploadStatus)
342+
self.tracking_id = headers['TrackingId'] if 'TrackingId' in headers else None
333343
status = BulkOperationStatus(
334344
status=response.RequestStatus,
335345
percent_complete=int(response.PercentComplete),

bingads/v11/bulk/bulk_service_manager.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -206,6 +206,7 @@ def submit_download(self, submit_download_parameters):
206206
LastSyncTimeInUTC=last_sync_time_in_utc,
207207
PerformanceStatsDateRange=performance_stats_date_range,
208208
)
209+
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.DownloadCampaignsByAccountIds)
209210
else:
210211
response = self.service_client.DownloadCampaignsByCampaignIds(
211212
Campaigns={
@@ -221,11 +222,13 @@ def submit_download(self, submit_download_parameters):
221222
LastSyncTimeInUTC=last_sync_time_in_utc,
222223
PerformanceStatsDateRange=performance_stats_date_range,
223224
)
225+
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.DownloadCampaignsByCampaignIds)
224226
operation = BulkDownloadOperation(
225227
request_id=response,
226228
authorization_data=self._authorization_data,
227229
poll_interval_in_milliseconds=self._poll_interval_in_milliseconds,
228230
environment=self._environment,
231+
tracking_id=headers['TrackingId'] if 'TrackingId' in headers else None,
229232
**self.suds_options
230233
)
231234
return operation
@@ -243,6 +246,7 @@ def submit_upload(self, submit_upload_parameters):
243246
AccountId=self._authorization_data.account_id,
244247
ResponseMode=submit_upload_parameters.response_mode,
245248
)
249+
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkUploadUrl)
246250
request_id = response.RequestId
247251
upload_url = response.UploadUrl
248252

@@ -256,6 +260,7 @@ def submit_upload(self, submit_upload_parameters):
256260
authorization_data=self._authorization_data,
257261
poll_interval_in_milliseconds=self._poll_interval_in_milliseconds,
258262
environment=self._environment,
263+
tracking_id=headers['TrackingId'] if 'TrackingId' in headers else None,
259264
**self.suds_options
260265
)
261266
return operation

bingads/v11/bulk/entities/ad_extensions/common.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ def version(self, version):
376376
_SimpleBulkMapping(
377377
header=_StringTable.ParentId,
378378
field_to_csv=lambda c: bulk_str(c.account_id),
379-
csv_to_field=lambda c, v: setattr(c, 'account_id', int(v))
379+
csv_to_field=lambda c, v: setattr(c, 'account_id', int(v) if v else None)
380380
),
381381
]
382382

bingads/v11/bulk/entities/audiences/bulk_custom_audience.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ def __init__(self,
6565
field_to_csv=lambda c: bulk_str(c.custom_audience.Scope),
6666
csv_to_field=lambda c, v: setattr(c.custom_audience, 'Scope', v if v else None)
6767
),
68+
_SimpleBulkMapping(
69+
_StringTable.AudienceSearchSize,
70+
field_to_csv=lambda c: bulk_str(c.custom_audience.SearchSize),
71+
csv_to_field=lambda c, v: setattr(c.custom_audience, 'SearchSize', int(v) if v else None)
72+
),
6873
]
6974

7075
@property

bingads/v11/bulk/entities/audiences/bulk_in_market_audience.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,11 @@ def __init__(self,
6565
field_to_csv=lambda c: bulk_str(c.in_market_audience.Scope),
6666
csv_to_field=lambda c, v: setattr(c.in_market_audience, 'Scope', v if v else None)
6767
),
68+
_SimpleBulkMapping(
69+
_StringTable.AudienceSearchSize,
70+
field_to_csv=lambda c: bulk_str(c.in_market_audience.SearchSize),
71+
csv_to_field=lambda c, v: setattr(c.in_market_audience, 'SearchSize', int(v) if v else None)
72+
),
6873
]
6974

7075
@property

bingads/v11/bulk/entities/audiences/bulk_remarketing_list.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,11 @@ def __init__(self,
7575
field_to_csv=lambda c: field_to_csv_RemarketingRule(c.remarketing_list),
7676
csv_to_field=lambda c, v: csv_to_field_RemarketingRule(c.remarketing_list, v)
7777
),
78+
_SimpleBulkMapping(
79+
_StringTable.AudienceSearchSize,
80+
field_to_csv=lambda c: bulk_str(c.remarketing_list.SearchSize),
81+
csv_to_field=lambda c, v: setattr(c.remarketing_list, 'SearchSize', int(v) if v else None)
82+
),
7883
]
7984

8085
@property

0 commit comments

Comments
 (0)