Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
),
_SimpleBulkMapping(
header=_StringTable.TrackingTemplate,
field_to_csv=lambda c: bulk_optional_str(c.ad_group_criterion.TrackingUrlTemplate, c.ad_group_criterion.Id)
if isinstance(c.ad_group_criterion, _BiddableAdGroupCriterion) else None,
csv_to_field=lambda c, v: setattr(c.ad_group_criterion, 'TrackingUrlTemplate', v if v else None)
if isinstance(c.ad_group_criterion, _BiddableAdGroupCriterion) else None
),
_SimpleBulkMapping(
header=_StringTable.CustomParameter,
field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.ad_group_criterion)
if isinstance(c.ad_group_criterion, _BiddableAdGroupCriterion) else None,
csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.ad_group_criterion, v)
if isinstance(c.ad_group_criterion, _BiddableAdGroupCriterion) else None
),
_SimpleBulkMapping(
header=_StringTable.FinalUrlSuffix,
field_to_csv=lambda c: bulk_optional_str(c.ad_group_criterion.FinalUrlSuffix, c.ad_group_criterion.Id) if isinstance(c.ad_group_criterion, _BiddableAdGroupCriterion) else None ,
csv_to_field=lambda c, v: setattr(c.ad_group_criterion, 'FinalUrlSuffix', v) if isinstance(c.ad_group_criterion, _BiddableAdGroupCriterion) else None
)
]
@property
def ad_group_criterion(self):
""" Defines an Ad Group Criterion """
return self._ad_group_criterion
@ad_group_criterion.setter
def ad_group_criterion(self, ad_group_criterion):
self._ad_group_criterion = ad_group_criterion
_SimpleBulkMapping(
_StringTable.Status,
field_to_csv=lambda c: c.ad_group_criterion.Status,
csv_to_field=lambda c, v: setattr(c.ad_group_criterion, 'Status', v)
),
_SimpleBulkMapping(
_StringTable.Id,
field_to_csv=lambda c: bulk_str(c.ad_group_criterion.Id),
csv_to_field=lambda c, v: setattr(c.ad_group_criterion, 'Id', int(v) if v else None)
),
_SimpleBulkMapping(
_StringTable.ParentId,
field_to_csv=lambda c: bulk_str(c.ad_group_criterion.AdGroupId),
csv_to_field=lambda c, v: setattr(c.ad_group_criterion, 'AdGroupId', int(v) if v else None)
),
_SimpleBulkMapping(
_StringTable.Campaign,
field_to_csv=lambda c: c.campaign_name,
csv_to_field=lambda c, v: setattr(c, 'campaign_name', v)
),
_SimpleBulkMapping(
_StringTable.AdGroup,
field_to_csv=lambda c: c.ad_group_name,
csv_to_field=lambda c, v: setattr(c, 'ad_group_name', v)
),
_SimpleBulkMapping(
_StringTable.SubType,
field_to_csv=lambda c: BulkAdGroupProductPartition._get_partition_type(c),
csv_to_field=lambda c, v: setattr(c.ad_group_criterion.Criterion, 'PartitionType', v)
),
_SimpleBulkMapping(
_StringTable.ParentAdGroupCriterionId,
_SimpleBulkMapping(
header=_StringTable.FinalUrl,
field_to_csv=lambda c: field_to_csv_Urls(c.keyword.FinalUrls, c.keyword.Id),
csv_to_field=lambda c, v: csv_to_field_Urls(c.keyword.FinalUrls, v)
),
_SimpleBulkMapping(
header=_StringTable.FinalMobileUrl,
field_to_csv=lambda c: field_to_csv_Urls(c.keyword.FinalMobileUrls, c.keyword.Id),
csv_to_field=lambda c, v: csv_to_field_Urls(c.keyword.FinalMobileUrls, v)
),
_SimpleBulkMapping(
header=_StringTable.TrackingTemplate,
field_to_csv=lambda c: bulk_str(c.keyword.TrackingUrlTemplate),
csv_to_field=lambda c, v: setattr(c.keyword, 'TrackingUrlTemplate', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.CustomParameter,
field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.keyword),
csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.keyword, v)
),
_ComplexBulkMapping(bidding_scheme_to_csv, csv_to_bidding_scheme),
_SimpleBulkMapping(
header=_StringTable.FinalUrlSuffix,
field_to_csv=lambda c: bulk_optional_str(c.keyword.FinalUrlSuffix, c.keyword.Id),
csv_to_field=lambda c, v: setattr(c.keyword, 'FinalUrlSuffix', v if v else None)
),
]
def process_mappings_to_row_values(self, row_values, exclude_readonly_data):
self._validate_property_not_null(self._keyword, 'keyword')
self.convert_to_values(row_values, BulkKeyword._MAPPINGS)
if not exclude_readonly_data:
_ComplexBulkMapping(budget_to_csv, csv_to_budget),
_SimpleBulkMapping(
header=_StringTable.BidAdjustment,
field_to_csv=lambda c: bulk_str(c.campaign.AudienceAdsBidAdjustment),
csv_to_field=lambda c, v: setattr(
c.campaign,
'AudienceAdsBidAdjustment',
int(v) if v else None
)
),
_SimpleBulkMapping(
header=_StringTable.BingMerchantCenterId,
field_to_csv=lambda c: BulkCampaign._write_store_id(c),
csv_to_field=lambda c, v: BulkCampaign._read_store_id(c, v)
),
_SimpleBulkMapping(
header=_StringTable.CampaignPriority,
field_to_csv=lambda c: BulkCampaign._write_priority(c),
csv_to_field=lambda c, v: BulkCampaign._read_priority(c, v)
),
_SimpleBulkMapping(
header=_StringTable.CountryCode,
field_to_csv=lambda c: BulkCampaign._write_sales_country_code(c),
csv_to_field=lambda c, v: BulkCampaign._read_sales_country_code(c, v)
),
_SimpleBulkMapping(
header=_StringTable.LocalInventoryAdsEnabled,
field_to_csv=lambda c: BulkCampaign._write_local_inventory_ads_enabled(c),
csv_to_field=lambda c, v: BulkCampaign._read_local_inventory_ads_enabled(c, v)
),
_SimpleBulkMapping(
header=_StringTable.TrackingTemplate,
return None
dsa_setting.DomainName = v
@staticmethod
def _write_website(c):
if not c.campaign.CampaignType:
return None
campgaign_types = [campaign_type.lower() for campaign_type in c.campaign.CampaignType]
if 'dynamicsearchads' in campgaign_types:
dsa_setting = c._get_dsa_setting()
if not dsa_setting:
return None
return bulk_str(dsa_setting.DomainName)
_MAPPINGS = [
_SimpleBulkMapping(
header=_StringTable.CampaignType,
field_to_csv=lambda c: BulkCampaign._write_campaign_type(c),
csv_to_field=lambda c, v: BulkCampaign._read_campaign_type(c, v)
),
_SimpleBulkMapping(
header=_StringTable.Status,
field_to_csv=lambda c: bulk_str(c.campaign.Status),
csv_to_field=lambda c, v: setattr(
c.campaign,
'Status',
v if v else None
)
),
_SimpleBulkMapping(
header=_StringTable.Id,
field_to_csv=lambda c: bulk_str(c.campaign.Id),
header=_StringTable.TrackingTemplate,
field_to_csv=lambda c: bulk_str(c.campaign.TrackingUrlTemplate),
csv_to_field=lambda c, v: setattr(c.campaign, 'TrackingUrlTemplate', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.CustomParameter,
field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.campaign),
csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.campaign, v)
),
_ComplexBulkMapping(biddingscheme_to_csv, csv_to_biddingscheme),
_SimpleBulkMapping(
header=_StringTable.BudgetId,
field_to_csv=lambda c: bulk_str(c.campaign.BudgetId),
csv_to_field=lambda c, v: setattr(c.campaign, 'BudgetId', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.BudgetType,
field_to_csv=lambda c: bulk_str(c.campaign.BudgetType),
csv_to_field=lambda c, v: csv_to_field_BudgetType(c.campaign, v)
),
_SimpleBulkMapping(
header=_StringTable.BudgetName,
field_to_csv=lambda c: bulk_str(c.budget_name),
csv_to_field=lambda c, v: setattr(c, 'budget_name', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Website,
field_to_csv=lambda c: BulkCampaign._write_website(c),
csv_to_field=lambda c, v: BulkCampaign._read_website(c, v)
),
_SimpleBulkMapping(
*See also:*
* :class:`.BulkServiceManager`
* :class:`.BulkOperation`
* :class:`.BulkFileReader`
* :class:`.BulkFileWriter`
"""
def __init__(self,
product_audience=None,
status=None,):
super(BulkProductAudience, self).__init__(audience = BulkAudience, status = status)
_MAPPINGS = [
_SimpleBulkMapping(
_StringTable.TagId,
field_to_csv=lambda c: bulk_str(c.product_audience.TagId),
csv_to_field=lambda c, v: setattr(c.product_audience, 'TagId', int(v) if v else None)
),
_SimpleBulkMapping(
_StringTable.Audience,
field_to_csv=lambda c: bulk_str(c.product_audience.ProductAudienceType),
csv_to_field=lambda c, v: setattr(c.product_audience, 'ProductAudienceType', v)
),
]
@property
def product_audience(self):
""" Defines a Product Audience """
return self._audience
_SimpleBulkMapping(
header=_StringTable.BudgetId,
field_to_csv=lambda c: bulk_str(c.campaign.BudgetId),
csv_to_field=lambda c, v: setattr(c.campaign, 'BudgetId', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.BudgetType,
field_to_csv=lambda c: bulk_str(c.campaign.BudgetType),
csv_to_field=lambda c, v: csv_to_field_BudgetType(c.campaign, v)
),
_SimpleBulkMapping(
header=_StringTable.BudgetName,
field_to_csv=lambda c: bulk_str(c.budget_name),
csv_to_field=lambda c, v: setattr(c, 'budget_name', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Website,
field_to_csv=lambda c: BulkCampaign._write_website(c),
csv_to_field=lambda c, v: BulkCampaign._read_website(c, v)
),
_SimpleBulkMapping(
header=_StringTable.DomainLanguage,
field_to_csv=lambda c: BulkCampaign._write_domain_language(c),
csv_to_field=lambda c, v: BulkCampaign._read_domain_language(c, v)
),
_SimpleBulkMapping(
header=_StringTable.Source,
field_to_csv=lambda c: BulkCampaign._write_source(c),
csv_to_field=lambda c, v: BulkCampaign._read_source(c, v)
),
_SimpleBulkMapping(
def experiment(self):
""" The experiment.
"""
return self._experiment
@experiment.setter
def experiment(self, experiment):
self._experiment = experiment
_MAPPINGS = [
_SimpleBulkMapping(
header=_StringTable.Id,
field_to_csv=lambda c: bulk_str(c.experiment.Id),
csv_to_field=lambda c, v: setattr(c.experiment, 'Id', int(v) if v else None)
),
_SimpleBulkMapping(
header=_StringTable.Status,
field_to_csv=lambda c: c.experiment.ExperimentStatus,
csv_to_field=lambda c, v: setattr(c.experiment, 'ExperimentStatus', v)
),
_SimpleBulkMapping(
header=_StringTable.Name,
field_to_csv=lambda c: c.experiment.Name,
csv_to_field=lambda c, v: setattr(c.experiment, 'Name', v)
),
_SimpleBulkMapping(
header=_StringTable.StartDate,
field_to_csv=lambda c: bulk_date_str(c.experiment.StartDate),
csv_to_field=lambda c, v: setattr(c.experiment, 'StartDate', parse_date(v))
),
_SimpleBulkMapping(
header=_StringTable.EndDate,
_SimpleBulkMapping(
header=_StringTable.BingMerchantCenterId,
field_to_csv=lambda c: BulkCampaign._write_store_id(c),
csv_to_field=lambda c, v: BulkCampaign._read_store_id(c, v)
),
_SimpleBulkMapping(
header=_StringTable.CampaignPriority,
field_to_csv=lambda c: BulkCampaign._write_priority(c),
csv_to_field=lambda c, v: BulkCampaign._read_priority(c, v)
),
_SimpleBulkMapping(
header=_StringTable.CountryCode,
field_to_csv=lambda c: BulkCampaign._write_sales_country_code(c),
csv_to_field=lambda c, v: BulkCampaign._read_sales_country_code(c, v)
),
_SimpleBulkMapping(
header=_StringTable.LocalInventoryAdsEnabled,
field_to_csv=lambda c: BulkCampaign._write_local_inventory_ads_enabled(c),
csv_to_field=lambda c, v: BulkCampaign._read_local_inventory_ads_enabled(c, v)
),
_SimpleBulkMapping(
header=_StringTable.TrackingTemplate,
field_to_csv=lambda c: bulk_str(c.campaign.TrackingUrlTemplate),
csv_to_field=lambda c, v: setattr(c.campaign, 'TrackingUrlTemplate', v if v else None)
),
_SimpleBulkMapping(
header=_StringTable.CustomParameter,
field_to_csv=lambda c: field_to_csv_UrlCustomParameters(c.campaign),
csv_to_field=lambda c, v: csv_to_field_UrlCustomParameters(c.campaign, v)
),
_ComplexBulkMapping(biddingscheme_to_csv, csv_to_biddingscheme),
_SimpleBulkMapping(