@@ -66,7 +66,7 @@ def main(client, customer_id, campaign_id, ad_group_id):
6666 # Associate the page feed with the campaign.
6767 update_campaign_dsa_setting (client , customer_id , campaign_id ,
6868 feed_details )
69- ad_group_service = client .get_service ('AdGroupService' , version = 'v1 ' )
69+ ad_group_service = client .get_service ('AdGroupService' , version = 'v2 ' )
7070 ad_group_resource_name = ad_group_service .ad_group_path (customer_id ,
7171 ad_group_id )
7272
@@ -96,14 +96,14 @@ def create_feed(client, customer_id):
9696 A FeedDetails instance with information about the newly created feed.
9797 """
9898 # Retrieve a new feed operation object.
99- feed_operation = client .get_type ('FeedOperation' , version = 'v1 ' )
99+ feed_operation = client .get_type ('FeedOperation' , version = 'v2 ' )
100100 # Create a new feed.
101101 feed = feed_operation .create
102102 feed .name .value = 'DSA Feed #{}' .format (uuid .uuid4 ())
103- feed .origin = client .get_type ('FeedOriginEnum' , version = 'v1 ' ).USER
103+ feed .origin = client .get_type ('FeedOriginEnum' , version = 'v2 ' ).USER
104104
105105 feed_attribute_type_enum = client .get_type ('FeedAttributeTypeEnum' ,
106- version = 'v1 ' )
106+ version = 'v2 ' )
107107
108108 # Create the feed's attributes.
109109 feed_attribute_url = feed .attributes .add ()
@@ -115,7 +115,7 @@ def create_feed(client, customer_id):
115115 feed_attribute_label .name .value = 'Label'
116116
117117 # Retrieve the feed service.
118- feed_service = client .get_service ('FeedService' , version = 'v1 ' )
118+ feed_service = client .get_service ('FeedService' , version = 'v2 ' )
119119 # Send the feed operation and add the feed.
120120 response = feed_service .mutate_feeds (customer_id , [feed_operation ])
121121
@@ -144,7 +144,7 @@ def get_feed_details(client, customer_id, resource_name):
144144 LIMIT 1
145145 ''' .format (resource_name )
146146
147- ga_service = client .get_service ('GoogleAdsService' , version = 'v1 ' )
147+ ga_service = client .get_service ('GoogleAdsService' , version = 'v2 ' )
148148 response = ga_service .search (customer_id , query = query )
149149
150150 # Maps specific fields in each row in the response to a dict. This would
@@ -169,14 +169,14 @@ def create_feed_mapping(client, customer_id, feed_details):
169169 """
170170 # Retrieve a new feed mapping operation object.
171171 feed_mapping_operation = client .get_type ('FeedMappingOperation' ,
172- version = 'v1 ' )
172+ version = 'v2 ' )
173173 # Create a new feed mapping.
174174 feed_mapping = feed_mapping_operation .create
175175 feed_mapping .criterion_type = client .get_type (
176- 'FeedMappingCriterionTypeEnum' , version = 'v1 ' ).DSA_PAGE_FEED
176+ 'FeedMappingCriterionTypeEnum' , version = 'v2 ' ).DSA_PAGE_FEED
177177 feed_mapping .feed .value = feed_details .resource_name
178178 dsa_page_feed_field_enum = client .get_type ('DsaPageFeedCriterionFieldEnum' ,
179- version = 'v1 ' )
179+ version = 'v2 ' )
180180
181181 url_field_mapping = feed_mapping .attribute_field_mappings .add ()
182182 url_field_mapping .feed_attribute_id .value = feed_details .url_attribute_id
@@ -189,7 +189,7 @@ def create_feed_mapping(client, customer_id, feed_details):
189189
190190 # Retrieve the feed mapping service.
191191 feed_mapping_service = client .get_service ('FeedMappingService' ,
192- version = 'v1 ' )
192+ version = 'v2 ' )
193193 # Submit the feed mapping operation and add the feed mapping.
194194 response = feed_mapping_service .mutate_feed_mappings (
195195 customer_id , [feed_mapping_operation ])
@@ -215,7 +215,7 @@ def create_feed_items(client, customer_id, feed_details, label):
215215 "http://www.example.com/discounts/flight-deals" ]
216216
217217 def map_feed_urls (url ):
218- feed_item_operation = client .get_type ('FeedItemOperation' , version = 'v1 ' )
218+ feed_item_operation = client .get_type ('FeedItemOperation' , version = 'v2 ' )
219219 feed_item = feed_item_operation .create
220220 feed_item .feed .value = feed_details .resource_name
221221
@@ -237,7 +237,7 @@ def map_feed_urls(url):
237237 feed_item_operations = list (map (map_feed_urls , urls ))
238238
239239 # Retrieve the feed item service.
240- feed_item_service = client .get_service ('FeedItemService' , version = 'v1 ' )
240+ feed_item_service = client .get_service ('FeedItemService' , version = 'v2 ' )
241241 # Submit the feed item operations and add the feed items.
242242 response = feed_item_service .mutate_feed_items (customer_id ,
243243 feed_item_operations )
@@ -269,7 +269,7 @@ def update_campaign_dsa_setting(client, customer_id, campaign_id, feed_details):
269269 LIMIT 1
270270 ''' .format (campaign_id )
271271
272- ga_service = client .get_service ('GoogleAdsService' , version = 'v1 ' )
272+ ga_service = client .get_service ('GoogleAdsService' , version = 'v2 ' )
273273 results = ga_service .search (customer_id , query = query )
274274
275275 for row in results :
@@ -284,7 +284,7 @@ def update_campaign_dsa_setting(client, customer_id, campaign_id, feed_details):
284284 campaign_id ))
285285
286286 # Retrieve a new campaign operation
287- campaign_operation = client .get_type ('CampaignOperation' , version = 'v1 ' )
287+ campaign_operation = client .get_type ('CampaignOperation' , version = 'v2 ' )
288288 # Copy the retrieved campaign onto the new campaign operation.
289289 campaign_operation .update .CopyFrom (campaign )
290290 updated_campaign = campaign_operation .update
@@ -296,7 +296,7 @@ def update_campaign_dsa_setting(client, customer_id, campaign_id, feed_details):
296296 campaign_operation .update_mask .CopyFrom (field_mask )
297297
298298 # Retrieve the campaign service.
299- campaign_service = client .get_service ('CampaignService' , version = 'v1 ' )
299+ campaign_service = client .get_service ('CampaignService' , version = 'v2 ' )
300300 # Submit the campaign operation and update the campaign.
301301 response = campaign_service .mutate_campaigns (customer_id ,
302302 [campaign_operation ])
@@ -317,7 +317,7 @@ def add_dsa_targeting(client, customer_id, ad_group_resource_name, label):
317317 """
318318 # Retrieve a new ad group criterion operation object.
319319 ad_group_criterion_operation = client .get_type (
320- 'AdGroupCriterionOperation' , version = 'v1 ' )
320+ 'AdGroupCriterionOperation' , version = 'v2 ' )
321321 # Create a new ad group criterion.
322322 ad_group_criterion = ad_group_criterion_operation .create
323323 ad_group_criterion .ad_group .value = ad_group_resource_name
@@ -328,11 +328,11 @@ def add_dsa_targeting(client, customer_id, ad_group_resource_name, label):
328328 webpage_criterion_info = ad_group_criterion .webpage .conditions .add ()
329329 webpage_criterion_info .argument .value = label
330330 webpage_criterion_info .operand = client .get_type (
331- 'WebpageConditionOperandEnum' , version = 'v1 ' ).CUSTOM_LABEL
331+ 'WebpageConditionOperandEnum' , version = 'v2 ' ).CUSTOM_LABEL
332332
333333 # Retrieve the ad group criterion service.
334334 ad_group_criterion_service = client .get_service ('AdGroupCriterionService' ,
335- version = 'v1 ' )
335+ version = 'v2 ' )
336336 response = ad_group_criterion_service .mutate_ad_group_criteria (
337337 customer_id , [ad_group_criterion_operation ])
338338 resource_name = response .results [0 ].resource_name
0 commit comments