78 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			78 lines
		
	
	
		
			2.2 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| 
 | |
| module Devops
 | |
|   module Version2_0
 | |
|     module Routes
 | |
|       module ScriptRoutes
 | |
| 
 | |
|         def self.registered(app)
 | |
|           # Get scripts names
 | |
|           #
 | |
|           # * *Request*
 | |
|           #   - method : GET
 | |
|           #   - headers :
 | |
|           #     - Accept: application/json
 | |
|           #
 | |
|           # * *Returns* :
 | |
|           #   [
 | |
|           #     "script_1"
 | |
|           #   ]
 | |
|           app.get_with_headers "/scripts", :headers => [:accept], &Devops::Version2_0::Handler::Script.get_scripts
 | |
| 
 | |
|           # Run command on node :node_name
 | |
|           #
 | |
|           # * *Request*
 | |
|           #   - method : POST
 | |
|           #   - body :
 | |
|           #     command to run
 | |
|           #
 | |
|           # * *Returns* : text stream
 | |
|           app.post_with_statistic "/script/command/:node_name", &Devops::Version2_0::Handler::Script.execute_command
 | |
| 
 | |
|           # Run script :script_name on nodes
 | |
|           #
 | |
|           # * *Request*
 | |
|           #   - method : POST
 | |
|           #   - headers :
 | |
|           #     - Content-Type: application/json
 | |
|           #   - body :
 | |
|           #     {
 | |
|           #       "nodes": [], -> array of nodes names
 | |
|           #       "params": [] -> array of script arguments
 | |
|           #     }
 | |
|           #
 | |
|           # * *Returns* : text stream
 | |
|           app.post_with_headers "/script/run/:script_name", :headers => [:content_type], &Devops::Version2_0::Handler::Script.run_script
 | |
| 
 | |
|           hash = {}
 | |
|           # Create script :script_name
 | |
|           #
 | |
|           # * *Request*
 | |
|           #   - method : PUT
 | |
|           #   - headers :
 | |
|           #     - Accept: application/json
 | |
|           #   - body : script content
 | |
|           #
 | |
|           # * *Returns* :
 | |
|           #   201 - Created
 | |
|           hash["PUT"] = Devops::Version2_0::Handler::Script.create_script
 | |
| 
 | |
|           # Delete script :script_name
 | |
|           #
 | |
|           # * *Request*
 | |
|           #   - method : Delete
 | |
|           #   - headers :
 | |
|           #     - Accept: application/json
 | |
|           #
 | |
|           # * *Returns* :
 | |
|           #   200 - Deleted
 | |
|           hash["DELETE"] = Devops::Version2_0::Handler::Script.delete_script
 | |
|           app.multi_routes "/script/:script_name", {:headers => [:accept]}, hash
 | |
| 
 | |
|           puts "Script routes initialized"
 | |
|         end
 | |
| 
 | |
|       end
 | |
|     end
 | |
|   end
 | |
| end
 | 
