adapt changes for split services
This commit is contained in:
parent
ff4dd4d61b
commit
5ff58b1d6c
|
@ -87,10 +87,7 @@ class Travis::Api::App
|
||||||
def self.setup_travis
|
def self.setup_travis
|
||||||
Travis::Amqp.config = Travis.config.amqp
|
Travis::Amqp.config = Travis.config.amqp
|
||||||
Travis::Database.connect
|
Travis::Database.connect
|
||||||
|
# Travis::Services.namespace = Travis::Services
|
||||||
Travis::Services.constants.each do |name|
|
|
||||||
Travis.services[name.to_s.underscore.to_sym] = Travis::Services.const_get(name) unless name == :Base
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def self.load_endpoints
|
def self.load_endpoints
|
||||||
|
|
|
@ -4,10 +4,12 @@ require 'addressable/uri'
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
# Superclass for HTTP endpoints. Takes care of prefixing.
|
# Superclass for HTTP endpoints. Takes care of prefixing.
|
||||||
class Endpoint < Responder
|
class Endpoint < Responder
|
||||||
|
include Travis::Services
|
||||||
|
|
||||||
set(:prefix) { "/" << name[/[^:]+$/].underscore }
|
set(:prefix) { "/" << name[/[^:]+$/].underscore }
|
||||||
set disable_root_endpoint: false
|
set disable_root_endpoint: false
|
||||||
register :scoping
|
register :scoping
|
||||||
helpers :services, :current_user
|
helpers :current_user # :services
|
||||||
|
|
||||||
before { content_type :json }
|
before { content_type :json }
|
||||||
error(ActiveRecord::RecordNotFound, Sinatra::NotFound) { not_found }
|
error(ActiveRecord::RecordNotFound, Sinatra::NotFound) { not_found }
|
||||||
|
|
|
@ -4,7 +4,7 @@ class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
class Accounts < Endpoint
|
class Accounts < Endpoint
|
||||||
get '/', scope: :private do
|
get '/', scope: :private do
|
||||||
body service(:account).find_all, type: :accounts
|
body all(params).run, type: :accounts
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -7,7 +7,7 @@ class Travis::Api::App
|
||||||
class Artifacts < Endpoint
|
class Artifacts < Endpoint
|
||||||
# Fetches an artifact by it's *id*.
|
# Fetches an artifact by it's *id*.
|
||||||
get('/:id') do |id|
|
get('/:id') do |id|
|
||||||
body service(:artifacts).find_one(params)
|
body one(params).run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,11 +2,9 @@ require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
class Branches < Endpoint
|
class Branches < Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
get('/') do
|
get('/') do
|
||||||
body service(:branches).find_all(params), type: :branches
|
body all(params).run, type: :branches
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,16 +2,13 @@ require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
class Builds < Endpoint
|
class Builds < Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
get '/' do
|
get '/' do
|
||||||
body service(:builds).find_all(params)
|
body all(params).run
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add documentation.
|
|
||||||
get '/:id' do
|
get '/:id' do
|
||||||
body service(:builds).find_one(params)
|
body one(params).run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,16 +2,14 @@ require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
class Hooks < Endpoint
|
class Hooks < Endpoint
|
||||||
# TODO: Add implementation and documentation.
|
|
||||||
get('/', scope: :private) do
|
get('/', scope: :private) do
|
||||||
body service(:hooks).find_all(params), type: :hooks
|
body all(params).run, type: :hooks
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add implementation and documentation.
|
|
||||||
put('/:id', scope: :private) do
|
put('/:id', scope: :private) do
|
||||||
body service(:hooks).update(params[:hook])
|
update(params[:hook]).run
|
||||||
|
204
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,16 +2,13 @@ require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
class Jobs < Endpoint
|
class Jobs < Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
get('/') do
|
get('/') do
|
||||||
body service(:jobs).find_all(params)
|
body all(params).run
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add documentation.
|
|
||||||
get('/:id') do
|
get('/:id') do
|
||||||
body service(:jobs).find_one(params)
|
body one(params).run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,16 +2,13 @@ require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
class Repositories < Endpoint
|
class Repositories < Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
get '/' do
|
get '/' do
|
||||||
body service(:repositories).find_all(params)
|
body all(params).run
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add documentation.
|
|
||||||
get('/:id') do
|
get('/:id') do
|
||||||
body service(:repositories).find_one(params)
|
body one(params).run
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO make sure status images and cc.xml work
|
# TODO make sure status images and cc.xml work
|
||||||
|
|
|
@ -2,16 +2,13 @@ require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
class Stats < Endpoint
|
class Stats < Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
get('/repos') do
|
get('/repos') do
|
||||||
{ :stats => service(:stats).daily_repository_counts }
|
{ :stats => service(:daily_repos) }
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add documentation.
|
|
||||||
get('/tests') do
|
get('/tests') do
|
||||||
{ :stats => service(:stats).daily_tests_counts }
|
{ :stats => service(:daily_tests) }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -23,21 +23,14 @@ class Travis::Api::App
|
||||||
end
|
end
|
||||||
|
|
||||||
put '/:id?', scope: :private do
|
put '/:id?', scope: :private do
|
||||||
service(:user).update_locale(locale)
|
update(params[:user]).run
|
||||||
204
|
204
|
||||||
end
|
end
|
||||||
|
|
||||||
# TODO: Add implementation and documentation.
|
|
||||||
post '/sync', scope: :private do
|
post '/sync', scope: :private do
|
||||||
service(:user).sync
|
service(:sync).run
|
||||||
204
|
204
|
||||||
end
|
end
|
||||||
|
|
||||||
private
|
|
||||||
|
|
||||||
def locale
|
|
||||||
params[:user][:locale]
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -2,11 +2,9 @@ require 'travis/api/app'
|
||||||
|
|
||||||
class Travis::Api::App
|
class Travis::Api::App
|
||||||
class Endpoint
|
class Endpoint
|
||||||
# TODO: Add documentation.
|
|
||||||
class Workers < Endpoint
|
class Workers < Endpoint
|
||||||
# TODO: Add implementation and documentation.
|
|
||||||
get('/') do
|
get('/') do
|
||||||
body service(:workers).find_all(params)
|
body all(params).run
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue
Block a user