@@ -73,9 +73,9 @@ def _create_budget(client, customer_id):
7373 campaign_budget = campaign_budget_operation .create
7474 campaign_budget .name = f"Interplanetary Cruise #{ uuid4 ()} "
7575 campaign_budget .amount_micros = 50000000
76- campaign_budget .delivery_method = client . get_type (
77- " BudgetDeliveryMethodEnum"
78- ). BudgetDeliveryMethod . STANDARD
76+ campaign_budget .delivery_method = (
77+ client . enums . BudgetDeliveryMethodEnum . STANDARD
78+ )
7979 # An App campaign cannot use a shared campaign budget.
8080 # explicitly_shared must be set to false.
8181 campaign_budget .explicitly_shared = False
@@ -108,18 +108,16 @@ def _create_campaign(client, customer_id, budget_resource_name):
108108 # Recommendation: Set the campaign to PAUSED when creating it to
109109 # prevent the ads from immediately serving. Set to ENABLED once you've
110110 # added targeting and the ads are ready to serve.
111- campaign .status = client .get_type (
112- "CampaignStatusEnum"
113- ).CampaignStatus .PAUSED
111+ campaign .status = client .enums .CampaignStatusEnum .PAUSED
114112 # All App campaigns have an advertising_channel_type of
115113 # MULTI_CHANNEL to reflect the fact that ads from these campaigns are
116114 # eligible to appear on multiple channels.
117- campaign .advertising_channel_type = client . get_type (
118- " AdvertisingChannelTypeEnum"
119- ). AdvertisingChannelType . MULTI_CHANNEL
120- campaign .advertising_channel_sub_type = client . get_type (
121- " AdvertisingChannelSubTypeEnum"
122- ). AdvertisingChannelSubType . APP_CAMPAIGN
115+ campaign .advertising_channel_type = (
116+ client . enums . AdvertisingChannelTypeEnum . MULTI_CHANNEL
117+ )
118+ campaign .advertising_channel_sub_type = (
119+ client . enums . AdvertisingChannelSubTypeEnum . APP_CAMPAIGN
120+ )
123121 # Sets the target CPA to $1 / app install.
124122 #
125123 # campaign_bidding_strategy is a 'oneof' message so setting target_cpa
@@ -130,13 +128,13 @@ def _create_campaign(client, customer_id, budget_resource_name):
130128 campaign .target_cpa .target_cpa_micros = 1000000
131129 # Sets the App Campaign Settings.
132130 campaign .app_campaign_setting .app_id = "com.google.android.apps.adwords"
133- campaign .app_campaign_setting .app_store = client . get_type (
134- " AppCampaignAppStoreEnum"
135- ). AppCampaignAppStore . GOOGLE_APP_STORE
131+ campaign .app_campaign_setting .app_store = (
132+ client . enums . AppCampaignAppStoreEnum . GOOGLE_APP_STORE
133+ )
136134 # Optimize this campaign for getting new users for your app.
137- campaign .app_campaign_setting .bidding_strategy_goal_type = client . get_type (
138- " AppCampaignBiddingStrategyGoalTypeEnum"
139- ). AppCampaignBiddingStrategyGoalType . OPTIMIZE_INSTALLS_TARGET_INSTALL_COST
135+ campaign .app_campaign_setting .bidding_strategy_goal_type = (
136+ client . enums . AppCampaignBiddingStrategyGoalTypeEnum . OPTIMIZE_INSTALLS_TARGET_INSTALL_COST
137+ )
140138 # Optional fields
141139 campaign .start_date = (datetime .now () + timedelta (1 )).strftime ("%Y%m%d" )
142140 campaign .end_date = (datetime .now () + timedelta (365 )).strftime ("%Y%m%d" )
@@ -172,8 +170,8 @@ def _set_campaign_targeting_criteria(
172170 campaign_resource_name: the campaign to apply targeting to
173171 """
174172 campaign_criterion_service = client .get_service ("CampaignCriterionService" )
175- location_type = client .get_type ( "CriterionTypeEnum" ). CriterionType .LOCATION
176- language_type = client .get_type ( "CriterionTypeEnum" ). CriterionType .LANGUAGE
173+ location_type = client .enums . CriterionTypeEnum .LOCATION
174+ language_type = client .enums . CriterionTypeEnum .LANGUAGE
177175 geo_target_constant_service = client .get_service ("GeoTargetConstantService" )
178176 language_constant_service = client .get_service ("LanguageConstantService" )
179177
@@ -190,8 +188,8 @@ def _set_campaign_targeting_criteria(
190188 campaign_criterion = campaign_criterion_operation .create
191189 campaign_criterion .campaign = campaign_resource_name
192190 campaign_criterion .type_ = location_type
193- campaign_criterion .location .geo_target_constant = geo_target_constant_service . geo_target_constant_path (
194- location_id
191+ campaign_criterion .location .geo_target_constant = (
192+ geo_target_constant_service . geo_target_constant_path ( location_id )
195193 )
196194 campaign_criterion_operations .append (campaign_criterion_operation )
197195
@@ -203,8 +201,8 @@ def _set_campaign_targeting_criteria(
203201 campaign_criterion = campaign_criterion_operation .create
204202 campaign_criterion .campaign = campaign_resource_name
205203 campaign_criterion .type_ = language_type
206- campaign_criterion .language .language_constant = language_constant_service . language_constant_path (
207- language_id
204+ campaign_criterion .language .language_constant = (
205+ language_constant_service . language_constant_path ( language_id )
208206 )
209207 campaign_criterion_operations .append (campaign_criterion_operation )
210208
@@ -239,7 +237,7 @@ def _create_ad_group(client, customer_id, campaign_resource_name):
239237 ad_group_operation = client .get_type ("AdGroupOperation" )
240238 ad_group = ad_group_operation .create
241239 ad_group .name = f"Earth to Mars cruises { uuid4 ()} "
242- ad_group .status = client .get_type ( "AdGroupStatusEnum" ). AdGroupStatus .ENABLED
240+ ad_group .status = client .enums . AdGroupStatusEnum .ENABLED
243241 ad_group .campaign = campaign_resource_name
244242
245243 ad_group_response = ad_group_service .mutate_ad_groups (
@@ -263,9 +261,7 @@ def _create_app_ad(client, customer_id, ad_group_resource_name):
263261 ad_group_ad_service = client .get_service ("AdGroupAdService" )
264262 ad_group_ad_operation = client .get_type ("AdGroupAdOperation" )
265263 ad_group_ad = ad_group_ad_operation .create
266- ad_group_ad .status = client .get_type (
267- "AdGroupAdStatusEnum"
268- ).AdGroupAdStatus .ENABLED
264+ ad_group_ad .status = client .enums .AdGroupAdStatusEnum .ENABLED
269265 ad_group_ad .ad_group = ad_group_resource_name
270266 # ad_data is a 'oneof' message so setting app_ad
271267 # is mutually exclusive with ad data fields such as
0 commit comments