travis-api/lib/travis/api/app/endpoint/logs.rb
Hiro Asari 5c079f8e66 Add specs for RemoveLog service
Status code is debatable; I opted for 422 when the job is still
running, and for 500 if unexpected error happened
2014-06-11 09:30:50 -04:00

32 lines
873 B
Ruby

require 'travis/api/app'
class Travis::Api::App
class Endpoint
# Logs are generated by builds.
class Logs < Endpoint
# Fetches a log by its *id*.
get '/:id' do |id|
respond_with service(:find_log, params)
end
# Clears up the content of the log by the *job id*
# Optionally takes parameter *reason*
patch '/:id' do |id|
begin
result = self.service(:remove_log, params)
respond_with result
rescue Travis::AuthorizationDenied => ade
status 401
{ error: { message: ade.message } }
rescue Travis::JobUnfinished => jue
status 422
{ error: { message: "Job #{id} is not finished" } }
rescue => e
status 500
{ error: { message: "Unexpected error occurred: #{e.message}" } }
end
end
end
end
end