| 
									
										
										
										
											2015-06-30 14:27:42 +03:00
										 |  |  | module Devops | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |   module API2_0 | 
					
						
							| 
									
										
										
										
											2015-06-30 14:27:42 +03:00
										 |  |  |     module Routes | 
					
						
							|  |  |  |       module ReportRoutes | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |         def self.registered(app) | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |           app.get_with_headers "/report/all", headers: [:accept] do | 
					
						
							|  |  |  |             json Devops::API2_0::Handler::Report.new(request, params).all.map{|r| r.to_hash} | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2015-06-30 14:27:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |           app.get_with_headers "/report/all/latest", headers: [:accept] do | 
					
						
							|  |  |  |             json Devops::API2_0::Handler::Report.new(request, params).all_latest.map{|r| r.to_hash} | 
					
						
							|  |  |  |           end | 
					
						
							| 
									
										
										
										
											2015-06-30 14:27:42 +03:00
										 |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |           app.get_with_headers "/report/all/attributes/:name", headers: [:accept] do |name| | 
					
						
							|  |  |  |             json Devops::API2_0::Handler::Report.new(request, params).attributes(name) | 
					
						
							| 
									
										
										
										
											2015-06-30 14:27:42 +03:00
										 |  |  |           end | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  | 
 | 
					
						
							|  |  |  |           app.get_with_headers "/report/:id", headers: [:accept] do |id| | 
					
						
							|  |  |  |             @text, @done = Devops::API2_0::Handler::Report.new(request, params).report(id) | 
					
						
							|  |  |  |             erb :index | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           app.get "/status/:id" do | 
					
						
							|  |  |  |             r = Devops::API2_0::Handler::Report.new(request, params).status(params[:id]) | 
					
						
							|  |  |  |             return [404, "Job with id '#{params[:id]}' not found"] if r.nil? | 
					
						
							|  |  |  |             r | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           puts "Report routes initialized" | 
					
						
							| 
									
										
										
										
											2015-06-30 14:27:42 +03:00
										 |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | __END__
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @@ layout | 
					
						
							|  |  |  | <html> | 
					
						
							|  |  |  |   <head> | 
					
						
							|  |  |  |     <% unless  @done %> | 
					
						
							|  |  |  |     <script> | 
					
						
							|  |  |  |       function reload() { | 
					
						
							|  |  |  |         location.reload(); | 
					
						
							|  |  |  |       } | 
					
						
							|  |  |  |       setTimeout(reload, 5000); | 
					
						
							|  |  |  |     </script>
 | 
					
						
							|  |  |  |     <% end  %> | 
					
						
							|  |  |  |   </head>
 | 
					
						
							|  |  |  |   <body> | 
					
						
							|  |  |  |     <%= yield %> | 
					
						
							|  |  |  |   </body>
 | 
					
						
							|  |  |  | </html>
 | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  | @@ index | 
					
						
							|  |  |  | <pre> | 
					
						
							|  |  |  | <%= @text %> | 
					
						
							|  |  |  | </pre>
 |