diff options
author | Rémy Coutable <remy@rymai.me> | 2018-01-24 14:44:49 +0000 |
---|---|---|
committer | Rémy Coutable <remy@rymai.me> | 2018-01-24 14:44:49 +0000 |
commit | c28ffa1da3aaed0c189a1787a17ed2c944882f09 (patch) | |
tree | ee03616501908f9b974a022ed145ac1798747e65 /lib | |
parent | 09da89e634c197919b129ad0f781c3cec9b93c37 (diff) | |
parent | 45b62dfd324318959ff6fa37f9d3f8a1a95b4aa7 (diff) | |
download | gitlab-ce-c28ffa1da3aaed0c189a1787a17ed2c944882f09.tar.gz |
Merge branch 'PNSalocin/gitlab-ce-24035-api-create-application' into 'master'
Add application create API
Closes #24035
See merge request gitlab-org/gitlab-ce!16643
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/applications.rb | 27 | ||||
-rw-r--r-- | lib/api/entities.rb | 10 |
3 files changed, 38 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index ae161efb358..f3f64244589 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -106,6 +106,7 @@ module API # Keep in alphabetical order mount ::API::AccessRequests + mount ::API::Applications mount ::API::AwardEmoji mount ::API::Boards mount ::API::Branches diff --git a/lib/api/applications.rb b/lib/api/applications.rb new file mode 100644 index 00000000000..b122cdefe4e --- /dev/null +++ b/lib/api/applications.rb @@ -0,0 +1,27 @@ +module API + # External applications API + class Applications < Grape::API + before { authenticated_as_admin! } + + resource :applications do + desc 'Create a new application' do + detail 'This feature was introduced in GitLab 10.5' + success Entities::ApplicationWithSecret + 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 + present application, with: Entities::ApplicationWithSecret + else + render_validation_error! application + end + end + end + end +end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index 3f4b62dc1b2..7b9a80a234b 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -1157,5 +1157,15 @@ module API pages_domain end end + + class Application < Grape::Entity + expose :uid, as: :application_id + expose :redirect_uri, as: :callback_url + end + + # Use with care, this exposes the secret + class ApplicationWithSecret < Application + expose :secret + end end end |