def main(client, activity_group_id, advertiser_company_id):
  # Initialize appropriate service.
  activity_group_service = client.GetService('ActivityGroupService',
                                             version='v201508')

  # Create statement object to select a single activity groups by ID.
  values = [{
      'key': 'activityGroupId',
      'value': {
          'xsi_type': 'NumberValue',
          'value': activity_group_id
      }
  }]
  query = 'WHERE id = :activityGroupId'

  # Create a filter statement.
  statement = dfp.FilterStatement(query, values, 1)

  # Get activity groups by statement.
  response = activity_group_service.getActivityGroupsByStatement(
      statement.ToStatement())
  if 'results' in response:
    updated_activity_groups = []
    for activity_group in response['results']:
      activity_group['companyIds'].append(advertiser_company_id)
      updated_activity_groups.append(activity_group)
    # Update the activity groups on the server.
    activity_groups = activity_group_service.updateActivityGroups(
        updated_activity_groups)

    for activity_group in activity_groups:
      print (('Activity group with ID \'%s\' and name \'%s\' was updated.')
             % (activity_group['id'], activity_group['name']))
  else:
    print 'No activity groups found to update.'
dataset/ETHPy150Open googleads/googleads-python-lib/examples/dfp/v201508/activity_group_service/update_activity_groups.py/main/original