|
| 1 | +from bingads.v11.bulk.entities import * |
| 2 | +from bingads.service_client import _CAMPAIGN_OBJECT_FACTORY_V11 |
| 3 | +from bingads.v11.internal.bulk.entities.single_record_bulk_entity import _SingleRecordBulkEntity |
| 4 | +from bingads.v11.internal.bulk.mappings import _SimpleBulkMapping |
| 5 | +from bingads.v11.internal.bulk.string_table import _StringTable |
| 6 | +from bingads.v11.internal.extensions import * |
| 7 | + |
| 8 | + |
| 9 | +class BulkAdGroupNegativeProductAudienceAssociation(_SingleRecordBulkEntity): |
| 10 | + """ Represents an Ad Group Negative Product Audience Association that can be read or written in a bulk file. |
| 11 | +
|
| 12 | + This class exposes the :attr:`negative_ad_group_criterion` property that can be read and written as fields of the |
| 13 | + Ad Group Negative Product Audience Association record in a bulk file. |
| 14 | +
|
| 15 | + For more information, see Ad Group Negative Product Audience Association at https://go.microsoft.com/fwlink/?linkid=846127. |
| 16 | +
|
| 17 | + *See also:* |
| 18 | +
|
| 19 | + * :class:`.BulkServiceManager` |
| 20 | + * :class:`.BulkOperation` |
| 21 | + * :class:`.BulkFileReader` |
| 22 | + * :class:`.BulkFileWriter` |
| 23 | + """ |
| 24 | + |
| 25 | + def __init__(self, |
| 26 | + negative_ad_group_criterion=None, |
| 27 | + campaign_name=None, |
| 28 | + ad_group_name=None, |
| 29 | + product_audience_name=None): |
| 30 | + super(BulkAdGroupNegativeProductAudienceAssociation, self).__init__() |
| 31 | + |
| 32 | + self._negative_ad_group_criterion = negative_ad_group_criterion |
| 33 | + self._campaign_name = campaign_name |
| 34 | + self._ad_group_name = ad_group_name |
| 35 | + self._product_audience_name = product_audience_name |
| 36 | + |
| 37 | + _MAPPINGS = [ |
| 38 | + _SimpleBulkMapping( |
| 39 | + _StringTable.Status, |
| 40 | + field_to_csv=lambda c: bulk_str(c.negative_ad_group_criterion.Status), |
| 41 | + csv_to_field=lambda c, v: setattr(c.negative_ad_group_criterion, 'Status', v if v else None) |
| 42 | + ), |
| 43 | + _SimpleBulkMapping( |
| 44 | + _StringTable.Id, |
| 45 | + field_to_csv=lambda c: bulk_str(c.negative_ad_group_criterion.Id), |
| 46 | + csv_to_field=lambda c, v: setattr(c.negative_ad_group_criterion, 'Id', int(v) if v else None) |
| 47 | + ), |
| 48 | + _SimpleBulkMapping( |
| 49 | + _StringTable.ParentId, |
| 50 | + field_to_csv=lambda c: bulk_str(c.negative_ad_group_criterion.AdGroupId), |
| 51 | + csv_to_field=lambda c, v: setattr(c.negative_ad_group_criterion, 'AdGroupId', int(v) if v else None) |
| 52 | + ), |
| 53 | + _SimpleBulkMapping( |
| 54 | + _StringTable.Campaign, |
| 55 | + field_to_csv=lambda c: c.campaign_name, |
| 56 | + csv_to_field=lambda c, v: setattr(c, 'campaign_name', v) |
| 57 | + ), |
| 58 | + _SimpleBulkMapping( |
| 59 | + _StringTable.AdGroup, |
| 60 | + field_to_csv=lambda c: c.ad_group_name, |
| 61 | + csv_to_field=lambda c, v: setattr(c, 'ad_group_name', v) |
| 62 | + ), |
| 63 | + _SimpleBulkMapping( |
| 64 | + _StringTable.Audience, |
| 65 | + field_to_csv=lambda c: c.product_audience_name, |
| 66 | + csv_to_field=lambda c, v: setattr(c, 'product_audience_name', v) |
| 67 | + ), |
| 68 | + _SimpleBulkMapping( |
| 69 | + _StringTable.AudienceId, |
| 70 | + field_to_csv=lambda c: field_to_csv_CriterionAudienceId(c.negative_ad_group_criterion), |
| 71 | + csv_to_field=lambda c, v: csv_to_field_CriterionAudienceId(c.negative_ad_group_criterion, int(v) if v else None) |
| 72 | + ), |
| 73 | + ] |
| 74 | + |
| 75 | + @property |
| 76 | + def negative_ad_group_criterion(self): |
| 77 | + """ Defines a Negative Ad Group Criterion """ |
| 78 | + |
| 79 | + return self._negative_ad_group_criterion |
| 80 | + |
| 81 | + @negative_ad_group_criterion.setter |
| 82 | + def negative_ad_group_criterion(self, negative_ad_group_criterion): |
| 83 | + self._negative_ad_group_criterion = negative_ad_group_criterion |
| 84 | + |
| 85 | + @property |
| 86 | + def campaign_name(self): |
| 87 | + """ Defines the name of the Campaign. |
| 88 | +
|
| 89 | + :rtype: str |
| 90 | + """ |
| 91 | + |
| 92 | + return self._campaign_name |
| 93 | + |
| 94 | + @campaign_name.setter |
| 95 | + def campaign_name(self, campaign_name): |
| 96 | + self._campaign_name = campaign_name |
| 97 | + |
| 98 | + @property |
| 99 | + def ad_group_name(self): |
| 100 | + """ Defines the name of the Ad Group |
| 101 | +
|
| 102 | + :rtype: str |
| 103 | + """ |
| 104 | + |
| 105 | + return self._ad_group_name |
| 106 | + |
| 107 | + @ad_group_name.setter |
| 108 | + def ad_group_name(self, ad_group_name): |
| 109 | + self._ad_group_name = ad_group_name |
| 110 | + |
| 111 | + @property |
| 112 | + def product_audience_name(self): |
| 113 | + """ Defines the name of the Product Audience |
| 114 | +
|
| 115 | + :rtype: str |
| 116 | + """ |
| 117 | + |
| 118 | + return self._product_audience_name |
| 119 | + |
| 120 | + @product_audience_name.setter |
| 121 | + def product_audience_name(self, product_audience_name): |
| 122 | + self._product_audience_name = product_audience_name |
| 123 | + |
| 124 | + def process_mappings_from_row_values(self, row_values): |
| 125 | + self._negative_ad_group_criterion = _CAMPAIGN_OBJECT_FACTORY_V11.create('NegativeAdGroupCriterion') |
| 126 | + self._negative_ad_group_criterion.Type = 'NegativeAdGroupCriterion' |
| 127 | + self._negative_ad_group_criterion.Criterion = _CAMPAIGN_OBJECT_FACTORY_V11.create('AudienceCriterion') |
| 128 | + self._negative_ad_group_criterion.Criterion.Type = 'AudienceCriterion' |
| 129 | + row_values.convert_to_entity(self, BulkAdGroupNegativeProductAudienceAssociation._MAPPINGS) |
| 130 | + |
| 131 | + def process_mappings_to_row_values(self, row_values, exclude_readonly_data): |
| 132 | + self._validate_property_not_null(self.negative_ad_group_criterion, 'negative_ad_group_criterion') |
| 133 | + self.convert_to_values(row_values, BulkAdGroupNegativeProductAudienceAssociation._MAPPINGS) |
| 134 | + |
| 135 | + def read_additional_data(self, stream_reader): |
| 136 | + super(BulkAdGroupNegativeProductAudienceAssociation, self).read_additional_data(stream_reader) |
0 commit comments