-
Notifications
You must be signed in to change notification settings - Fork 141
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Allow ordering of service templates directly
For the new ServiceTemplateTransformationPlan, ordering must happen directly on the service template. Currently, the API only allows ordering through a service catalog.
- Loading branch information
Jillian Tullo
committed
Feb 8, 2018
1 parent
f304c85
commit b5693a1
Showing
5 changed files
with
114 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
module Api | ||
module Mixins | ||
module ServiceTemplates | ||
def order_template(id, data) | ||
service_template = resource_search(id, :service_templates, ServiceTemplate) | ||
raise BadRequestError, "#{service_template_ident(service_template)} cannot be ordered" unless service_template.orderable? | ||
workflow = service_template.provision_workflow(User.current_user, data || {}) | ||
request_result = workflow.submit_request | ||
errors = request_result[:errors] | ||
if errors.present? | ||
raise BadRequestError, "Failed to order #{service_template_ident(service_template)} - #{errors.join(", ")}" | ||
end | ||
request_result[:request] | ||
end | ||
|
||
private | ||
|
||
def service_template_ident(st) | ||
"Service Template id:#{st.id} name:'#{st.name}'" | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters