debian-mirror-gitlab/lib/api/applications.rb

67 lines
2.2 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2018-03-17 18:26:18 +05:30
module API
# External applications API
2021-01-03 14:25:43 +05:30
class Applications < ::API::Base
2018-03-17 18:26:18 +05:30
before { authenticated_as_admin! }
2023-05-27 22:25:52 +05:30
feature_category :system_access
2021-01-29 00:20:46 +05:30
2018-03-17 18:26:18 +05:30
resource :applications do
desc 'Create a new application' do
detail 'This feature was introduced in GitLab 10.5'
2023-01-13 00:05:48 +05:30
success code: 200, model: Entities::ApplicationWithSecret
2018-03-17 18:26:18 +05:30
end
params do
2023-01-13 00:05:48 +05:30
requires :name, type: String, desc: 'Name of the application.', documentation: { example: 'MyApplication' }
requires :redirect_uri, type: String, desc: 'Redirect URI of the application.', documentation: { example: 'https://redirect.uri' }
requires :scopes, type: String,
desc: 'Scopes of the application. You can specify multiple scopes by separating\
each scope using a space',
allow_blank: false
2020-03-13 15:44:24 +05:30
2022-08-27 11:52:29 +05:30
optional :confidential,
type: Boolean,
default: true,
2023-01-13 00:05:48 +05:30
desc: 'The application is used where the client secret can be kept confidential. Native mobile apps \
and Single Page Apps are considered non-confidential. Defaults to true if not supplied'
2018-03-17 18:26:18 +05:30
end
post do
application = Doorkeeper::Application.new(declared_params)
if application.save
present application, with: Entities::ApplicationWithSecret
else
render_validation_error! application
end
end
2018-12-13 13:39:08 +05:30
desc 'Get applications' do
2023-01-13 00:05:48 +05:30
detail 'List all registered applications'
2018-12-13 13:39:08 +05:30
success Entities::Application
2023-01-13 00:05:48 +05:30
is_array true
2018-12-13 13:39:08 +05:30
end
get do
applications = ApplicationsFinder.new.execute
present applications, with: Entities::Application
end
2023-01-13 00:05:48 +05:30
desc 'Delete an application' do
detail 'Delete a specific application'
success code: 204
end
2022-11-25 23:54:43 +05:30
params do
requires :id, type: Integer, desc: 'The ID of the application (not the application_id)'
end
2018-12-13 13:39:08 +05:30
delete ':id' do
application = ApplicationsFinder.new(params).execute
2021-04-29 21:17:54 +05:30
break not_found!('Application') unless application
2018-12-13 13:39:08 +05:30
application.destroy
2020-03-13 15:44:24 +05:30
no_content!
2018-12-13 13:39:08 +05:30
end
2018-03-17 18:26:18 +05:30
end
end
end