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

158 lines
4.3 KiB
Ruby
Raw Normal View History

2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-11-03 12:29:30 +05:30
module API
2021-01-03 14:25:43 +05:30
class Boards < ::API::Base
2018-03-17 18:26:18 +05:30
include BoardsResponses
2017-08-17 22:00:37 +05:30
include PaginationParams
2021-06-08 01:23:25 +05:30
prepend_mod_with('API::BoardsResponses') # rubocop: disable Cop/InjectEnterpriseEditionModule
2019-12-04 20:38:33 +05:30
2021-01-29 00:20:46 +05:30
feature_category :boards
2021-03-08 18:12:59 +05:30
before { authenticate! }
2018-03-17 18:26:18 +05:30
helpers do
def board_parent
user_project
end
end
2016-11-03 12:29:30 +05:30
params do
requires :id, type: String, desc: 'The ID of a project'
end
2019-02-15 15:39:39 +05:30
resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
2018-03-17 18:26:18 +05:30
segment ':id/boards' do
desc 'Get all project boards' do
detail 'This feature was introduced in 8.13'
success Entities::Board
end
params do
use :pagination
end
get '/' do
2021-04-17 20:07:23 +05:30
authorize!(:read_issue_board, user_project)
2019-09-30 21:07:59 +05:30
present paginate(board_parent.boards.with_associations), with: Entities::Board
2018-03-17 18:26:18 +05:30
end
desc 'Find a project board' do
detail 'This feature was introduced in 10.4'
success Entities::Board
end
get '/:board_id' do
2021-04-17 20:07:23 +05:30
authorize!(:read_issue_board, user_project)
2018-03-17 18:26:18 +05:30
present board, with: Entities::Board
end
2021-01-29 00:20:46 +05:30
desc 'Create a project board' do
detail 'This feature was introduced in 10.4'
success Entities::Board
end
params do
requires :name, type: String, desc: 'The board name'
end
post '/' do
2021-04-17 20:07:23 +05:30
authorize!(:admin_issue_board, board_parent)
2021-01-29 00:20:46 +05:30
create_board
end
desc 'Update a project board' do
detail 'This feature was introduced in 11.0'
success Entities::Board
end
params do
use :update_params
end
put '/:board_id' do
2021-04-17 20:07:23 +05:30
authorize!(:admin_issue_board, board_parent)
2021-01-29 00:20:46 +05:30
update_board
end
desc 'Delete a project board' do
detail 'This feature was introduced in 10.4'
success Entities::Board
end
delete '/:board_id' do
2021-04-17 20:07:23 +05:30
authorize!(:admin_issue_board, board_parent)
2021-01-29 00:20:46 +05:30
delete_board
end
2016-11-03 12:29:30 +05:30
end
params do
requires :board_id, type: Integer, desc: 'The ID of a board'
end
segment ':id/boards/:board_id' do
desc 'Get the lists of a project board' do
2017-08-17 22:00:37 +05:30
detail 'Does not include `done` list. This feature was introduced in 8.13'
2016-11-03 12:29:30 +05:30
success Entities::List
end
2017-08-17 22:00:37 +05:30
params do
use :pagination
end
2016-11-03 12:29:30 +05:30
get '/lists' do
2021-04-17 20:07:23 +05:30
authorize!(:read_issue_board, user_project)
2017-08-17 22:00:37 +05:30
present paginate(board_lists), with: Entities::List
2016-11-03 12:29:30 +05:30
end
desc 'Get a list of a project board' do
detail 'This feature was introduced in 8.13'
success Entities::List
end
params do
requires :list_id, type: Integer, desc: 'The ID of a list'
end
get '/lists/:list_id' do
2021-04-17 20:07:23 +05:30
authorize!(:read_issue_board, user_project)
2016-11-03 12:29:30 +05:30
present board_lists.find(params[:list_id]), with: Entities::List
end
desc 'Create a new board list' do
detail 'This feature was introduced in 8.13'
success Entities::List
end
params do
2018-11-18 11:00:15 +05:30
use :list_creation_params
2016-11-03 12:29:30 +05:30
end
post '/lists' do
2021-04-17 20:07:23 +05:30
authorize!(:admin_issue_board_list, user_project)
2016-11-03 12:29:30 +05:30
2018-03-17 18:26:18 +05:30
create_list
2016-11-03 12:29:30 +05:30
end
desc 'Moves a board list to a new position' do
detail 'This feature was introduced in 8.13'
success Entities::List
end
params do
requires :list_id, type: Integer, desc: 'The ID of a list'
requires :position, type: Integer, desc: 'The position of the list'
end
put '/lists/:list_id' do
2018-03-17 18:26:18 +05:30
list = board_lists.find(params[:list_id])
2016-11-03 12:29:30 +05:30
2021-04-17 20:07:23 +05:30
authorize!(:admin_issue_board_list, user_project)
2016-11-03 12:29:30 +05:30
2018-03-17 18:26:18 +05:30
move_list(list)
2016-11-03 12:29:30 +05:30
end
desc 'Delete a board list' do
detail 'This feature was introduced in 8.13'
success Entities::List
end
params do
requires :list_id, type: Integer, desc: 'The ID of a board list'
end
delete "/lists/:list_id" do
2021-04-17 20:07:23 +05:30
authorize!(:admin_issue_board_list, user_project)
2016-11-03 12:29:30 +05:30
list = board_lists.find(params[:list_id])
2018-03-17 18:26:18 +05:30
destroy_list(list)
2016-11-03 12:29:30 +05:30
end
end
end
end
end