Create or update a Media attached to a post.

        :param bulk_mode: If True, minimize db operations by bulk creating post objects
        :param api_media_attachment: the API data for the Media
        :return: the Media attachment object

def process_post_media_attachment(self, bulk_mode, api_media_attachment):
        """
        Create or update a Media attached to a post.

        :param bulk_mode: If True, minimize db operations by bulk creating post objects
        :param api_media_attachment: the API data for the Media
        :return: the Media attachment object
        """
        attachment = None

        # try to get from the ref data map if in bulk mode
        if bulk_mode:
            attachment = self.ref_data_map["media"].get(api_media_attachment["ID"])

        # double check the db before giving up, we may have sync'd it in a previous run
        if not attachment:
            # do a direct db lookup if we're not in bulk mode
            attachment, created = self.get_or_create_media(api_media_attachment)
            if attachment and not created:
                self.update_existing_media(attachment, api_media_attachment)

            # add to ref data map so later lookups work
            if attachment:
                self.ref_data_map["media"][api_media_attachment["ID"]] = attachment

        return attachment