def GetFeedItemIdsForCampaign(campaign_feed):
  """Gets the Feed Item Ids used by a campaign through a given Campaign Feed.

  Args:
    campaign_feed: the Campaign Feed we are retrieving Feed Item Ids from.

  Returns:
    A list of Feed Item IDs.
  """
  feed_item_ids = set()

  try:
    lhs_operand = campaign_feed['matchingFunction']['lhsOperand']
  except __HOLE__:
    lhs_operand = None

  if (lhs_operand and lhs_operand[0]['FunctionArgumentOperand.Type'] ==
      'RequestContextOperand'):
    request_context_operand = lhs_operand[0]

    if (request_context_operand['contextType'] == 'FEED_ITEM_ID' and
        campaign_feed['matchingFunction']['operator'] == 'IN'):
      for argument in campaign_feed['matchingFunction']['rhsOperand']:
        if argument['xsi_type'] == 'ConstantOperand':
          feed_item_ids.add(argument['longValue'])

  return feed_item_ids
dataset/ETHPy150Open googleads/googleads-python-lib/examples/adwords/v201603/migration/migrate_to_extension_settings.py/GetFeedItemIdsForCampaign