Skip to content

Commit

Permalink
Changes for release v16_0. (#841)
Browse files Browse the repository at this point in the history
  • Loading branch information
BenRKarl committed Feb 23, 2024
1 parent 720b39e commit 2e100cb
Show file tree
Hide file tree
Showing 1,535 changed files with 234,893 additions and 2,964 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 1,11 @@
* 23.1.0
- Google Ads API v16 release.
- Use native `open` function to load README in setup.py.
- Remove `namespace_packages` parameter in call to `setup` in setup.py.
- Remove `upload_image` and `upload_media_bundle` examples.
- Combine detect and apply recommendations examples.
- Update extensions-related examples to use assets instead.

* 23.0.0
- Remove support for Python 3.7
- Add support for Python 3.11 and 3.12
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/create_customer.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 58,7 @@ def main(client, manager_customer_id):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=("Creates a new client under the given manager.")
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/get_account_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 179,7 @@ def print_account_hierarchy(
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description="This example gets the account hierarchy of the specified "
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/get_change_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 186,7 @@ def main(client, customer_id):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description="This example gets specific details about the most recent "
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/get_change_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 85,7 @@ def main(client, customer_id):
if __name__ == "__main__":
# GoogleAdsClient will read a google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 59,7 @@ def main(client, customer_id, email_address, access_role):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/link_manager_to_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 112,7 @@ def main(client, customer_id, manager_customer_id):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
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 @@ -44,7 44,7 @@ def main(client):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

try:
main(googleads_client)
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/update_user_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 137,7 @@ def modify_user_access(client, customer_id, user_id, access_role):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description="This code example updates the access role of a user, "
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_ad_customizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 263,7 @@ def create_ad_with_customizations(
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_ad_group_bid_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 65,7 @@ def main(client, customer_id, ad_group_id, bid_modifier_value):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_app_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -295,7 295,7 @@ def create_ad_text_asset(client, text):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_bidding_data_exclusion.py
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 80,7 @@ def main(client, customer_id, start_date_time, end_date_time):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description="Adds a data exclusion for conversions in Smart Bidding "
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 94,7 @@ def main(
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description="Adds a seasonality adjustment for conversions in Smart "
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_call_ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 101,7 @@ def main(
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=("Adds a call extension to a specific account.")
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_display_upload_ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 150,7 @@ def create_display_upload_ad_group_ad(
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description="Adds a display upload ad to a given ad group."
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 260,7 @@ def add_dsa_target(client, customer_id, ad_group_id, dsa_page_url_label):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_dynamic_search_ads.py
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 260,7 @@ def add_webpage_criterion(client, customer_id, ad_group_resource_name):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 670,7 @@ def create_asset_group_signal_operation(client, customer_id, audience_id):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=("Creates a Performance Max campaign.")
Expand Down
87 changes: 63 additions & 24 deletions examples/advanced_operations/add_responsive_search_ad_full.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 51,9 @@
_COUNTRY_CODE = "AR"


def main(client, customer_id, omit_image_extensions, customizer_attribute_name=None):
def main(
client, customer_id, omit_image_extensions, customizer_attribute_name=None
):
"""
The main method that creates all necessary entities for the example.
Expand All @@ -75,7 77,9 @@ def main(client, customer_id, omit_image_extensions, customizer_attribute_name=N
# Create a budget, which can be shared by multiple campaigns.
campaign_budget = create_campaign_budget(client, customer_id)

campaign_resource_name = create_campaign(client, customer_id, campaign_budget)
campaign_resource_name = create_campaign(
client, customer_id, campaign_budget
)

ad_group_resource_name = create_ad_group(
client, customer_id, campaign_resource_name
Expand Down Expand Up @@ -122,7 126,9 @@ def create_customizer_attribute(client, customer_id, customizer_attribute_name):

# Issue a mutate request to add the customizer attribute and prints its
# information.
customizer_attribute_service = client.get_service("CustomizerAttributeService")
customizer_attribute_service = client.get_service(
"CustomizerAttributeService"
)
response = customizer_attribute_service.mutate_customizer_attributes(
customer_id=customer_id, operations=[operation]
)
Expand Down Expand Up @@ -153,13 159,19 @@ def link_customizer_attribute_to_customer(
# Create a customer customizer with the value to be used in the responsive
# search ad.
customer_customizer = operation.create
customer_customizer.customizer_attribute = customizer_attribute_resource_name
customer_customizer.value.type_ = client.enums.CustomizerAttributeTypeEnum.PRICE
customer_customizer.customizer_attribute = (
customizer_attribute_resource_name
)
customer_customizer.value.type_ = (
client.enums.CustomizerAttributeTypeEnum.PRICE
)
# The ad customizer will dynamically replace the placeholder with this value
# when the ad serves.
customer_customizer.value.string_value = "100USD"

customer_customizer_service = client.get_service("CustomerCustomizerService")
customer_customizer_service = client.get_service(
"CustomerCustomizerService"
)
# Issue a mutate request to create the customer customizer and prints its
# information.
response = customer_customizer_service.mutate_customer_customizers(
Expand Down Expand Up @@ -192,7 204,9 @@ def create_ad_text_asset(client, text, pinned_field=None):
return ad_text_asset


def create_ad_text_asset_with_customizer(client, customizer_attribute_resource_name):
def create_ad_text_asset_with_customizer(
client, customizer_attribute_resource_name
):
"""Create an AdTextAsset.
Args:
client: an initialized GoogleAdsClient instance.
Expand Down Expand Up @@ -230,7 244,9 @@ def create_campaign_budget(client, customer_id):
campaign_budget_operation = client.get_type("CampaignBudgetOperation")
campaign_budget = campaign_budget_operation.create
campaign_budget.name = f"Campaign budget {uuid.uuid4()}"
campaign_budget.delivery_method = client.enums.BudgetDeliveryMethodEnum.STANDARD
campaign_budget.delivery_method = (
client.enums.BudgetDeliveryMethodEnum.STANDARD
)
campaign_budget.amount_micros = 500000

# Add budget.
Expand All @@ -256,7 272,9 @@ def create_campaign(client, customer_id, campaign_budget):
campaign_operation = client.get_type("CampaignOperation")
campaign = campaign_operation.create
campaign.name = f"Testing RSA via API {uuid.uuid4()}"
campaign.advertising_channel_type = client.enums.AdvertisingChannelTypeEnum.SEARCH
campaign.advertising_channel_type = (
client.enums.AdvertisingChannelTypeEnum.SEARCH
)

# Recommendation: Set the campaign to PAUSED when creating it to prevent
# the ads from immediately serving. Set to ENABLED once you've added
Expand Down Expand Up @@ -433,7 451,9 @@ def add_keywords(client, customer_id, ad_group_resource_name):
ad_group_criterion.ad_group = ad_group_resource_name
ad_group_criterion.status = client.enums.AdGroupCriterionStatusEnum.ENABLED
ad_group_criterion.keyword.text = _KEYWORD_TEXT_EXACT_1
ad_group_criterion.keyword.match_type = client.enums.KeywordMatchTypeEnum.EXACT
ad_group_criterion.keyword.match_type = (
client.enums.KeywordMatchTypeEnum.EXACT
)

# Uncomment the below line if you want to change this keyword to a negative target.
# ad_group_criterion.negative = True
Expand All @@ -450,7 470,9 @@ def add_keywords(client, customer_id, ad_group_resource_name):
ad_group_criterion.ad_group = ad_group_resource_name
ad_group_criterion.status = client.enums.AdGroupCriterionStatusEnum.ENABLED
ad_group_criterion.keyword.text = _KEYWORD_TEXT_PHRASE_1
ad_group_criterion.keyword.match_type = client.enums.KeywordMatchTypeEnum.PHRASE
ad_group_criterion.keyword.match_type = (
client.enums.KeywordMatchTypeEnum.PHRASE
)

# Uncomment the below line if you want to change this keyword to a negative target.
# ad_group_criterion.negative = True
Expand All @@ -467,7 489,9 @@ def add_keywords(client, customer_id, ad_group_resource_name):
ad_group_criterion.ad_group = ad_group_resource_name
ad_group_criterion.status = client.enums.AdGroupCriterionStatusEnum.ENABLED
ad_group_criterion.keyword.text = _KEYWORD_TEXT_BROAD_1
ad_group_criterion.keyword.match_type = client.enums.KeywordMatchTypeEnum.BROAD
ad_group_criterion.keyword.match_type = (
client.enums.KeywordMatchTypeEnum.BROAD
)

# Uncomment the below line if you want to change this keyword to a negative target.
# ad_group_criterion.negative = True
Expand All @@ -482,9 506,11 @@ def add_keywords(client, customer_id, ad_group_resource_name):
campaign_criterion_operations = operations

# Add keywords
ad_group_criterion_response = ad_group_criterion_service.mutate_ad_group_criteria(
customer_id=customer_id,
operations=[*campaign_criterion_operations],
ad_group_criterion_response = (
ad_group_criterion_service.mutate_ad_group_criteria(
customer_id=customer_id,
operations=[*campaign_criterion_operations],
)
)
for result in ad_group_criterion_response.results:
print("Created keyword " f"{result.resource_name}.")
Expand Down Expand Up @@ -515,7 541,9 @@ def add_geo_targeting(client, customer_id, campaign_resource_name):
[_GEO_LOCATION_1, _GEO_LOCATION_2, _GEO_LOCATION_3]
)

results = geo_target_constant_service.suggest_geo_target_constants(gtc_request)
results = geo_target_constant_service.suggest_geo_target_constants(
gtc_request
)

operations = []
for suggestion in results.geo_target_constant_suggestions:
Expand All @@ -526,7 554,9 @@ def add_geo_targeting(client, customer_id, campaign_resource_name):
f"from search term ({suggestion.search_term})."
)
# Create the campaign criterion for location targeting.
campaign_criterion_operation = client.get_type("CampaignCriterionOperation")
campaign_criterion_operation = client.get_type(
"CampaignCriterionOperation"
)
campaign_criterion = campaign_criterion_operation.create
campaign_criterion.campaign = campaign_resource_name
campaign_criterion.location.geo_target_constant = (
Expand All @@ -535,8 565,10 @@ def add_geo_targeting(client, customer_id, campaign_resource_name):
operations.append(campaign_criterion_operation)

campaign_criterion_service = client.get_service("CampaignCriterionService")
campaign_criterion_response = campaign_criterion_service.mutate_campaign_criteria(
customer_id=customer_id, operations=[*operations]
campaign_criterion_response = (
campaign_criterion_service.mutate_campaign_criteria(
customer_id=customer_id, operations=[*operations]
)
)

for result in campaign_criterion_response.results:
Expand Down Expand Up @@ -583,16 615,23 @@ def add_images(client, customer_id, campaign_resource_name):

# Step 6.2 - Create Image Extension
extension_feed_item_service = client.get_service("ExtensionFeedItemService")
extension_feed_item_operation = client.get_type("ExtensionFeedItemOperation")
extension_feed_item_operation = client.get_type(
"ExtensionFeedItemOperation"
)
extension_feed_item = extension_feed_item_operation.create
extension_feed_item.image_feed_item.image_asset = image_asset_resource_name

extension_feed_response = extension_feed_item_service.mutate_extension_feed_items(
customer_id=customer_id, operations=[extension_feed_item_operation]
extension_feed_response = (
extension_feed_item_service.mutate_extension_feed_items(
customer_id=customer_id, operations=[extension_feed_item_operation]
)
)
image_resource_name = extension_feed_response.results[0].resource_name

print("Created an image extension with resource name: " f"'{image_resource_name}'")
print(
"Created an image extension with resource name: "
f"'{image_resource_name}'"
)

# Step 6.3 - Link Image Extension to RSA
campaign_extension_setting_service = client.get_service(
Expand Down Expand Up @@ -622,7 661,7 @@ def add_images(client, customer_id, campaign_resource_name):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(
description=("Creates a Responsive Search Ad for specified customer.")
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_smart_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -811,7 811,7 @@ def print_response_details(response):
if __name__ == "__main__":
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v15")
googleads_client = GoogleAdsClient.load_from_storage(version="v16")

parser = argparse.ArgumentParser(description=("Creates a Smart campaign."))
# The following argument(s) should be provided to run the example.
Expand Down
Loading

0 comments on commit 2e100cb

Please sign in to comment.