Skip to content

Commit

Permalink
Changes for release v4_0 and Deprecation of v1_0. (#290)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenRKarl authored Jul 15, 2020
1 parent 506cba4 commit f63e318
Show file tree
Hide file tree
Showing 2,196 changed files with 137,373 additions and 113,219 deletions.
6 changes: 6 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
* 6.0.0
- Google Ads v4_0 release
- Deprecate v1_0
- Updates to various examples to standardize param names and make
changes to support v4.

* 5.1.0
- Google Ads v3_1 release
- Add add_campaign_labels example
Expand Down
4 changes: 2 additions & 2 deletions examples/account_management/create_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,8 @@


def main(client, manager_customer_id):
customer_service = client.get_service('CustomerService', version='v3')
customer = client.get_type('Customer', version='v3')
customer_service = client.get_service('CustomerService', version='v4')
customer = client.get_type('Customer', version='v4')
today = datetime.today().strftime('%Y%m%d %H:%M:%S')
customer.descriptive_name.value = ('Account created with '
'CustomerService on %s' % today)
Expand Down
6 changes: 3 additions & 3 deletions examples/account_management/get_account_changes.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def resource_name_for_resource_type(resource_type, row):


def main(client, customer_id):
ads_service = client.get_service('GoogleAdsService', version='v3')
ads_service = client.get_service('GoogleAdsService', version='v4')
query = ('SELECT change_status.resource_name, '
'change_status.last_change_date_time, '
'change_status.resource_type, '
Expand All @@ -74,9 +74,9 @@ def main(client, customer_id):
page_size=ADS_PAGE_SIZE)

resource_type_enum = (client.get_type(
'ChangeStatusResourceTypeEnum', version='v3').ChangeStatusResourceType)
'ChangeStatusResourceTypeEnum', version='v4').ChangeStatusResourceType)
change_status_operation_enum = (client.get_type(
'ChangeStatusOperationEnum', version='v3').ChangeStatusOperation)
'ChangeStatusOperationEnum', version='v4').ChangeStatusOperation)

try:
for row in response:
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/get_account_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@


def main(client, customer_id):
customer_service = client.get_service('CustomerService', version='v3')
customer_service = client.get_service('CustomerService', version='v4')

resource_name = customer_service.customer_path(customer_id)

Expand Down
12 changes: 6 additions & 6 deletions examples/account_management/link_manager_to_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,14 @@ def main(client, customer_id, manager_customer_id):

# Extend an invitation to the client while authenticating as the manager.
client_link_operation = client.get_type(
'CustomerClientLinkOperation', version='v3')
'CustomerClientLinkOperation', version='v4')
client_link = client_link_operation.create
client_link.client_customer.value = 'customers/{}'.format(customer_id)
client_link.status = client.get_type(
'ManagerLinkStatusEnum').PENDING

