| 
									
										
										
										
											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 | 
					
						
							| 
									
										
										
										
											2015-07-30 15:37:43 +03:00
										 |  |  |             json Devops::API2_0::Handler::Report.new(request).all.map{|r| r.to_hash} | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |           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 | 
					
						
							| 
									
										
										
										
											2015-07-30 15:37:43 +03:00
										 |  |  |             json Devops::API2_0::Handler::Report.new(request).all_latest.map{|r| r.to_hash} | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |           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| | 
					
						
							| 
									
										
										
										
											2015-07-30 15:37:43 +03:00
										 |  |  |             json Devops::API2_0::Handler::Report.new(request).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| | 
					
						
							| 
									
										
										
										
											2015-07-30 15:37:43 +03:00
										 |  |  |             @text, @done = Devops::API2_0::Handler::Report.new(request).report(id) | 
					
						
							| 
									
										
										
										
											2015-08-03 15:09:04 +03:00
										 |  |  |             erb :report | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							| 
									
										
										
										
											2015-07-30 15:37:43 +03:00
										 |  |  |           app.get "/status/:id" do |id| | 
					
						
							|  |  |  |             r = Devops::API2_0::Handler::Report.new(request).status(id) | 
					
						
							| 
									
										
										
										
											2015-08-06 12:37:56 +03:00
										 |  |  |             return [404, "Job with id '#{id}' not found"] if r.nil? | 
					
						
							| 
									
										
										
										
											2015-07-23 16:56:51 +03:00
										 |  |  |             r | 
					
						
							|  |  |  |           end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |           puts "Report routes initialized" | 
					
						
							| 
									
										
										
										
											2015-06-30 14:27:42 +03:00
										 |  |  |         end | 
					
						
							|  |  |  | 
 | 
					
						
							|  |  |  |       end | 
					
						
							|  |  |  |     end | 
					
						
							|  |  |  |   end | 
					
						
							|  |  |  | end | 
					
						
							|  |  |  | 
 |