def BuildAdGroupCriterionOperations(adgroup_id):
  criterion_operations = [
      {
          # You must specify the xsi_type of operations run by the
          # BatchJobService.
          'xsi_type': 'AdGroupCriterionOperation',
          'operand': {
              'xsi_type': 'BiddableAdGroupCriterion',
              'adGroupId': adgroup_id,
              'criterion': {
                  'xsi_type': 'Keyword',
                  # Make 10% of keywords invalid to demonstrate error handling.
                  'text': 'mars%s%s' % (uuid.uuid4(),
                                        '!!!' if i % 10 == 0 else ''),
                  'matchType': 'BROAD'
              }
          },
          'operator': 'ADD'
      }
      for i in range(KEYWORD_COUNT)]

  return criterion_operations
Builds the operations adding a Keyword Criterion to each AdGroup.
dataset/ETHPy150Open googleads/googleads-python-lib/examples/adwords/v201509/campaign_management/add_keywords_using_incremental_batch_job.py/BuildAdGroupCriterionOperations