code: def _UpdateCampaignDSASetting(client, campaign_id, feed_id):
    
    # Get the CampaignService.
    campaign_service = client.GetService('CampaignService', version='v201809')
  
    selector = {
        'fields': ['Id', 'Settings'],
        'predicates': [{
            'field': 'Id',
            'operator': 'EQUALS',
            'values': [campaign_id]
        }]
    }
  
    response = campaign_service.get(selector)
  
    if response['totalNumEntries']:
      campaign = response['entries'][0]
    else:
      raise ValueError('No campaign with ID "%d" exists.' % campaign_id)
  
    if not campaign['settings']:
      raise ValueError('This is not a DSA campaign.')
  
    dsa_setting = None
  
    campaign_settings = campaign['settings']
  
    for setting in campaign_settings:
      if setting['Setting.Type'] == 'DynamicSearchAdsSetting':
        dsa_setting = setting
        break
  
    if dsa_setting is None:
      raise ValueError('This is not a DSA campaign.')
  
    dsa_setting['pageFeed'] = {
        'feedIds': [feed_id]
    }
  
    # Optional: Specify whether only the supplied URLs should be used with your
    # Dynamic Search Ads.
    dsa_setting['useSuppliedUrlsOnly'] = True
  
    operation = {
        'operand': {
            'id': campaign_id,
            'settings': campaign_settings
        },
        'operator': 'SET'
    }
  
    campaign_service.mutate([operation])
    print 'DSA page feed for campaign ID "%d" was updated with feed ID "%d".' % (
        campaign_id, feed_id)
docs: Updates the campaign DSA setting to DSA pagefeeds.
  
    Args:
      client: an AdWordsClient instance.
      campaign_id: a str Campaign ID.
      feed_id: a str page Feed ID.
  
    Raises:
      ValueError: If the given campaign is found not to be a dynamic search ad
      campaign.