def SetCampaignTargetingCriteria(client, campaign):
  """Sets targeting criteria for the given campaign.

  Args:
    client: An AdWordsClient instance.
    campaign: A suds object representing the campaign we wish to attach
      targeting criteria.
  """
  campaign_criterion_service = client.GetService('CampaignCriterionService')

  # Create locations. The IDs can be found in the documentation or retrieved
  # with the LocationCriterionService.
  criteria = [
      {
          'xsi_type': 'Location',
          'id': 21137  # California
      },
      {
          'xsi_type': 'Location',
          'id': 2484  # Mexico
      },
      {
          'xsi_type': 'Language',
          'id': 1000  # English
      },
      {
          'xsi_type': 'Language',
          'id': 1003  # Spanish
      }
  ]

  operations = [{
      'operator': 'ADD',
      'operand': {
          'campaignId': campaign['id'],
          'criterion': criterion
      }
  } for criterion in criteria]

  response = campaign_criterion_service.mutate(operations)

  if response and 'value' in response:
    # Display the added campaign targets.
    for criterion in response['value']:
      print ('Campaign criteria of type "%s" and id "%s" was added.'
             % (criterion['criterion']['type'],
                criterion['criterion']['id']))
Sets targeting criteria for the given campaign.

  Args:
    client: An AdWordsClient instance.
    campaign: A suds object representing the campaign we wish to attach
      targeting criteria.