customer_client_link_service = client.get_service(
'CustomerClientLinkService', version='v3')
'CustomerClientLinkService', version='v4')
response = customer_client_link_service.mutate_customer_client_link(
manager_customer_id, client_link_operation)
resource_name = response.results[0].resource_name
Expand All @@ -64,7 +64,7 @@ def main(client, customer_id, manager_customer_id):
customer_client_link.resource_name = "{}"
'''.format(resource_name)

ga_service = client.get_service('GoogleAdsService', version='v3')
ga_service = client.get_service('GoogleAdsService', version='v4')
response = ga_service.search(manager_customer_id, query=query)

# Since the google_ads_service.search method returns an iterator we need
Expand All @@ -74,18 +74,18 @@ def main(client, customer_id, manager_customer_id):
manager_link_id = row.customer_client_link.manager_link_id

manager_link_operation = client.get_type(
'CustomerManagerLinkOperation', version='v3')
'CustomerManagerLinkOperation', version='v4')
manager_link = manager_link_operation.update
manager_link.resource_name.value = (
'customers/{}/customerManagerLinks/{}~{}'.format(
customer_id, manager_customer_id, manager_link_id))

manager_link.status = client.get_type('ManagerLinkStatusEnum', version='v3')
manager_link.status = client.get_type('ManagerLinkStatusEnum', version='v4')
field_mask = protobuf_helpers.field_mask(None, manager_link)
manager_link_operation.update_mask.CopyFrom(field_mask)

manager_link_service = client.get_service('ManagerLinkService',
version='v3')
version='v4')
response = manager_link_service.mutate_manager_links(
manager_customer_id, [manager_link_operation])
resource_name = response.results[0].resource_name
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/list_accessible_customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@


def main(client):
customer_service = client.get_service('CustomerService', version='v3')
customer_service = client.get_service('CustomerService', version='v4')

try:
accessible_customers = customer_service.list_accessible_customers()
Expand Down
6 changes: 3 additions & 3 deletions examples/advanced_operations/add_ad_group_bid_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@


def main(client, customer_id, ad_group_id, bid_modifier_value):
ad_group_service = client.get_service('AdGroupService', version='v3')
ad_group_service = client.get_service('AdGroupService', version='v4')
ad_group_bm_service = client.get_service('AdGroupBidModifierService',
version='v3')
version='v4')

# Create ad group bid modifier for mobile devices with the specified ad
# group ID and bid modifier value.
Expand All @@ -44,7 +44,7 @@ def main(client, customer_id, ad_group_id, bid_modifier_value):

# Sets the device.
ad_group_bid_modifier.device.type = client.get_type('DeviceEnum',
version='v3').MOBILE
version='v4').MOBILE

# Add the ad group bid modifier.
try:
Expand Down
50 changes: 25 additions & 25 deletions examples/advanced_operations/add_app_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,20 +74,20 @@ def _create_budget(client, customer_id):
"""
# Retrieves a new campaign budget operation object.
campaign_budget_operation = client.get_type('CampaignBudgetOperation',
version='v2')
version='v4')
# Creates a campaign budget.
campaign_budget = campaign_budget_operation.create
campaign_budget.name.value = f'Interplanetary Cruise #{uuid4()}'
campaign_budget.amount_micros.value = 50000000
campaign_budget.delivery_method = client.get_type(
'BudgetDeliveryMethodEnum', version='v2').STANDARD
'BudgetDeliveryMethodEnum', version='v4').STANDARD
# An App campaign cannot use a shared campaign budget.
# explicitly_shared must be set to false.
campaign_budget.explicitly_shared.value = False

# Retrieves the campaign budget service.
campaign_budget_service = client.get_service('CampaignBudgetService',
version='v2')
version='v4')
# Submits the campaign budget operation to add the campaign budget.
response = campaign_budget_service.mutate_campaign_budgets(
customer_id, [campaign_budget_operation])
Expand All @@ -107,23 +107,23 @@ def _create_campaign(client, customer_id, budget_resource_name):
Returns:
A resource_name str for the newly created app campaign.
"""
campaign_service = client.get_service('CampaignService', version='v2')
campaign_operation = client.get_type('CampaignOperation', version='v2')
campaign_service = client.get_service('CampaignService', version='v4')
campaign_operation = client.get_type('CampaignOperation', version='v4')
campaign = campaign_operation.create
campaign.name.value = f'Interplanetary Cruise App #{uuid4()}'
campaign.campaign_budget.value = budget_resource_name
# Recommendation: Set the campaign to PAUSED when creating it to
# prevent the ads from immediately serving. Set to ENABLED once you've
# added targeting and the ads are ready to serve.
campaign.status = client.get_type(
'CampaignStatusEnum', version='v2').PAUSED
'CampaignStatusEnum', version='v4').PAUSED
# All App campaigns have an advertising_channel_type of
# MULTI_CHANNEL to reflect the fact that ads from these campaigns are
# eligible to appear on multiple channels.
campaign.advertising_channel_type = client.get_type(
'AdvertisingChannelTypeEnum', version='v2').MULTI_CHANNEL
'AdvertisingChannelTypeEnum', version='v4').MULTI_CHANNEL
campaign.advertising_channel_sub_type = client.get_type(
'AdvertisingChannelSubTypeEnum', version='v2').APP_CAMPAIGN
'AdvertisingChannelSubTypeEnum', version='v4').APP_CAMPAIGN
# Sets the target CPA to $1 / app install.
#
# campaign_bidding_strategy is a 'oneof' message so setting target_cpa
Expand All @@ -136,11 +136,11 @@ def _create_campaign(client, customer_id, budget_resource_name):
campaign.app_campaign_setting.app_id.value = (
'com.google.android.apps.adwords')
campaign.app_campaign_setting.app_store = client.get_type(
'AppCampaignAppStoreEnum', version='v2').GOOGLE_APP_STORE
'AppCampaignAppStoreEnum', version='v4').GOOGLE_APP_STORE
# Optimize this campaign for getting new users for your app.
campaign.app_campaign_setting.bidding_strategy_goal_type = (client
.get_type('AppCampaignBiddingStrategyGoalTypeEnum',
version='v2').OPTIMIZE_INSTALLS_TARGET_INSTALL_COST)
version='v4').OPTIMIZE_INSTALLS_TARGET_INSTALL_COST)
# Optional fields
campaign.start_date.value = (datetime.now() +
timedelta(1)).strftime('%Y%m%d')
Expand All @@ -152,7 +152,7 @@ def _create_campaign(client, customer_id, budget_resource_name):
# your campaign on people who are most likely to complete the
# corresponding in-app actions.
# selective_optimization1 = (client.get_type('StringValue',
# version='v2'))
# version='v4'))
# selective_optimization1.value = (
# 'INSERT_CONVERSION_ACTION_RESOURCE_NAME_HERE')
# campaign.selective_optimization.conversion_actions.extend(
Expand All @@ -178,15 +178,15 @@ def _set_campaign_targeting_criteria(client, customer_id,
campaign_resource_name: the campaign to apply targeting to
"""
campaign_criterion_service = client.get_service(
'CampaignCriterionService', version='v2')
'CampaignCriterionService', version='v4')
geo_target_constant_service = client.get_service(
'GeoTargetConstantService', version='v2')
'GeoTargetConstantService', version='v4')
language_constant_service = client.get_service(
'LanguageConstantService', version='v2')
'LanguageConstantService', version='v4')
location_type = client.get_type(
'CriterionTypeEnum', version='v2').LOCATION
'CriterionTypeEnum', version='v4').LOCATION
language_type = client.get_type(
'CriterionTypeEnum', version='v2').LANGUAGE
'CriterionTypeEnum', version='v4').LANGUAGE

campaign_criterion_operations = []
# Creates the location campaign criteria.
Expand All @@ -197,7 +197,7 @@ def _set_campaign_targeting_criteria(client, customer_id,
for location_id in ['21137', # California
'2484']: # Mexico
campaign_criterion_operation = client.get_type(
'CampaignCriterionOperation', version='v2')
'CampaignCriterionOperation', version='v4')
campaign_criterion = campaign_criterion_operation.create
campaign_criterion.campaign.value = campaign_resource_name
campaign_criterion.type = location_type
Expand All @@ -209,7 +209,7 @@ def _set_campaign_targeting_criteria(client, customer_id,
for language_id in ['1000', # English
'1003']: # Spanish
campaign_criterion_operation = client.get_type(
'CampaignCriterionOperation', version='v2')
'CampaignCriterionOperation', version='v4')
campaign_criterion = campaign_criterion_operation.create
campaign_criterion.campaign.value = campaign_resource_name
campaign_criterion.type = language_type
Expand All @@ -235,18 +235,18 @@ def _create_ad_group(client, customer_id, campaign_resource_name):
Returns:
A resource_name str for the newly created ad group.
"""
ad_group_service = client.get_service('AdGroupService', version='v2')
ad_group_service = client.get_service('AdGroupService', version='v4')

# Creates the ad group.
# Note that the ad group type must not be set.
# Since the advertising_channel_sub_type is APP_CAMPAIGN,
# 1- you cannot override bid settings at the ad group level.
# 2- you cannot add ad group criteria.
ad_group_operation = client.get_type('AdGroupOperation', version='v2')
ad_group_operation = client.get_type('AdGroupOperation', version='v4')
ad_group = ad_group_operation.create
ad_group.name.value = f'Earth to Mars cruises {uuid4()}'
ad_group.status = client.get_type(
'AdGroupStatusEnum', version='v2').ENABLED
'AdGroupStatusEnum', version='v4').ENABLED
ad_group.campaign.value = campaign_resource_name

ad_group_response = ad_group_service.mutate_ad_groups(
Expand All @@ -266,11 +266,11 @@ def _create_app_ad(client, customer_id, ad_group_resource_name):
ad_group_resource_name: the ad group where the ad will be added.
"""
# Creates the ad group ad.
ad_group_ad_service = client.get_service('AdGroupAdService', version='v2')
ad_group_ad_operation = client.get_type('AdGroupAdOperation', version='v2')
ad_group_ad_service = client.get_service('AdGroupAdService', version='v4')
ad_group_ad_operation = client.get_type('AdGroupAdOperation', version='v4')
ad_group_ad = ad_group_ad_operation.create
ad_group_ad.status = client.get_type(
'AdGroupAdStatusEnum', version='v2').ENABLED
'AdGroupAdStatusEnum', version='v4').ENABLED
ad_group_ad.ad_group.value = ad_group_resource_name
# ad_data is a 'oneof' message so setting app_ad
# is mutually exclusive with ad data fields such as
Expand All @@ -293,7 +293,7 @@ def _create_app_ad(client, customer_id, ad_group_resource_name):


def _create_ad_text_asset(client, text):
ad_text_asset = client.get_type('AdTextAsset', version='v2')
ad_text_asset = client.get_type('AdTextAsset', version='v4')
ad_text_asset.text.value = text
return ad_text_asset

Expand Down
Loading

0 comments on commit f63e318

Please sign in to comment.