Module Expr Str Import alias Import alias Import alias Import alias ImportFrom alias Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore TupleLoad Str Str Str FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Assign NameStore Call AttributeLoad NameLoad attr keyword Str Assign NameStore Call NameLoad NameLoad Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Assign NameStore SubscriptLoad NameLoad Index Str Print BinOpMod Str TupleLoad SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Call NameLoad NameLoad Expr Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad attr Expr Call NameLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str keyword Str Assign NameStore ListLoad Dict Str Str Dict Str Return SubscriptLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Index Str Index Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListComp Dict Str Str Str Str Dict Str Str SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Dict Str Str Str Str Str Str Str Str Str Str Str ListLoad Str Str comprehension NameStore NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults Num body Expr Str Assign NameStore ListComp Dict Str Str Str Str Dict Str Str Str Str SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Dict Str Str Str Str BinOpMod Str TupleLoad NameLoad IfExp CompareEq BinOpMod NameLoad Num Num Str Str Str Str comprehension NameStore NameLoad comprehension NameStore Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Num body Expr Str Assign NameStore ListComp Dict Str Str Str Str Dict Str Str Str Str SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Call AttributeLoad NameLoad attr BinOpMod Str Call AttributeLoad NameLoad attr Dict Str ListLoad Dict Str Str Str Dict Str Num Str comprehension NameStore NameLoad comprehension NameStore Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListLoad Dict Str Str Str Str Dict Str Str Str Str BinOpMod Str Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Dict Str Str Str Str Return NameLoad decorator_list FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore ListComp Dict Str Str Str Str Dict Str Str Str Str SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Dict Str Str Str Str Str Str Str comprehension NameStore NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults Num body Expr Str Assign NameStore SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Num Index Str Index Str Assign NameStore ListComp Dict Str Str Str Str Dict Str Str Str Str Str Str BinOpMod Str Call AttributeLoad NameLoad attr Str Call AttributeLoad NameLoad attr Str Dict Str NameLoad Dict Str Str Str comprehension NameStore Call NameLoad NameLoad Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr Str Str Assign NameStore Dict Str Str ListLoad Str Str Str ListLoad Dict Str Str Str Str Str ListLoad NameLoad Return SubscriptLoad SubscriptLoad Call AttributeLoad NameLoad attr NameLoad Index Str Index Num decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults NameLoad body Expr Str Assign NameStore Call NameLoad NameLoad NameLoad Assign NameStore Num While BoolOpAnd CompareIn NameLoad Call NameLoad NameLoad CompareIn SubscriptLoad NameLoad Index Str NameLoad body Assign NameStore BinOpAdd BinOpMult Num BinOpPow Num NameLoad BinOpDiv Call AttributeLoad NameLoad attr Num Num Num Print BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore Call NameLoad NameLoad NameLoad AugAssignAdd NameStore Num If CompareIn Str NameLoad body Assign NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Print BinOpMod Str TupleLoad SubscriptLoad NameLoad Index Str SubscriptLoad NameLoad Index Str NameLoad Return NameLoad Raise Call NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr NameLoad If CompareIn Str SubscriptLoad NameLoad Index Str body For NameStore SubscriptLoad SubscriptLoad NameLoad Index Str Index Str body If CompareIn Str NameLoad body Print BinOpMod Str SubscriptLoad NameLoad Index Str Print BinOpMod Str SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Print BinOpMod Str SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Print BinOpMod Str SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Print BinOpMod Str SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str Print BinOpMod Str SubscriptLoad SubscriptLoad SubscriptLoad NameLoad Index Str Index Str Index Str If CompareIn Str NameLoad body Print BinOpMod Str SubscriptLoad NameLoad Index Str decorator_list If CompareEq NameLoad Str body Assign NameStore Call AttributeLoad AttributeLoad NameLoad attr attr Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad
N/A N/A This uses the BatchJobService to create a complete Campaign.

