import uuid


def CreateAdGroup(client, campaign_id):
  """Creates an AdGroup for the given shopping campaign ID.

  Args:
    client: an AdWordsClient instance.
    campaign_id: the str ID of a shopping campaign.

  Returns:
    The created AdGroup as a sudsobject.
  """
  ad_group_service = client.GetService('AdGroupService', 'v201809')

  adgroup = {
      # Required: Set the ad group type to SHOPPING_SHOWCASE_ADS
      'adGroupType': 'SHOPPING_SHOWCASE_ADS',
      'campaignId': campaign_id,
      'name': 'AdGroup #%s' % uuid.uuid4(),
      # REQUIRED: Set the ad group's bidding strategy configuration.
      'biddingStrategyConfiguration': {
          # Showcase ads require either ManualCpc or EnhancedCpc.
          'biddingStrategyType': 'MANUAL_CPC',
          # Optional: Set the bids
          'bids': [{
              'xsi_type': 'CpcBid',
              'bid': {
                  'microAmount': 100000
              }
          }]
      }
  }

  adgroup_operations = {
      'operator': 'ADD',
      'operand': adgroup
  }

  # Make the mutate request to add the AdGroup to the Shopping Campaign
  adgroup = ad_group_service.mutate(adgroup_operations)['value'][0]

  print ('AdGroup with name "%s" and ID "%s" was added.'
         % (adgroup['name'], adgroup['id']))

  return adgroup