forked from ManageIQ/manageiq-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathservice_templates_controller.rb
54 lines (45 loc) · 1.83 KB
/
service_templates_controller.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
module Api
class ServiceTemplatesController < BaseController
include Subcollections::ServiceDialogs
include Subcollections::Tags
include Subcollections::ResourceActions
include Subcollections::ServiceRequests
include Api::Mixins::Pictures
include Api::Mixins::ServiceTemplates
before_action :set_additional_attributes, :only => [:show]
alias fetch_service_templates_picture fetch_picture
def create_resource(_type, _id, data)
catalog_item_type = ServiceTemplate.class_from_request_data(data)
catalog_item_type.create_catalog_item(data.deep_symbolize_keys, User.current_user.userid)
rescue => err
raise BadRequestError, "Could not create Service Template - #{err}"
end
def edit_resource(type, id, data)
catalog_item = resource_search(id, type, collection_class(:service_templates))
catalog_item.update_catalog_item(data.deep_symbolize_keys, User.current_user.userid)
rescue => err
raise BadRequestError, "Could not update Service Template - #{err}"
end
def order_resource(_type, id, data)
order_service_template(id, data)
end
def archive_resource(type, id, _data)
service_template = resource_search(id, type, collection_class(type))
service_template.archive!
action_result(true, "Archived Service Template")
rescue => err
action_result(false, "Could not archive Service Template - #{err}")
end
def unarchive_resource(type, id, _data)
service_template = resource_search(id, type, collection_class(type))
service_template.unarchive!
action_result(true, "Unarchived Service Template")
rescue => err
action_result(false, "Could not unarchive Service Template - #{err}")
end
private
def set_additional_attributes
@additional_attributes = %w(config_info)
end
end
end