2929
3030from google .ads .googleads .client import GoogleAdsClient
3131from google .ads .googleads .errors import GoogleAdsException
32- from google .ads .googleads .v19 .services .services .google_ads_service import GoogleAdsServiceClient
33- from google .ads .googleads .v19 .services .types .google_ads_service import SearchGoogleAdsRequest
34- from google .ads .googleads .v19 .services .types .google_ads_service import SearchGoogleAdsStreamRequest
35- from google .ads .googleads .v19 .services .types .google_ads_service import SearchGoogleAdsStreamResponse
3632from google .api_core .exceptions import DeadlineExceeded
3733from google .api_core .retry import Retry
3834
3935
40- _CLIENT_TIMEOUT_SECONDS : int = 5 * 60 # 5 minutes.
36+ _CLIENT_TIMEOUT_SECONDS = 5 * 60 # 5 minutes.
4137_QUERY : str = "SELECT campaign.id FROM campaign"
4238
4339
@@ -57,16 +53,14 @@ def make_server_streaming_call(
5753 client: An initialized GoogleAds client.
5854 customer_id: The str Google Ads customer ID.
5955 """
60- ga_service : GoogleAdsServiceClient = client .get_service ("GoogleAdsService" )
61- campaign_ids : list [str ] = []
56+ ga_service = client .get_service ("GoogleAdsService" )
57+ campaign_ids : List [str ] = []
6258
6359 try :
64- search_request : SearchGoogleAdsStreamRequest = client .get_type (
65- "SearchGoogleAdsStreamRequest"
66- )
60+ search_request = client .get_type ("SearchGoogleAdsStreamRequest" )
6761 search_request .customer_id = customer_id
6862 search_request .query = _QUERY
69- stream : SearchGoogleAdsStreamResponse = ga_service .search_stream (
63+ stream = ga_service .search_stream (
7064 request = search_request ,
7165 # When making any request, an optional "timeout" parameter can be
7266 # provided to specify a client-side response deadline in seconds.
@@ -81,7 +75,7 @@ def make_server_streaming_call(
8175 campaign_ids .append (row .campaign .id )
8276
8377 print ("The server streaming call completed before the timeout." )
84- except DeadlineExceeded :
78+ except DeadlineExceeded as ex :
8579 print ("The server streaming call did not complete before the timeout." )
8680 sys .exit (1 )
8781 except GoogleAdsException as ex :
@@ -108,16 +102,14 @@ def make_unary_call(client: GoogleAdsClient, customer_id: str) -> None:
108102 client: An initialized GoogleAds client.
109103 customer_id: The Google Ads customer ID.
110104 """
111- ga_service : GoogleAdsServiceClient = client .get_service ("GoogleAdsService" )
112- campaign_ids : list [str ] = []
105+ ga_service = client .get_service ("GoogleAdsService" )
106+ campaign_ids : List [str ] = []
113107
114108 try :
115- search_request : SearchGoogleAdsRequest = client .get_type (
116- "SearchGoogleAdsRequest"
117- )
109+ search_request = client .get_type ("SearchGoogleAdsRequest" )
118110 search_request .customer_id = customer_id
119111 search_request .query = _QUERY
120- results : SearchGoogleAdsStreamResponse = ga_service .search (
112+ results = ga_service .search (
121113 request = search_request ,
122114 # When making any request, an optional "retry" parameter can be
123115 # provided to specify its retry behavior. Complete information about
@@ -145,7 +137,7 @@ def make_unary_call(client: GoogleAdsClient, customer_id: str) -> None:
145137 campaign_ids .append (row .campaign .id )
146138
147139 print ("The unary call completed before the timeout." )
148- except DeadlineExceeded :
140+ except DeadlineExceeded as ex :
149141 print ("The unary call did not complete before the timeout." )
150142 sys .exit (1 )
151143 except GoogleAdsException as ex :
0 commit comments