Skip to content

Commit

Permalink
upgrade to version 11.5.8
Browse files Browse the repository at this point in the history
  • Loading branch information
qitia committed Jan 12, 2018
1 parent fcea26d commit 1446a44
Show file tree
Hide file tree
Showing 16 changed files with 9,642 additions and 9,550 deletions.
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
@@ -1,6 +1,13 @@
.. :changelog:
Release History
---------------
11.5.8(2018-01-12)
+++++++++++++++++++
*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.
*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.
---------------
11.5.7(2017-12-12)
+++++++++++++++++++
Expand Down
28 changes: 28 additions & 0 deletions bingads/headerplugin.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
from suds.plugin import MessagePlugin

class HeaderPlugin(MessagePlugin):
def __init__(self):
self.document = None

def parsed(self, context):
self.document = context.reply

def get_headers(self, method):
Result = {}
method = method.method
binding = method.binding.output
SHeaderElem = binding.headpart_types(method, False)

envns = ('SOAP-ENV', 'http://schemas.xmlsoap.org/soap/envelope/')
soapenv = self.document.getChild('Envelope', envns)
soapheaders = soapenv.getChild('Header', envns)
SHeaderNodes = soapheaders.children

for Elem in SHeaderElem:
for Node in SHeaderNodes:
if(Node.name == Elem.name):
ElemRes = Elem.resolve(nobuiltin=True)
NodeRes = binding.unmarshaller().process(Node, ElemRes)
Result[Elem.name] = NodeRes
return Result
#
4 changes: 1 addition & 3 deletions bingads/manifest.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
import sys
VERSION = '11.5.7'
BULK_FORMAT_VERSION = '3.0'
BULK_FORMAT_VERSION_4 = '4.0'
VERSION = '11.5.8'
BULK_FORMAT_VERSION_5 = '5.0'
WORKING_NAME = 'BingAdsSDKPython'
USER_AGENT = '{0} {1} {2}'.format(WORKING_NAME, VERSION, sys.version_info[0:3])
3 changes: 3 additions & 0 deletions bingads/service_client.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from suds.client import Client, Factory, WebFault, ObjectCache # noqa

