Example #1
0
    def put(self, id, event_trigger):
        """Updates an existing event trigger.

        The exchange, topic and event can not be updated. The right way to
        change them is to delete the event trigger first, then create a new
        event trigger with new params.
        """
        acl.enforce('event_triggers:update', auth_ctx.ctx())

        values = event_trigger.to_dict()

        for field in UPDATE_NOT_ALLOWED:
            if values.get(field):
                raise exc.EventTriggerException(
                    "Can not update fields %s of event trigger." %
                    UPDATE_NOT_ALLOWED)

        LOG.info('Update event trigger: [id=%s, values=%s]', id, values)

        with db_api.transaction():
            # ensure that event trigger exists
            db_api.get_event_trigger(id)

            db_model = triggers.update_event_trigger(id, values)

        return resources.EventTrigger.from_db_model(db_model)
Example #2
0
    def get(self, id):
        """Returns the specified event_trigger."""
        acl.enforce('event_trigger:get', auth_ctx.ctx())

        LOG.info('Fetch event trigger [id=%s]', id)

        db_model = db_api.get_event_trigger(id)

        return resources.EventTrigger.from_dict(db_model.to_dict())
Example #3
0
    def delete(self, id):
        """Delete event trigger."""
        acl.enforce('event_trigger:delete', auth_ctx.ctx())

        LOG.info("Delete event trigger [id=%s]", id)

        event_trigger = db_api.get_event_trigger(id)

        triggers.delete_event_trigger(event_trigger.to_dict())
Example #4
0
    def delete(self, id):
        """Delete event trigger."""
        acl.enforce('event_trigger:delete', auth_ctx.ctx())

        LOG.info("Delete event trigger [id=%s]", id)

        with db_api.transaction():
            event_trigger = db_api.get_event_trigger(id)

            triggers.delete_event_trigger(event_trigger.to_dict())
    def delete(self, id):
        """Delete event trigger."""
        acl.enforce('event_triggers:delete', auth_ctx.ctx())

        LOG.debug("Delete event trigger [id=%s]", id)

        with db_api.transaction():
            event_trigger = db_api.get_event_trigger(id)

            triggers.delete_event_trigger(event_trigger.to_dict())
        def _delete_event_trigger():
            with db_api.transaction():
                event_trigger = db_api.get_event_trigger(id)

                triggers.delete_event_trigger(event_trigger.to_dict())
        def _update_event_trigger():
            with db_api.transaction():
                # ensure that event trigger exists
                db_api.get_event_trigger(id)

                return triggers.update_event_trigger(id, values)
Example #8
0
        def _delete_event_trigger():
            with db_api.transaction():
                event_trigger = db_api.get_event_trigger(id)

                triggers.delete_event_trigger(event_trigger.to_dict())
Example #9
0
        def _update_event_trigger():
            with db_api.transaction():
                # ensure that event trigger exists
                db_api.get_event_trigger(id)

                return triggers.update_event_trigger(id, values)