Update examples to use v26 by BenRKarl · Pull Request #1097 · googleads/google-ads-python · GitHub
Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions examples/account_management/create_customer.py
10 changes: 5 additions & 5 deletions examples/account_management/get_account_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,16 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.services.services.google_ads_service.client import (
from google.ads.googleads.v26.services.services.google_ads_service.client import (
GoogleAdsServiceClient,
)
from google.ads.googleads.v24.services.services.customer_service.client import (
from google.ads.googleads.v26.services.services.customer_service.client import (
CustomerServiceClient,
)
from google.ads.googleads.v24.resources.types.customer_client import (
from google.ads.googleads.v26.resources.types.customer_client import (
CustomerClient,
)
from google.ads.googleads.v24.services.types.google_ads_service import (
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchPagedResponse,
GoogleAdsRow,
)
Comment on lines +40 to 43

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. GoogleAdsServiceClient.search() returns a SearchPager:

Suggested change
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchPagedResponse,
GoogleAdsRow,
)
from google.ads.googleads.v26.services.services.google_ads_service.pagers import (
SearchPager,
)
from google.ads.googleads.v26.services.types.google_ads_service import (
GoogleAdsRow,
)

Expand Down Expand Up @@ -238,7 +238,7 @@ def print_account_hierarchy(

# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")
try:
main(googleads_client, args.login_customer_id)
except GoogleAdsException as ex:
Expand Down
8 changes: 4 additions & 4 deletions examples/account_management/get_change_details.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@
from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.util import get_nested_attr
from google.ads.googleads.v24.services.services.google_ads_service.client import (
from google.ads.googleads.v26.services.services.google_ads_service.client import (
GoogleAdsServiceClient,
)
from google.ads.googleads.v24.services.types.google_ads_service import (
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
GoogleAdsRow,
)
Comment on lines +34 to 38

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead:

Suggested change
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
GoogleAdsRow,
)
from google.ads.googleads.v26.services.services.google_ads_service.pagers import (
SearchPager,
)
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
GoogleAdsRow,
)

from google.ads.googleads.v24.resources.types.change_event import ChangeEvent
from google.ads.googleads.v26.resources.types.change_event import ChangeEvent


# [START get_change_details]
Expand Down Expand Up @@ -218,7 +218,7 @@ def main(client: GoogleAdsClient, customer_id: str) -> None:

# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")
try:
main(googleads_client, args.customer_id)
except GoogleAdsException as ex:
Expand Down
8 changes: 4 additions & 4 deletions examples/account_management/get_change_summary.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,15 +21,15 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.services.services.google_ads_service.client import (
from google.ads.googleads.v26.services.services.google_ads_service.client import (
GoogleAdsServiceClient,
)
from google.ads.googleads.v24.services.types.google_ads_service import (
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
GoogleAdsRow,
)
Comment on lines +27 to 31

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead:

Suggested change
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
GoogleAdsRow,
)
from google.ads.googleads.v26.services.services.google_ads_service.pagers import (
SearchPager,
)
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
GoogleAdsRow,
)

from google.ads.googleads.v24.resources.types.change_status import ChangeStatus
from google.ads.googleads.v26.resources.types.change_status import ChangeStatus


# [START get_change_summary]
Expand Down Expand Up @@ -109,7 +109,7 @@ def main(client: GoogleAdsClient, customer_id: str) -> None:

# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")

try:
main(googleads_client, args.customer_id)
Expand Down
10 changes: 5 additions & 5 deletions examples/account_management/invite_user_with_access_role.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,18 +22,18 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.services.services.customer_user_access_invitation_service.client import (
from google.ads.googleads.v26.services.services.customer_user_access_invitation_service.client import (
CustomerUserAccessInvitationServiceClient,
)
from google.ads.googleads.v24.services.types.customer_user_access_invitation_service import (
from google.ads.googleads.v26.services.types.customer_user_access_invitation_service import (
CustomerUserAccessInvitationOperation,
MutateCustomerUserAccessInvitationResponse,
)
from google.ads.googleads.v24.resources.types.customer_user_access_invitation import (
from google.ads.googleads.v26.resources.types.customer_user_access_invitation import (
CustomerUserAccessInvitation,
)

# AccessRoleEnum is part of google.ads.googleads.v24.enums.types.access_role
# AccessRoleEnum is part of google.ads.googleads.v26.enums.types.access_role
# but it's accessed via client.enums.AccessRoleEnum, so direct import for type hint might not be strictly needed for the parameter.
# The field invitation.access_role expects an int (the enum value).

Expand Down Expand Up @@ -127,7 +127,7 @@ def 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="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")

try:
main(
Expand Down
18 changes: 9 additions & 9 deletions examples/account_management/link_manager_to_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,31 +22,31 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.services.services.customer_client_link_service.client import (
from google.ads.googleads.v26.services.services.customer_client_link_service.client import (
CustomerClientLinkServiceClient,
)
from google.ads.googleads.v24.services.types.customer_client_link_service import (
from google.ads.googleads.v26.services.types.customer_client_link_service import (
CustomerClientLinkOperation,
MutateCustomerClientLinkResponse,
)
from google.ads.googleads.v24.resources.types.customer_client_link import (
from google.ads.googleads.v26.resources.types.customer_client_link import (
CustomerClientLink,
)
from google.ads.googleads.v24.services.services.google_ads_service.client import (
from google.ads.googleads.v26.services.services.google_ads_service.client import (
GoogleAdsServiceClient,
)
from google.ads.googleads.v24.services.types.google_ads_service import (
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchPagedResponse,
GoogleAdsRow,
)
Comment on lines +38 to 41

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead.

Also note: MutateCustomerClientLinkResponse (imported on line 30) has a singular .result field in v26 rather than .results, so response.results[0].resource_name on line 86 will raise an AttributeError (should be response.result.resource_name).

from google.ads.googleads.v24.services.services.customer_manager_link_service.client import (
from google.ads.googleads.v26.services.services.customer_manager_link_service.client import (
CustomerManagerLinkServiceClient,
)
from google.ads.googleads.v24.services.types.customer_manager_link_service import (
from google.ads.googleads.v26.services.types.customer_manager_link_service import (
CustomerManagerLinkOperation,
MutateCustomerManagerLinkResponse,
)
from google.ads.googleads.v24.resources.types.customer_manager_link import (
from google.ads.googleads.v26.resources.types.customer_manager_link import (
CustomerManagerLink,
)

Expand Down Expand Up @@ -179,7 +179,7 @@ def 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="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")
try:
main(googleads_client, args.customer_id, args.manager_customer_id)
except GoogleAdsException as ex:
Expand Down
6 changes: 3 additions & 3 deletions examples/account_management/list_accessible_customers.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.services.services.customer_service.client import (
from google.ads.googleads.v26.services.services.customer_service.client import (
CustomerServiceClient,
)
from google.ads.googleads.v24.services.types.customer_service import (
from google.ads.googleads.v26.services.types.customer_service import (
ListAccessibleCustomersResponse,
)

Expand All @@ -54,7 +54,7 @@ def main(client: GoogleAdsClient) -> None:
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="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")

try:
main(googleads_client)
Expand Down
12 changes: 6 additions & 6 deletions examples/account_management/update_user_access.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,20 +26,20 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.services.services.google_ads_service.client import (
from google.ads.googleads.v26.services.services.google_ads_service.client import (
GoogleAdsServiceClient,
)
from google.ads.googleads.v24.services.types.google_ads_service import (
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
)
Comment on lines +32 to 35

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

SearchPagedResponse does not exist in google.ads.googleads.v26.services.types.google_ads_service and raises an ImportError at runtime. Import SearchPager from google.ads.googleads.v26.services.services.google_ads_service.pagers instead:

Suggested change
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
)
from google.ads.googleads.v26.services.services.google_ads_service.pagers import (
SearchPager,
)
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
)

from google.ads.googleads.v24.resources.types.customer_user_access import (
from google.ads.googleads.v26.resources.types.customer_user_access import (
CustomerUserAccess,
)
from google.ads.googleads.v24.services.services.customer_user_access_service.client import (
from google.ads.googleads.v26.services.services.customer_user_access_service.client import (
CustomerUserAccessServiceClient,
)
from google.ads.googleads.v24.services.types.customer_user_access_service import (
from google.ads.googleads.v26.services.types.customer_user_access_service import (
CustomerUserAccessOperation,
MutateCustomerUserAccessResponse,
)
Expand Down Expand Up @@ -233,7 +233,7 @@ def modify_user_access(

# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")
try:
main(
googleads_client,
Expand Down
8 changes: 4 additions & 4 deletions examples/account_management/verify_advertiser_identity.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.enums.types.identity_verification_program_status import (
from google.ads.googleads.v26.enums.types.identity_verification_program_status import (
IdentityVerificationProgramStatusEnum,
)
from google.ads.googleads.v24.services.services.identity_verification_service.client import (
from google.ads.googleads.v26.services.services.identity_verification_service.client import (
IdentityVerificationServiceClient,
)
from google.ads.googleads.v24.services.types.identity_verification_service import (
from google.ads.googleads.v26.services.types.identity_verification_service import (
GetIdentityVerificationResponse,
IdentityVerification,
IdentityVerificationProgress,
Expand Down Expand Up @@ -182,7 +182,7 @@ def start_identity_verification(

# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client = GoogleAdsClient.load_from_storage(version="v24")
googleads_client = GoogleAdsClient.load_from_storage(version="v26")

try:
main(googleads_client, args.customer_id)
Expand Down
16 changes: 8 additions & 8 deletions examples/advanced_operations/add_ad_customizer.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,25 +24,25 @@

from google.ads.googleads.client import GoogleAdsClient
from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.common.types import AdTextAsset
from google.ads.googleads.v24.resources.types import (
from google.ads.googleads.v26.common.types import AdTextAsset
from google.ads.googleads.v26.resources.types import (
AdGroupAd,
AdGroupCustomizer,
CustomizerAttribute,
)
from google.ads.googleads.v24.services.services.ad_group_ad_service import (
from google.ads.googleads.v26.services.services.ad_group_ad_service import (
AdGroupAdServiceClient,
)
from google.ads.googleads.v24.services.services.ad_group_customizer_service import (
from google.ads.googleads.v26.services.services.ad_group_customizer_service import (
AdGroupCustomizerServiceClient,
)
from google.ads.googleads.v24.services.services.customizer_attribute_service import (
from google.ads.googleads.v26.services.services.customizer_attribute_service import (
CustomizerAttributeServiceClient,
)
from google.ads.googleads.v24.services.services.google_ads_service import (
from google.ads.googleads.v26.services.services.google_ads_service import (
GoogleAdsServiceClient,
)
from google.ads.googleads.v24.services.types import (
from google.ads.googleads.v26.services.types import (
AdGroupAdOperation,
AdGroupCustomizerOperation,
CustomizerAttributeOperation,
Expand Down Expand Up @@ -341,7 +341,7 @@ def create_ad_with_customizations(
# GoogleAdsClient will read the google-ads.yaml configuration file in the
# home directory if none is specified.
googleads_client: GoogleAdsClient = GoogleAdsClient.load_from_storage(
version="v24"
version="v26"
)

try:
Expand Down
12 changes: 6 additions & 6 deletions examples/advanced_operations/add_ad_group_bid_modifier.py
Loading
Loading