Skip to content

Update examples to use v26 - #1097

Open
BenRKarl wants to merge 2 commits into
mainfrom
examples_to_latest
Open

BenRKarl wants to merge 2 commits into
mainfrom
examples_to_latest

Conversation

@BenRKarl

Copy link
Copy Markdown
Contributor

No description provided.

@BenRKarl
BenRKarl requested a review from a team as a code owner October 20, 2026 15:48
@BenRKarl
BenRKarl requested review from Raibaz and sundquist October 20, 2026 15:48
@BenRKarl BenRKarl added the kokoro:run This label is required to run a kokoro presubmit if an external contributor sends a PR. label Oct 20, 2026
@BenRKarl
BenRKarl requested review from bobhancockg and removed request for sundquist October 20, 2026 15:49
@kokoro-team kokoro-team removed the kokoro:run This label is required to run a kokoro presubmit if an external contributor sends a PR. label Oct 20, 2026
Raibaz
Raibaz previously approved these changes Oct 20, 2026
Comment on lines +40 to 43
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchPagedResponse,
GoogleAdsRow,
)

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,
)

Comment on lines +34 to 38
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
GoogleAdsRow,
)

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,
)

Comment on lines +27 to 31
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
GoogleAdsRow,
)

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,
)

Comment on lines +38 to 41
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchPagedResponse,
GoogleAdsRow,
)

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).

Comment on lines +32 to 35
from google.ads.googleads.v26.services.types.google_ads_service import (
SearchGoogleAdsRequest,
SearchPagedResponse,
)

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,
)

GoogleAdsServiceClient,
)
from google.ads.googleads.v24.services.types import *
from google.ads.googleads.v26.services.types import *

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.

Avoid wildcard imports (import *) per the Google Python Style Guide, especially on services.types which loads hundreds of protobuf classes into the module namespace. Explicitly import the operation/response types used in this example instead.

