2017-01-04 17:07:49 -05:00
|
|
|
module API
|
|
|
|
# External applications API
|
|
|
|
class Applications < Grape::API
|
|
|
|
before { authenticated_as_admin! }
|
|
|
|
|
|
|
|
resource :applications do
|
|
|
|
desc 'Create a new application' do
|
2018-01-23 04:50:10 -05:00
|
|
|
detail 'This feature was introduced in GitLab 10.5'
|
2018-01-24 03:44:07 -05:00
|
|
|
success Entities::ApplicationWithSecret
|
2017-01-04 17:07:49 -05:00
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :name, type: String, desc: 'Application name'
|
|
|
|
requires :redirect_uri, type: String, desc: 'Application redirect URI'
|
|
|
|
requires :scopes, type: String, desc: 'Application scopes'
|
|
|
|
end
|
|
|
|
post do
|
|
|
|
application = Doorkeeper::Application.new(declared_params)
|
|
|
|
|
|
|
|
if application.save
|
2018-01-24 03:44:07 -05:00
|
|
|
present application, with: Entities::ApplicationWithSecret
|
2017-01-04 17:07:49 -05:00
|
|
|
else
|
|
|
|
render_validation_error! application
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|