def _append_view_properties(self, rule_enforcement_apis):
        """
        Method which appends corresponding execution (if available) and trigger instance object
        properties.
        """
        trigger_instance_ids = set([])
        execution_ids = []

        for rule_enforcement_api in rule_enforcement_apis:
            if rule_enforcement_api.get("trigger_instance_id", None):
                trigger_instance_ids.add(
                    str(rule_enforcement_api["trigger_instance_id"])
                )

            if rule_enforcement_api.get("execution_id", None):
                execution_ids.append(rule_enforcement_api["execution_id"])

        # 1. Retrieve corresponding execution objects
        # NOTE: Executions contain a lot of field and could contain a lot of data so we only
        # retrieve fields we need
        only_fields = [
            "id",
            "action.ref",
            "action.parameters",
            "runner.name",
            "runner.runner_parameters",
            "parameters",
            "status",
        ]
        execution_dbs = ActionExecution.query(
            id__in=execution_ids, only_fields=only_fields
        )

        execution_dbs_by_id = {}
        for execution_db in execution_dbs:
            execution_dbs_by_id[str(execution_db.id)] = execution_db

        # 2. Retrieve corresponding trigger instance objects
        trigger_instance_dbs = TriggerInstance.query(id__in=list(trigger_instance_ids))

        trigger_instance_dbs_by_id = {}

        for trigger_instance_db in trigger_instance_dbs:
            trigger_instance_dbs_by_id[
                str(trigger_instance_db.id)
            ] = trigger_instance_db

        # Ammend rule enforcement objects with additional data
        for rule_enforcement_api in rule_enforcement_apis:
            rule_enforcement_api["trigger_instance"] = {}
            rule_enforcement_api["execution"] = {}

            trigger_instance_id = rule_enforcement_api.get("trigger_instance_id", None)
            execution_id = rule_enforcement_api.get("execution_id", None)

            trigger_instance_db = trigger_instance_dbs_by_id.get(
                trigger_instance_id, None
            )
            execution_db = execution_dbs_by_id.get(execution_id, None)

            if trigger_instance_db:
                trigger_instance_api = TriggerInstanceAPI.from_model(
                    trigger_instance_db
                )
                rule_enforcement_api["trigger_instance"] = trigger_instance_api

            if execution_db:
                execution_api = ActionExecutionAPI.from_model(execution_db)
                rule_enforcement_api["execution"] = execution_api

        return rule_enforcement_apis

        Method which appends corresponding execution (if available) and trigger instance object
        properties.
        
st2api/st2api/controllers/v1/rule_enforcement_views.py