@@ -74,20 +74,20 @@ def _create_budget(client, customer_id):
7474 """
7575 # Retrieves a new campaign budget operation object.
7676 campaign_budget_operation = client .get_type ('CampaignBudgetOperation' ,
77- version = 'v2 ' )
77+ version = 'v4 ' )
7878 # Creates a campaign budget.
7979 campaign_budget = campaign_budget_operation .create
8080 campaign_budget .name .value = f'Interplanetary Cruise #{ uuid4 ()} '
8181 campaign_budget .amount_micros .value = 50000000
8282 campaign_budget .delivery_method = client .get_type (
83- 'BudgetDeliveryMethodEnum' , version = 'v2 ' ).STANDARD
83+ 'BudgetDeliveryMethodEnum' , version = 'v4 ' ).STANDARD
8484 # An App campaign cannot use a shared campaign budget.
8585 # explicitly_shared must be set to false.
8686 campaign_budget .explicitly_shared .value = False
8787
8888 # Retrieves the campaign budget service.
8989 campaign_budget_service = client .get_service ('CampaignBudgetService' ,
90- version = 'v2 ' )
90+ version = 'v4 ' )
9191 # Submits the campaign budget operation to add the campaign budget.
9292 response = campaign_budget_service .mutate_campaign_budgets (
9393 customer_id , [campaign_budget_operation ])
@@ -107,23 +107,23 @@ def _create_campaign(client, customer_id, budget_resource_name):
107107 Returns:
108108 A resource_name str for the newly created app campaign.
109109 """
110- campaign_service = client .get_service ('CampaignService' , version = 'v2 ' )
111- campaign_operation = client .get_type ('CampaignOperation' , version = 'v2 ' )
110+ campaign_service = client .get_service ('CampaignService' , version = 'v4 ' )
111+ campaign_operation = client .get_type ('CampaignOperation' , version = 'v4 ' )
112112 campaign = campaign_operation .create
113113 campaign .name .value = f'Interplanetary Cruise App #{ uuid4 ()} '
114114 campaign .campaign_budget .value = budget_resource_name
115115 # Recommendation: Set the campaign to PAUSED when creating it to
116116 # prevent the ads from immediately serving. Set to ENABLED once you've
117117 # added targeting and the ads are ready to serve.
118118 campaign .status = client .get_type (
119- 'CampaignStatusEnum' , version = 'v2 ' ).PAUSED
119+ 'CampaignStatusEnum' , version = 'v4 ' ).PAUSED
120120 # All App campaigns have an advertising_channel_type of
121121 # MULTI_CHANNEL to reflect the fact that ads from these campaigns are
122122 # eligible to appear on multiple channels.
123123 campaign .advertising_channel_type = client .get_type (
124- 'AdvertisingChannelTypeEnum' , version = 'v2 ' ).MULTI_CHANNEL
124+ 'AdvertisingChannelTypeEnum' , version = 'v4 ' ).MULTI_CHANNEL
125125 campaign .advertising_channel_sub_type = client .get_type (
126- 'AdvertisingChannelSubTypeEnum' , version = 'v2 ' ).APP_CAMPAIGN
126+ 'AdvertisingChannelSubTypeEnum' , version = 'v4 ' ).APP_CAMPAIGN
127127 # Sets the target CPA to $1 / app install.
128128 #
129129 # campaign_bidding_strategy is a 'oneof' message so setting target_cpa
@@ -136,11 +136,11 @@ def _create_campaign(client, customer_id, budget_resource_name):
136136 campaign .app_campaign_setting .app_id .value = (
137137 'com.google.android.apps.adwords' )
138138 campaign .app_campaign_setting .app_store = client .get_type (
139- 'AppCampaignAppStoreEnum' , version = 'v2 ' ).GOOGLE_APP_STORE
139+ 'AppCampaignAppStoreEnum' , version = 'v4 ' ).GOOGLE_APP_STORE
140140 # Optimize this campaign for getting new users for your app.
141141 campaign .app_campaign_setting .bidding_strategy_goal_type = (client
142142 .get_type ('AppCampaignBiddingStrategyGoalTypeEnum' ,
143- version = 'v2 ' ).OPTIMIZE_INSTALLS_TARGET_INSTALL_COST )
143+ version = 'v4 ' ).OPTIMIZE_INSTALLS_TARGET_INSTALL_COST )
144144 # Optional fields
145145 campaign .start_date .value = (datetime .now () +
146146 timedelta (1 )).strftime ('%Y%m%d' )
@@ -152,7 +152,7 @@ def _create_campaign(client, customer_id, budget_resource_name):
152152 # your campaign on people who are most likely to complete the
153153 # corresponding in-app actions.
154154 # selective_optimization1 = (client.get_type('StringValue',
155- # version='v2 '))
155+ # version='v4 '))
156156 # selective_optimization1.value = (
157157 # 'INSERT_CONVERSION_ACTION_RESOURCE_NAME_HERE')
158158 # campaign.selective_optimization.conversion_actions.extend(
@@ -178,15 +178,15 @@ def _set_campaign_targeting_criteria(client, customer_id,
178178 campaign_resource_name: the campaign to apply targeting to
179179 """
180180 campaign_criterion_service = client .get_service (
181- 'CampaignCriterionService' , version = 'v2 ' )
181+ 'CampaignCriterionService' , version = 'v4 ' )
182182 geo_target_constant_service = client .get_service (
183- 'GeoTargetConstantService' , version = 'v2 ' )
183+ 'GeoTargetConstantService' , version = 'v4 ' )
184184 language_constant_service = client .get_service (
185- 'LanguageConstantService' , version = 'v2 ' )
185+ 'LanguageConstantService' , version = 'v4 ' )
186186 location_type = client .get_type (
187- 'CriterionTypeEnum' , version = 'v2 ' ).LOCATION
187+ 'CriterionTypeEnum' , version = 'v4 ' ).LOCATION
188188 language_type = client .get_type (
189- 'CriterionTypeEnum' , version = 'v2 ' ).LANGUAGE
189+ 'CriterionTypeEnum' , version = 'v4 ' ).LANGUAGE
190190
191191 campaign_criterion_operations = []
192192 # Creates the location campaign criteria.
@@ -197,7 +197,7 @@ def _set_campaign_targeting_criteria(client, customer_id,
197197 for location_id in ['21137' , # California
198198 '2484' ]: # Mexico
199199 campaign_criterion_operation = client .get_type (
200- 'CampaignCriterionOperation' , version = 'v2 ' )
200+ 'CampaignCriterionOperation' , version = 'v4 ' )
201201 campaign_criterion = campaign_criterion_operation .create
202202 campaign_criterion .campaign .value = campaign_resource_name
203203 campaign_criterion .type = location_type
@@ -209,7 +209,7 @@ def _set_campaign_targeting_criteria(client, customer_id,
209209 for language_id in ['1000' , # English
210210 '1003' ]: # Spanish
211211 campaign_criterion_operation = client .get_type (
212- 'CampaignCriterionOperation' , version = 'v2 ' )
212+ 'CampaignCriterionOperation' , version = 'v4 ' )
213213 campaign_criterion = campaign_criterion_operation .create
214214 campaign_criterion .campaign .value = campaign_resource_name
215215 campaign_criterion .type = language_type
@@ -235,18 +235,18 @@ def _create_ad_group(client, customer_id, campaign_resource_name):
235235 Returns:
236236 A resource_name str for the newly created ad group.
237237 """
238- ad_group_service = client .get_service ('AdGroupService' , version = 'v2 ' )
238+ ad_group_service = client .get_service ('AdGroupService' , version = 'v4 ' )
239239
240240 # Creates the ad group.
241241 # Note that the ad group type must not be set.
242242 # Since the advertising_channel_sub_type is APP_CAMPAIGN,
243243 # 1- you cannot override bid settings at the ad group level.
244244 # 2- you cannot add ad group criteria.
245- ad_group_operation = client .get_type ('AdGroupOperation' , version = 'v2 ' )
245+ ad_group_operation = client .get_type ('AdGroupOperation' , version = 'v4 ' )
246246 ad_group = ad_group_operation .create
247247 ad_group .name .value = f'Earth to Mars cruises { uuid4 ()} '
248248 ad_group .status = client .get_type (
249- 'AdGroupStatusEnum' , version = 'v2 ' ).ENABLED
249+ 'AdGroupStatusEnum' , version = 'v4 ' ).ENABLED
250250 ad_group .campaign .value = campaign_resource_name
251251
252252 ad_group_response = ad_group_service .mutate_ad_groups (
@@ -266,11 +266,11 @@ def _create_app_ad(client, customer_id, ad_group_resource_name):
266266 ad_group_resource_name: the ad group where the ad will be added.
267267 """
268268 # Creates the ad group ad.
269- ad_group_ad_service = client .get_service ('AdGroupAdService' , version = 'v2 ' )
270- ad_group_ad_operation = client .get_type ('AdGroupAdOperation' , version = 'v2 ' )
269+ ad_group_ad_service = client .get_service ('AdGroupAdService' , version = 'v4 ' )
270+ ad_group_ad_operation = client .get_type ('AdGroupAdOperation' , version = 'v4 ' )
271271 ad_group_ad = ad_group_ad_operation .create
272272 ad_group_ad .status = client .get_type (
273- 'AdGroupAdStatusEnum' , version = 'v2 ' ).ENABLED
273+ 'AdGroupAdStatusEnum' , version = 'v4 ' ).ENABLED
274274 ad_group_ad .ad_group .value = ad_group_resource_name
275275 # ad_data is a 'oneof' message so setting app_ad
276276 # is mutually exclusive with ad data fields such as
@@ -293,7 +293,7 @@ def _create_app_ad(client, customer_id, ad_group_resource_name):
293293
294294
295295def _create_ad_text_asset (client , text ):
296- ad_text_asset = client .get_type ('AdTextAsset' , version = 'v2 ' )
296+ ad_text_asset = client .get_type ('AdTextAsset' , version = 'v4 ' )
297297 ad_text_asset .text .value = text
298298 return ad_text_asset
299299
0 commit comments