Class: Orchestrator::Api::DependenciesController
- Inherits:
-
Orchestrator::ApiController
- Object
- ActionController::Base
- Base
- Orchestrator::ApiController
- Orchestrator::Api::DependenciesController
- Defined in:
- app/controllers/orchestrator/api/dependencies_controller.rb
Instance Method Summary collapse
- #create ⇒ Object
- #destroy ⇒ Object
- #index ⇒ Object
-
#reload ⇒ Object
Additional Functions:.
- #show ⇒ Object
- #update ⇒ Object
Methods inherited from Base
Instance Method Details
#create ⇒ Object
39 40 41 42 |
# File 'app/controllers/orchestrator/api/dependencies_controller.rb', line 39 def create dep = Dependency.new(safe_params) save_and_respond dep end |
#destroy ⇒ Object
44 45 46 47 |
# File 'app/controllers/orchestrator/api/dependencies_controller.rb', line 44 def destroy @dep.delete render :nothing => true end |
#index ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# File 'app/controllers/orchestrator/api/dependencies_controller.rb', line 14 def index role = params.permit(:role)[:role] query = @@elastic.query(params) if role && Dependency::ROLES.include?(role.to_sym) query.filter({ role: [role] }) end query.sort = [{name: "asc"}] respond_with @@elastic.search(query) end |
#reload ⇒ Object
Additional Functions:
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'app/controllers/orchestrator/api/dependencies_controller.rb', line 54 def reload depman = ::Orchestrator::DependencyManager.instance depman.load(@dep, :force).then(proc { updated = 0 @dep.modules.each do |mod| manager = mod.manager if manager updated += 1 manager.reloaded(mod) end end content = { message: updated == 1 ? "#{updated} module updated" : "#{updated} modules updated" }.to_json env['async.callback'].call([200, { 'Content-Length' => content.bytesize, 'Content-Type' => 'application/json' }, [content]]) }, proc { |err| output = err. env['async.callback'].call([500, { 'Content-Length' => output.bytesize, 'Content-Type' => 'text/plain' }, [output]]) }) throw :async end |
#show ⇒ Object
29 30 31 |
# File 'app/controllers/orchestrator/api/dependencies_controller.rb', line 29 def show respond_with @dep end |
#update ⇒ Object
33 34 35 36 37 |
# File 'app/controllers/orchestrator/api/dependencies_controller.rb', line 33 def update # Must destroy and re-add to change class or module name @dep.update_attributes(update_params) save_and_respond @dep end |