Comment on lines 79 to 82
from google.ads.googleads.v26.services.types.google_ads_service import (
MutateGoogleAdsResponse,
MutateOperation,
MutateOperationResponse,

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.

MutateOperationResponse is imported here but unused in this file.


from google.protobuf import field_mask_pb2
from google.ads.googleads.v24.resources.types import youtube_video_upload
from google.ads.googleads.v26.resources.types import youtube_video_upload

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.

youtube_video_upload (line 52), GoogleAdsRow (line 35), and UpdateYouTubeVideoUploadRequest / UpdateYouTubeVideoUploadResponse / RemoveYouTubeVideoUploadRequest / RemoveYouTubeVideoUploadResponse (lines 45–48) are unused in this file and can be removed.

Comment thread examples/asyncio/async_search.py Outdated
Comment on lines 27 to 29
from google.ads.googleads.v26.services.types.google_ads_service import (
GoogleAdsRow,
)

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.

GoogleAdsRow is imported here but unused in this file.

Comment thread examples/asyncio/async_search_stream.py Outdated
Comment on lines 27 to 29
from google.ads.googleads.v26.services.types.google_ads_service import (
GoogleAdsRow,
)

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.

GoogleAdsRow is imported here but unused in this file.

BenRKarl and others added 2 commits November 23, 2026 08:37
- Replace nonexistent SearchPagedResponse with SearchPager from
  google.ads.googleads.v26.services.services.google_ads_service.pagers
  in account_management examples
- Fix MutateCustomerClientLinkResponse.result access in
  link_manager_to_client.py
- Move InsightsAudienceAttributeGroup import to common.types in
  generate_audience_insights.py
- Fix AdTextAsset import path in validate_ad.py
- Migrate hotel bid modifier fields to v26 generalized booking criteria
  in add_hotel_ad_group_bid_modifiers.py and
  get_ad_group_bid_modifiers.py
- Fix type annotations in add_call.py (CallAsset),
  detect_and_apply_recommendations.py (ApplyRecommendationResponse), and
  add_shopping_product_listing_group_tree.py
  (MutateAdGroupCriteriaResponse)
- Replace wildcard import in add_app_campaign.py with explicit imports
- Remove unused imports in add_performance_max_campaign.py,
  async_search.py, and async_search_stream.py
# 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")

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.

Switching to v26 breaks line 159 (request.cookie_frequency_cap = 0): cookie_frequency_cap was removed from GenerateReachForecastRequest in v26 (replaced by cookie_frequency_cap_setting), so this will raise an AttributeError at runtime.

  • Removing line 159 leaves the frequency cap uncapped by default, or it can be migrated to request.cookie_frequency_cap_setting.

AdTextAsset,
)
from google.ads.googleads.v24.errors.types.policy_finding_error import (
from google.ads.googleads.v26.errors.types.policy_finding_error import (

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.

Line 169 references client.enums.PolicyFindingErrorEnum.POLICY_FINDING, which raises AttributeError at runtime because PolicyFindingErrorEnum lives under errors.types rather than enums.types.

  • Since PolicyFindingErrorEnum is already imported here, line 169 can use PolicyFindingErrorEnum.POLICY_FINDING directly.
  • Also on line 183, policy_finding_details is annotated as PolicyFindingErrorEnum instead of PolicyFindingDetails (from google.ads.googleads.v26.errors.types.errors).

from google.ads.googleads.errors import GoogleAdsException
from google.ads.googleads.v24.common.types.bidding import TargetSpend
from google.ads.googleads.v24.resources.types.accessible_bidding_strategy import (
from google.ads.googleads.v26.common.types.bidding import TargetSpend

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.

TargetSpend is imported here but unused in this file and can be removed.

ReachPlanServiceClient,
)
from google.ads.googleads.v24.services.types.reach_plan_service import (
from google.ads.googleads.v26.services.types.reach_plan_service import (

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.

Two v26 breaking changes in request_reach_curve will raise AttributeError at runtime:

  • Line 159: request.cookie_frequency_cap was removed from GenerateReachForecastRequest in v26 (replaced by cookie_frequency_cap_setting).
  • Line 163: request.targeting.plannable_location_id was removed from Targeting and replaced by the repeated plannable_location_ids field (e.g., request.targeting.plannable_location_ids.append(location_id)).

)
from google.ads.googleads.v24.common.types.criteria import (
from google.ads.googleads.v26.common.types.criteria import (
AddressInfo,

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.

AddressInfo (from v26.common.types.criteria) is imported here to annotate address_info: AddressInfo = user_identifier.address_info on line 459, but user_identifier.address_info is actually OfflineUserAddressInfo (from google.ads.googleads.v26.common.types.offline_user_data). AddressInfo does not define hashed_first_name or hashed_last_name.

)
from google.ads.googleads.v24.errors.types.policy_finding_error import (
from google.ads.googleads.v26.errors.types.policy_finding_error import (
PolicyFindingErrorEnum,

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.

PolicyFindingErrorEnum is imported here to annotate policy_finding_details: PolicyFindingErrorEnum = error.details.policy_finding_details on line 183, which is actually PolicyFindingDetails (from google.ads.googleads.v26.errors.types.errors).

from google.ads.googleads.v26.services.types.google_ads_service import (
GoogleAdsRow,
SearchGoogleAdsRequest,
SearchGoogleAdsResponse,

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.

ga_service.search(...) on line 70 returns a SearchPager (from google.ads.googleads.v26.services.services.google_ads_service.pagers), not SearchGoogleAdsResponse. Updating the import and annotation to SearchPager matches the account_management examples in this PR.

The same SearchGoogleAdsResponse annotation on .search(...) also appears in find_and_remove_criteria_from_shared_set.py, get_responsive_search_ads.py, get_all_disapproved_ads.py, evaluate_and_update_experiment.py, set_up_remarketing.py, update_audience_target_restriction.py, add_performance_max_product_listing_group_tree.py, add_performance_max_retail_campaign.py, and add_shopping_product_listing_group_tree.py.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants