Skip to content

Commit

Permalink
Changes for release v8_0. (#449)
Browse files Browse the repository at this point in the history
  • Loading branch information
laurachevalier4 authored Jun 15, 2021
1 parent ee2c059 commit 09be83d
Show file tree
Hide file tree
Showing 2,165 changed files with 164,413 additions and 137,423 deletions.
5 changes: 5 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
* 12.0.0
- Google Ads API v8_0 release.
- Deprecate Google Ads API v5_0.
- *NOTE* This will be the last release to support Python 3.6.

* 11.0.2
- Update dataclasses dependency so it's only installed when using Python < 3.7

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,7 @@ def _update_merchant_center_link_status(
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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=("Approves a Merchant Center link request.")
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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

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_account_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
13 changes: 9 additions & 4 deletions examples/account_management/get_change_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,16 +123,21 @@ def main(client, customer_id):

print(
f"On {event.change_date_time}, user {event.user_email} "
f"used interface {event.client_type} to perform a(n) "
f"{event.resource_change_operation} operation on a "
f"{event.change_resource_type} with resource name "
f"used interface {event.client_type.name} to perform a(n) "
f"{event.resource_change_operation.name} operation on a "
f"{event.change_resource_type.name} with resource name "
f"'{event.change_resource_name}'"
)

operation_type = event.resource_change_operation.name

if operation_type in ("UPDATE", "CREATE"):
for changed_field in event.changed_fields.paths:
# Change field name from "type" to "type_" so that it doesn't
# raise an exception when accessed on the protobuf object, see:
# https://developers.google.com/google-ads/api/docs/client-libs/python/library-version-10#field_names_that_are_reserved_words
if changed_field == "type":
changed_field = "type_"
new_value = get_nested_attr(new_resource, changed_field)
if operation_type == "CREATE":
print(f"\t{changed_field} set to {new_value}")
Expand All @@ -147,7 +152,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
4 changes: 3 additions & 1 deletion examples/account_management/get_pending_invitations.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,13 +57,15 @@ def main(client, customer_id):
f"access role: {invite.access_role}, and "
f"created on: {invite.creation_date_time} was found."
)


# [END get_pending_invitations]


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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=("Retrieves pending invitations for a customer account.")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
10 changes: 3 additions & 7 deletions examples/account_management/link_manager_to_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,12 +85,8 @@ def main(client, customer_id, manager_customer_id):
)
manager_link_operation = client.get_type("CustomerManagerLinkOperation")
manager_link = manager_link_operation.update
manager_link.resource_name = (
customer_manager_link_service.customer_manager_link_path(
customer_id,
manager_customer_id,
manager_link_id,
)
manager_link.resource_name = customer_manager_link_service.customer_manager_link_path(
customer_id, manager_customer_id, manager_link_id,
)

manager_link.status = client.get_type(
Expand Down Expand Up @@ -131,7 +127,7 @@ def _handle_googleads_exception(exception):
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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

try:
main(googleads_client)
Expand Down
2 changes: 1 addition & 1 deletion examples/account_management/reject_merchant_center_link.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ def _remove_merchant_center_link(
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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
8 changes: 3 additions & 5 deletions examples/account_management/update_user_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,10 +113,8 @@ def _modify_user_access(client, customer_id, user_id, access_role):
customer_user_access_op = client.get_type("CustomerUserAccessOperation")
access_role_enum = client.get_type("AccessRoleEnum").AccessRole
customer_user_access = customer_user_access_op.update
customer_user_access.resource_name = (
customer_user_access_service.customer_user_access_path(
customer_id, user_id
)
customer_user_access.resource_name = customer_user_access_service.customer_user_access_path(
customer_id, user_id
)
customer_user_access.access_role = getattr(access_role_enum, access_role)
client.copy_from(
Expand All @@ -137,7 +135,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description="This code example updates the access role of a user, "
Expand Down
7 changes: 2 additions & 5 deletions examples/advanced_operations/add_ad_customizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,7 @@ def _get_feed_attributes(client, customer_id, feed_resource_name):

# [START add_ad_customizer_2]
def _create_ad_customizer_mapping(
client,
customer_id,
ad_customizer_feed_resource_name,
feed_details,
client, customer_id, ad_customizer_feed_resource_name, feed_details,
):
"""Creates a feed mapping for a given feed.
Expand Down Expand Up @@ -443,7 +440,7 @@ def _handle_googleads_exception(exception):
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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
19 changes: 8 additions & 11 deletions examples/advanced_operations/add_ad_group_bid_modifier.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,11 +50,8 @@ def main(client, customer_id, ad_group_id, bid_modifier_value):
ad_group_bid_modifier.device.type_ = device_enum.MOBILE

# Add the ad group bid modifier.
ad_group_bm_response = (
ad_group_bm_service.mutate_ad_group_bid_modifiers(
customer_id=customer_id,
operations=[ad_group_bid_modifier_operation],
)
ad_group_bm_response = ad_group_bm_service.mutate_ad_group_bid_modifiers(
customer_id=customer_id, operations=[ad_group_bid_modifier_operation],
)
# [END add_ad_group_bid_modifier]

Expand All @@ -67,7 +64,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down Expand Up @@ -98,11 +95,11 @@ def main(client, customer_id, ad_group_id, bid_modifier_value):

try:
main(
googleads_client,
args.customer_id,
args.ad_group_id,
args.bid_modifier_value,
)
googleads_client,
args.customer_id,
args.ad_group_id,
args.bid_modifier_value,
)
except GoogleAdsException as ex:
print(
f'Request with ID "{ex.request_id}" failed with status '
Expand Down
10 changes: 5 additions & 5 deletions examples/advanced_operations/add_app_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@ def _set_campaign_targeting_criteria(
campaign_criterion = campaign_criterion_operation.create
campaign_criterion.campaign = campaign_resource_name
campaign_criterion.type_ = location_type
campaign_criterion.location.geo_target_constant = (
geo_target_constant_service.geo_target_constant_path(location_id)
campaign_criterion.location.geo_target_constant = geo_target_constant_service.geo_target_constant_path(
location_id
)
campaign_criterion_operations.append(campaign_criterion_operation)

Expand All @@ -203,8 +203,8 @@ def _set_campaign_targeting_criteria(
campaign_criterion = campaign_criterion_operation.create
campaign_criterion.campaign = campaign_resource_name
campaign_criterion.type_ = language_type
campaign_criterion.language.language_constant = (
language_constant_service.language_constant_path(language_id)
campaign_criterion.language.language_constant = language_constant_service.language_constant_path(
language_id
)
campaign_criterion_operations.append(campaign_criterion_operation)

Expand Down Expand Up @@ -305,7 +305,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
11 changes: 4 additions & 7 deletions examples/advanced_operations/add_display_upload_ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,6 @@ def main(client, customer_id, ad_group_id):
)



def _create_media_bundle_asset(client, customer_id):
"""Creates a media bundle from the assets in a zip file.
Expand Down Expand Up @@ -136,11 +135,9 @@ def _create_display_upload_ad_group_ad(
display_upload_ad.display_upload_ad.media_bundle.asset = (
ad_asset_resource_name
)
display_upload_ad.display_upload_ad.display_upload_product_type = (
client.get_type(
"DisplayUploadProductTypeEnum"
).DisplayUploadProductType.HTML5_UPLOAD_AD
)
display_upload_ad.display_upload_ad.display_upload_product_type = client.get_type(
"DisplayUploadProductTypeEnum"
).DisplayUploadProductType.HTML5_UPLOAD_AD

# Add the ad group ad to the client account and display the resulting
# ad's resource name.
Expand All @@ -156,7 +153,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description="Adds a display upload ad to a given ad group."
Expand Down
21 changes: 10 additions & 11 deletions examples/advanced_operations/add_dynamic_page_feed.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,12 @@ def main(client, customer_id, campaign_id, ad_group_id):
# We need to look up the attribute name and ID for the feed we just
# created so that we can give them back to the API for construction of
# feed mappings in the next function.
feed_details = _get_feed_details(
client, customer_id, feed_resource_name
)
feed_details = _get_feed_details(client, customer_id, feed_resource_name)
_create_feed_mapping(client, customer_id, feed_details)
_create_feed_items(
client, customer_id, feed_details, dsa_page_url_label
)
_create_feed_items(client, customer_id, feed_details, dsa_page_url_label)

# Associate the page feed with the campaign.
_update_campaign_dsa_setting(
client, customer_id, campaign_id, feed_details
)
_update_campaign_dsa_setting(client, customer_id, campaign_id, feed_details)
ad_group_service = client.get_service("AdGroupService")
ad_group_resource_name = ad_group_service.ad_group_path(
customer_id, ad_group_id
Expand Down Expand Up @@ -369,7 +363,7 @@ def _add_dsa_targeting(client, customer_id, ad_group_resource_name, 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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand All @@ -393,7 +387,12 @@ def _add_dsa_targeting(client, customer_id, ad_group_resource_name, label):
args = parser.parse_args()

try:
main(googleads_client, args.customer_id, args.campaign_id, args.ad_group_id)
main(
googleads_client,
args.customer_id,
args.campaign_id,
args.ad_group_id,
)
except GoogleAdsException as ex:
print(
f'Request with ID "{ex.request_id}" failed with status '
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 @@ -268,7 +268,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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ def main(client, customer_id, ad_group_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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_gmail_ad.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ def _get_image(url):
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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description=(
Expand Down
2 changes: 1 addition & 1 deletion examples/advanced_operations/add_local_campaign.py
Original file line number Diff line number Diff line change
Expand Up @@ -343,7 +343,7 @@ def _create_youtube_video_asset(
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="v7")
googleads_client = GoogleAdsClient.load_from_storage(version="v8")

parser = argparse.ArgumentParser(
description="Adds a Local Campaign to the given account."
Expand Down
Loading

0 comments on commit 09be83d

Please sign in to comment.