from .headerplugin import HeaderPlugin
from .authorization import *
from .service_info import SERVICE_INFO_DICT_V11
from .manifest import USER_AGENT
Expand Down Expand Up @@ -42,6 +43,8 @@ def __init__(self, service, authorization_data=None, environment='production', v
self._service = ServiceClient._format_service(service)
self._environment = ServiceClient._format_environment(environment)

self.hp=HeaderPlugin()
suds_options['plugins'] = [self.hp]
self._soap_client = Client(self.service_url, **suds_options)

def __getattr__(self, name):
Expand Down
10 changes: 10 additions & 0 deletions bingads/v11/bulk/bulk_operation.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,14 @@ def __init__(self,
authorization_data,
poll_interval_in_milliseconds=15000,
environment='production',
tracking_id=None,
**suds_options):
self._request_id = request_id
self._service_client = ServiceClient('BulkService', authorization_data, environment, version='v11', **suds_options)
self._authorization_data = authorization_data
self._poll_interval_in_milliseconds = poll_interval_in_milliseconds
self._final_status = None
self.tracking_id=tracking_id

def download_result_file(self, result_file_directory, result_file_name, decompress, overwrite, timeout_in_milliseconds=None):
""" Download file with specified URL and download parameters.
Expand Down Expand Up @@ -193,12 +195,14 @@ def __init__(self,
authorization_data,
poll_interval_in_milliseconds=15000,
environment='production',
tracking_id=None,
**suds_options):
super(BulkDownloadOperation, self).__init__(
request_id=request_id,
authorization_data=authorization_data,
poll_interval_in_milliseconds=poll_interval_in_milliseconds,
environment=environment,
tracking_id=tracking_id,
**suds_options
)

Expand Down Expand Up @@ -238,6 +242,8 @@ def get_status(self):
if self.final_status is not None:
return self.final_status
response = self._get_status_with_retry(3)
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkDownloadStatus)
self.tracking_id = headers['TrackingId'] if 'TrackingId' in headers else None
status = BulkOperationStatus(
status=response.RequestStatus,
percent_complete=int(response.PercentComplete),
Expand Down Expand Up @@ -285,12 +291,14 @@ def __init__(self,
authorization_data,
poll_interval_in_milliseconds=15000,
environment='production',
tracking_id=None,
**suds_options):
super(BulkUploadOperation, self).__init__(
request_id=request_id,
authorization_data=authorization_data,
poll_interval_in_milliseconds=poll_interval_in_milliseconds,
environment=environment,
tracking_id=tracking_id,
**suds_options
)

Expand Down Expand Up @@ -330,6 +338,8 @@ def get_status(self):
if self.final_status is not None:
return self.final_status
response = self._get_status_with_retry(3)
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkUploadStatus)
self.tracking_id = headers['TrackingId'] if 'TrackingId' in headers else None
status = BulkOperationStatus(
status=response.RequestStatus,
percent_complete=int(response.PercentComplete),
Expand Down
5 changes: 5 additions & 0 deletions bingads/v11/bulk/bulk_service_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ def submit_download(self, submit_download_parameters):
LastSyncTimeInUTC=last_sync_time_in_utc,
PerformanceStatsDateRange=performance_stats_date_range,
)
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.DownloadCampaignsByAccountIds)
else:
response = self.service_client.DownloadCampaignsByCampaignIds(
Campaigns={
Expand All @@ -221,11 +222,13 @@ def submit_download(self, submit_download_parameters):
LastSyncTimeInUTC=last_sync_time_in_utc,
PerformanceStatsDateRange=performance_stats_date_range,
)
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.DownloadCampaignsByCampaignIds)
operation = BulkDownloadOperation(
request_id=response,
authorization_data=self._authorization_data,
poll_interval_in_milliseconds=self._poll_interval_in_milliseconds,
environment=self._environment,
tracking_id=headers['TrackingId'] if 'TrackingId' in headers else None,
**self.suds_options
)
return operation
Expand All @@ -243,6 +246,7 @@ def submit_upload(self, submit_upload_parameters):
AccountId=self._authorization_data.account_id,
ResponseMode=submit_upload_parameters.response_mode,
)
headers=self.service_client.hp.get_headers(self.service_client.soap_client.service.GetBulkUploadUrl)
request_id = response.RequestId
upload_url = response.UploadUrl

Expand All @@ -256,6 +260,7 @@ def submit_upload(self, submit_upload_parameters):
authorization_data=self._authorization_data,
poll_interval_in_milliseconds=self._poll_interval_in_milliseconds,
environment=self._environment,
tracking_id=headers['TrackingId'] if 'TrackingId' in headers else None,
**self.suds_options
)
return operation
Expand Down
2 changes: 1 addition & 1 deletion bingads/v11/bulk/entities/ad_extensions/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ def version(self, version):
_SimpleBulkMapping(
header=_StringTable.ParentId,
field_to_csv=lambda c: bulk_str(c.account_id),
csv_to_field=lambda c, v: setattr(c, 'account_id', int(v))
csv_to_field=lambda c, v: setattr(c, 'account_id', int(v) if v else None)
),
]

Expand Down
5 changes: 5 additions & 0 deletions bingads/v11/bulk/entities/audiences/bulk_custom_audience.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def __init__(self,
field_to_csv=lambda c: bulk_str(c.custom_audience.Scope),
csv_to_field=lambda c, v: setattr(c.custom_audience, 'Scope', v if v else None)
),
_SimpleBulkMapping(
_StringTable.AudienceSearchSize,
field_to_csv=lambda c: bulk_str(c.custom_audience.SearchSize),
csv_to_field=lambda c, v: setattr(c.custom_audience, 'SearchSize', int(v) if v else None)
),
]

@property
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,11 @@ def __init__(self,
field_to_csv=lambda c: bulk_str(c.in_market_audience.Scope),
csv_to_field=lambda c, v: setattr(c.in_market_audience, 'Scope', v if v else None)
),
_SimpleBulkMapping(
_StringTable.AudienceSearchSize,
field_to_csv=lambda c: bulk_str(c.in_market_audience.SearchSize),
csv_to_field=lambda c, v: setattr(c.in_market_audience, 'SearchSize', int(v) if v else None)
),
]

@property
Expand Down
5 changes: 5 additions & 0 deletions bingads/v11/bulk/entities/audiences/bulk_remarketing_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,11 @@ def __init__(self,
field_to_csv=lambda c: field_to_csv_RemarketingRule(c.remarketing_list),
csv_to_field=lambda c, v: csv_to_field_RemarketingRule(c.remarketing_list, v)
),
_SimpleBulkMapping(
_StringTable.AudienceSearchSize,
field_to_csv=lambda c: bulk_str(c.remarketing_list.SearchSize),
csv_to_field=lambda c, v: setattr(c.remarketing_list, 'SearchSize', int(v) if v else None)
),
]

@property
Expand Down
1 change: 1 addition & 0 deletions bingads/v11/internal/bulk/csv_headers.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@ class _CsvHeaders:
_StringTable.AudienceId,
_StringTable.RemarketingTargetingSetting,
_StringTable.RemarketingRule,
_StringTable.AudienceSearchSize,

# Expanded Text Ad
_StringTable.TitlePart1,
Expand Down
1 change: 1 addition & 0 deletions bingads/v11/internal/bulk/string_table.py
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,7 @@ class _StringTable:
AudienceId = "Audience Id"
RemarketingTargetingSetting = "Remarketing Targeting Setting"
RemarketingRule = "Remarketing Rule"
AudienceSearchSize = "Audience Search Size"

# Expanded Text Ad
TitlePart1 = "Title Part 1"
Expand Down
Loading

0 comments on commit 1446a44

Please sign in to comment.