The complete Campaign created by this example also includes AdGroups and
KeyWords.

 N/A random N/A time N/A urllib2 N/A uuid googleads adwords N/A NUMBER_OF_CAMPAIGNS_TO_ADD 2 N/A NUMBER_OF_ADGROUPS_TO_ADD 2 N/A NUMBER_OF_KEYWORDS_TO_ADD 5 N/A MAX_POLL_ATTEMPTS 5 N/A PENDING_STATUSES N/A ACTIVE AWAITING_FILE CANCELING main N/A N/A client number_of_campaigns number_of_adgroups number_of_keywords N/A N/A N/A batch_job_helper N/A N/A client GetBatchJobHelper version v201603 N/A batch_job N/A AddBatchJob client N/A upload_url N/A N/A batch_job N/A uploadUrl N/A url N/A batch_job_id N/A batch_job N/A id N/A N/A Created BatchJob with ID "%d", status "%s", and upload URL "%s" N/A N/A batch_job N/A id N/A batch_job N/A status upload_url N/A budget_operations N/A BuildBudgetOperations batch_job_helper N/A campaign_operations N/A BuildCampaignOperations batch_job_helper budget_operations number_of_campaigns N/A campaign_criterion_operations N/A BuildCampaignCriterionOperations campaign_operations N/A adgroup_operations N/A BuildAdGroupOperations batch_job_helper campaign_operations number_of_adgroups N/A adgroup_criterion_operations N/A BuildAdGroupCriterionOperations adgroup_operations number_of_keywords N/A adgroup_ad_operations N/A BuildAdGroupAdOperations adgroup_operations N/A N/A N/A batch_job_helper UploadOperations upload_url budget_operations campaign_operations campaign_criterion_operations adgroup_operations adgroup_criterion_operations adgroup_ad_operations N/A download_url N/A GetBatchJobDownloadUrlWhenReady client batch_job_id N/A response N/A N/A N/A N/A urllib2 urlopen download_url read N/A N/A PrintResponse batch_job_helper response N/A AddBatchJob N/A N/A client N/A N/A N/A Add a new BatchJob to upload operations to.

  Args:
    client: an instantiated AdWordsClient used to retrieve the BatchJob.

  Returns:
    The new BatchJob created by the request.
   N/A batch_job_service N/A N/A client GetService BatchJobService version v201603 N/A batch_job_operations N/A N/A operand operator N/A ADD N/A N/A N/A N/A N/A batch_job_service mutate batch_job_operations N/A value N/A 0 N/A BuildAdGroupAdOperations N/A N/A adgroup_operations N/A N/A N/A Builds the operations adding a TextAd to each AdGroup.

  Args:
    adgroup_operations: a list containing the operations that will add AdGroups.

  Returns:
    a list containing the operations that will create a new TextAd for each of
    the provided AdGroups.
   N/A adgroup_ad_operations N/A N/A xsi_type operand operator AdGroupAdOperation N/A adGroupId ad N/A N/A adgroup_operation N/A operand N/A id N/A xsi_type headline description1 description2 displayUrl finalUrls TextAd Luxury Cruise to Mars Visit the Red Planet in style. Low-gravity fun for everyone! www.example.com N/A http://www.example.com/1 ADD N/A adgroup_operation adgroup_operations N/A adgroup_ad_operations N/A BuildAdGroupCriterionOperations N/A N/A adgroup_operations number_of_keywords N/A 1 N/A N/A Builds the operations adding a Keyword Criterion to each AdGroup.

  Args:
    adgroup_operations: a list containing the operations that will add AdGroups.
    number_of_keywords: an int defining the number of Keywords to be created.

  Returns:
    a list containing the operations that will create a new Keyword Criterion
    associated with each provided AdGroup.
   N/A criterion_operations N/A N/A xsi_type operand operator AdGroupCriterionOperation N/A xsi_type adGroupId criterion BiddableAdGroupCriterion N/A N/A adgroup_operation N/A operand N/A id N/A xsi_type text matchType Keyword N/A mars%s%s N/A i N/A N/A N/A i 2 0 !!! BROAD ADD N/A adgroup_operation adgroup_operations N/A i N/A range number_of_keywords N/A criterion_operations N/A BuildAdGroupOperations N/A N/A batch_job_helper campaign_operations number_of_adgroups N/A 1 N/A N/A Builds the operations adding desired number of AdGroups to given Campaigns.

  Note: When the AdGroups are created, they will have a different Id than those
  generated here as a temporary Id. This is just used to identify them in the
  BatchJobService.

  Args:
    batch_job_helper: a BatchJobHelper instance.
    campaign_operations: a list containing the operations that will add
      Campaigns.
    number_of_adgroups: an int defining the number of AdGroups to be created per
      Campaign.

  Returns:
    a list containing the operations that will add the desired number of
    AdGroups to each of the provided Campaigns.
   N/A adgroup_operations N/A N/A xsi_type operand operator AdGroupOperation N/A campaignId id name biddingStrategyConfiguration N/A N/A campaign_operation N/A operand N/A id N/A N/A batch_job_helper GetId N/A Batch Ad Group #%s N/A N/A uuid uuid4 N/A bids N/A N/A xsi_type bid CpcBid N/A microAmount 10000000 ADD N/A campaign_operation campaign_operations N/A _ N/A range number_of_adgroups N/A adgroup_operations N/A BuildBudgetOperations N/A N/A batch_job_helper N/A N/A N/A Builds the operations needed to create a new Budget.

  Note: When the Budget is created, it will have a different Id than the one
  generated here as a temporary Id. This is just used to identify it in the
  BatchJobService.

  Args:
    batch_job_helper: a BatchJobHelper instance.

  Returns:
    a list containing the operation that will create a new Budget.
   N/A budget_operations N/A N/A xsi_type operand operator BudgetOperation N/A name budgetId amount deliveryMethod N/A Batch budget #%s N/A N/A uuid uuid4 N/A N/A batch_job_helper GetId N/A microAmount 50000000 STANDARD ADD N/A budget_operations N/A BuildCampaignCriterionOperations N/A N/A campaign_operations N/A N/A N/A Builds the operations needed to create Negative Campaign Criterion.

  Args:
    campaign_operations: a list containing the operations that will add
      Campaigns.

  Returns:
    a list containing the operations that will create a new Negative Campaign
    Criterion associated with each provided Campaign.
   N/A criterion_operations N/A N/A xsi_type operand operator CampaignCriterionOperation N/A xsi_type campaignId criterion NegativeCampaignCriterion N/A N/A campaign_operation N/A operand N/A id N/A xsi_type matchType text Keyword BROAD venus ADD N/A campaign_operation campaign_operations N/A criterion_operations N/A BuildCampaignOperations N/A N/A batch_job_helper budget_operations number_of_campaigns N/A 1 N/A N/A Builds the operations needed to create a new Campaign.

  Note: When the Campaigns are created, they will have a different Id than those
  generated here as a temporary Id. This is just used to identify them in the
  BatchJobService.

  Args:
    batch_job_helper: a BatchJobHelper instance.
    budget_operations: a list containing the operation that will add the budget
      used by these Campaigns.
    number_of_campaigns: an int number defining the number of campaigns to be
      created.

  Returns:
    a list containing the operations to create the desired number of Campaigns.
   N/A budget_id N/A N/A N/A budget_operations N/A 0 N/A operand N/A budgetId N/A campaign_operations N/A N/A xsi_type operand operator CampaignOperation N/A name status id advertisingChannelType budget biddingStrategyConfiguration N/A Batch Campaign #%s N/A N/A uuid uuid4 PAUSED N/A N/A batch_job_helper GetId SEARCH N/A budgetId budget_id N/A biddingStrategyType MANUAL_CPC ADD N/A _ N/A range number_of_campaigns N/A campaign_operations N/A GetBatchJob N/A N/A client batch_job_id N/A N/A N/A Retrieves the BatchJob with the given id.

  Args:
    client: an instantiated AdWordsClient used to retrieve the BatchJob.
    batch_job_id: a long identifying the BatchJob to be retrieved.
  Returns:
    The BatchJob associated with the given id.
   N/A batch_job_service N/A N/A client GetService BatchJobService v201603 N/A selector N/A fields predicates N/A Id Status DownloadUrl N/A N/A field operator values Id EQUALS N/A batch_job_id N/A N/A N/A N/A N/A batch_job_service get selector N/A entries N/A 0 N/A GetBatchJobDownloadUrlWhenReady N/A N/A client batch_job_id max_poll_attempts N/A MAX_POLL_ATTEMPTS N/A N/A Retrieves the downloadUrl when the BatchJob is complete.

  Args:
    client: an instantiated AdWordsClient used to poll the BatchJob.
    batch_job_id: a long identifying the BatchJob to be polled.
    max_poll_attempts: an int defining the number of times the the BatchJob will
      be checked to determine whether it has completed.

  Returns:
    A str containing the downloadUrl of the completed BatchJob.

  Raises:
    Exception: If the BatchJob hasn't finished after the maximum poll attempts
      have been made.
   N/A batch_job N/A GetBatchJob client batch_job_id N/A poll_attempt 0 N/A N/A N/A poll_attempt N/A range max_poll_attempts N/A N/A batch_job N/A status PENDING_STATUSES N/A N/A sleep_interval N/A N/A 30 N/A 2 poll_attempt N/A N/A N/A random randint 0 10000 1000 N/A N/A Batch Job not ready, sleeping for %s seconds. sleep_interval N/A N/A N/A time sleep sleep_interval N/A batch_job N/A GetBatchJob client batch_job_id N/A poll_attempt 1 N/A N/A downloadUrl batch_job N/A N/A url N/A N/A batch_job N/A downloadUrl N/A url N/A N/A Batch Job with Id "%s", Status "%s", and DownloadUrl "%s" ready. N/A N/A batch_job N/A id N/A batch_job N/A status url N/A url N/A N/A Exception Batch Job not finished downloading. Try checking later. N/A PrintResponse N/A N/A batch_job_helper response_xml N/A N/A N/A Prints the BatchJobService response.

  Args:
    batch_job_helper: a BatchJobHelper instance.
    response_xml: a string containing a response from the BatchJobService.
   N/A response N/A N/A batch_job_helper ParseResponse response_xml N/A N/A rval N/A response N/A mutateResponse N/A N/A data N/A N/A response N/A mutateResponse N/A rval N/A N/A N/A errorList data N/A N/A N/A Operation %s - FAILURE: N/A data N/A index N/A N/A 	errorType=%s N/A N/A N/A data N/A errorList N/A errors N/A ApiError.Type N/A N/A 	trigger=%s N/A N/A N/A data N/A errorList N/A errors N/A trigger N/A N/A 	errorString=%s N/A N/A N/A data N/A errorList N/A errors N/A errorString N/A N/A 	fieldPath=%s N/A N/A N/A data N/A errorList N/A errors N/A fieldPath N/A N/A 	reason=%s N/A N/A N/A data N/A errorList N/A errors N/A reason N/A N/A result data N/A N/A N/A Operation %s - SUCCESS. N/A data N/A index N/A N/A N/A __name__ __main__ N/A N/A adwords_client N/A N/A N/A adwords AdWordsClient LoadFromStorage N/A N/A main adwords_client NUMBER_OF_CAMPAIGNS_TO_ADD NUMBER_OF_ADGROUPS_TO_ADD NUMBER_OF_KEYWORDS_TO_ADD