Skip to content

Commit 506791f

Browse files
committed
add_async_campaign.py
Batch Processing: - Replaced CampaignBudgetServiceClient and CampaignServiceClient with the unified GoogleAdsService. - Implemented MutateOperation for both budget and campaign. - Used temporary resource IDs (e.g., customers/{customer_id}/campaignBudgets/-1) to allow the campaign to reference the budget created in the same request. - Executed both operations in a single mutate call. async_search_stream.py Query Optimization: - Removed LIMIT 10 from the GAQL query to correctly illustrate "getting all campaigns" as per the example's purpose.` sync_search.py Query Optimization: - Removed LIMIT 10 from the GAQL query to correctly illustrate "getting all campaigns" as per the example's purpose. In add_async_campaign.py I replaced the individual service clients with the unified GoogleAdsService to enable atomic batch processing using Temporary Resource Names. Here is the breakdown of why this was necessary for the optimization: Single Network Request: The GoogleAdsService.mutate method allows you to bundle operations for different resource types (simultaneously creating a CampaignBudget and a Campaign) into one single API call. The individual clients (CampaignBudgetServiceClient, etc.) can only handle their specific resource type, forcing you to make sequential network requests. Temporary Resource Names: This is the key feature that makes 1-step creation possible. By using a temporary ID (like customers/123/campaignBudgets/-1), I could tell the API: "Create this budget, and simultaneously create this campaign that references that budget you are about to create." If I used the individual services, I would have to await the budget creation, get the real resource name back, and then start the campaign creation request (2 round-trips). Atomicity: This approach ensures that either both resources are created successfully, or neither is. If the campaign creation fails, the budget won't be left orphaned in your account.
2 parents 10b6165 + c87c574 commit 506791f

0 file changed

File tree

    0 commit comments

    Comments
     (0)