62 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
			
		
		
	
	
			62 lines
		
	
	
		
			1.4 KiB
		
	
	
	
		
			Ruby
		
	
	
	
	
	
| module Devops
 | |
|   module API2_0
 | |
|     module Routes
 | |
|       module ReportRoutes
 | |
| 
 | |
|         def self.registered(app)
 | |
| 
 | |
|           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
 | |
| 
 | |
|           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
 | |
| 
 | |
|           app.get_with_headers "/report/all/attributes/:name", headers: [:accept] do |name|
 | |
|             json Devops::API2_0::Handler::Report.new(request, params).attributes(name)
 | |
|           end
 | |
| 
 | |
|           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"
 | |
|         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>
 | 
