From 08ea5b9a4a8eb29a567db67da7f88e0fa771e45a Mon Sep 17 00:00:00 2001 From: Keenan Brock Date: Fri, 23 Feb 2024 03:17:59 -0500 Subject: [PATCH] Add MiqTask#deliver and execute --- app/controllers/api/request_tasks_controller.rb | 9 +++++++++ config/api.yml | 2 ++ 2 files changed, 11 insertions(+) diff --git a/app/controllers/api/request_tasks_controller.rb b/app/controllers/api/request_tasks_controller.rb index 1fb6414328..2ae5b1b927 100644 --- a/app/controllers/api/request_tasks_controller.rb +++ b/app/controllers/api/request_tasks_controller.rb @@ -1,5 +1,14 @@ module Api class RequestTasksController < BaseController include Api::Mixins::ResourceCancel + + # execute queues the work. + # this is typically called from within the workflow + def execute_resource(type, id, _data) + api_resource(type, id, "Executing") do |task| + raise BadRequestError, "Resource must be approved. state is #{task.state}" unless task.approved? + task.execute_queue + end + end end end diff --git a/config/api.yml b/config/api.yml index d9f35c7921..c65629d04e 100644 --- a/config/api.yml +++ b/config/api.yml @@ -3233,6 +3233,8 @@ :post: - :name: cancel :identifier: miq_request_control + - :name: execute + :identifier: miq_request_control :subcollection_actions: :get: - :name: read