fluke/devops-service/routes/v2.0/script.rb

78 lines
2.2 KiB
Ruby
Raw Normal View History

2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
module Devops
module Version2_0
2014-12-22 14:22:04 +03:00
module Routes
2014-12-15 14:26:54 +03:00
module ScriptRoutes
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
def self.registered(app)
# Get scripts names
#
# * *Request*
# - method : GET
# - headers :
# - Accept: application/json
#
# * *Returns* :
# [
# "script_1"
# ]
2015-02-19 11:27:56 +03:00
app.get_with_headers "/scripts", :headers => [:accept], &Devops::Version2_0::Handler::Script.get_scripts
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
# Run command on node :node_name
#
# * *Request*
# - method : POST
# - body :
# command to run
#
# * *Returns* : text stream
2015-02-19 11:27:56 +03:00
app.post_with_statistic "/script/command/:node_name", &Devops::Version2_0::Handler::Script.execute_command
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
# 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
2015-02-19 11:27:56 +03:00
app.post_with_headers "/script/run/:script_name", :headers => [:content_type], &Devops::Version2_0::Handler::Script.run_script
2014-05-08 15:34:26 +04:00
2015-02-19 11:27:56 +03:00
hash = {}
2014-12-15 14:26:54 +03:00
# Create script :script_name
#
# * *Request*
# - method : PUT
# - headers :
# - Accept: application/json
# - body : script content
#
# * *Returns* :
# 201 - Created
2015-02-19 11:27:56 +03:00
hash["PUT"] = Devops::Version2_0::Handler::Script.create_script
2014-12-15 14:26:54 +03:00
# Delete script :script_name
#
# * *Request*
# - method : Delete
# - headers :
# - Accept: application/json
#
# * *Returns* :
# 200 - Deleted
2015-02-19 11:27:56 +03:00
hash["DELETE"] = Devops::Version2_0::Handler::Script.delete_script
app.multi_routes "/script/:script_name", {:headers => [:accept]}, hash
2014-05-08 15:34:26 +04:00
2014-12-15 14:26:54 +03:00
puts "Script routes initialized"
end
end
2014-05-08 15:34:26 +04:00
end
end
end