2018-12-05 23:21:45 +05:30
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
module API
|
2021-01-03 14:25:43 +05:30
|
|
|
class ProjectMilestones < ::API::Base
|
2017-09-10 17:25:29 +05:30
|
|
|
include PaginationParams
|
|
|
|
include MilestoneResponses
|
|
|
|
|
2020-07-28 23:09:34 +05:30
|
|
|
before { authenticate! }
|
2017-09-10 17:25:29 +05:30
|
|
|
|
2021-12-11 22:18:48 +05:30
|
|
|
feature_category :team_planning
|
2022-07-16 23:28:13 +05:30
|
|
|
urgency :low
|
2021-01-29 00:20:46 +05:30
|
|
|
|
2017-09-10 17:25:29 +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
|
2017-09-10 17:25:29 +05:30
|
|
|
desc 'Get a list of project milestones' do
|
|
|
|
success Entities::Milestone
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :list_params
|
|
|
|
end
|
|
|
|
get ":id/milestones" do
|
|
|
|
authorize! :read_milestone, user_project
|
|
|
|
|
|
|
|
list_milestones_for(user_project)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get a single project milestone' do
|
|
|
|
success Entities::Milestone
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :milestone_id, type: Integer, desc: 'The ID of a project milestone'
|
|
|
|
end
|
|
|
|
get ":id/milestones/:milestone_id" do
|
|
|
|
authorize! :read_milestone, user_project
|
|
|
|
|
|
|
|
get_milestone_for(user_project)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Create a new project milestone' do
|
|
|
|
success Entities::Milestone
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :title, type: String, desc: 'The title of the milestone'
|
|
|
|
use :optional_params
|
|
|
|
end
|
|
|
|
post ":id/milestones" do
|
|
|
|
authorize! :admin_milestone, user_project
|
|
|
|
|
|
|
|
create_milestone_for(user_project)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Update an existing project milestone' do
|
|
|
|
success Entities::Milestone
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
use :update_params
|
|
|
|
end
|
|
|
|
put ":id/milestones/:milestone_id" do
|
|
|
|
authorize! :admin_milestone, user_project
|
|
|
|
|
|
|
|
update_milestone_for(user_project)
|
|
|
|
end
|
|
|
|
|
2018-03-17 18:26:18 +05:30
|
|
|
desc 'Remove a project milestone'
|
|
|
|
delete ":id/milestones/:milestone_id" do
|
|
|
|
authorize! :admin_milestone, user_project
|
|
|
|
|
2018-11-20 20:47:30 +05:30
|
|
|
milestone = user_project.milestones.find(params[:milestone_id])
|
|
|
|
Milestones::DestroyService.new(user_project, current_user).execute(milestone)
|
2018-03-17 18:26:18 +05:30
|
|
|
|
2020-03-13 15:44:24 +05:30
|
|
|
no_content!
|
2018-03-17 18:26:18 +05:30
|
|
|
end
|
|
|
|
|
2017-09-10 17:25:29 +05:30
|
|
|
desc 'Get all issues for a single project milestone' do
|
|
|
|
success Entities::IssueBasic
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :milestone_id, type: Integer, desc: 'The ID of a project milestone'
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get ":id/milestones/:milestone_id/issues" do
|
|
|
|
authorize! :read_milestone, user_project
|
|
|
|
|
|
|
|
milestone_issuables_for(user_project, :issue)
|
|
|
|
end
|
|
|
|
|
|
|
|
desc 'Get all merge requests for a single project milestone' do
|
|
|
|
detail 'This feature was introduced in GitLab 9.'
|
|
|
|
success Entities::MergeRequestBasic
|
|
|
|
end
|
|
|
|
params do
|
|
|
|
requires :milestone_id, type: Integer, desc: 'The ID of a project milestone'
|
|
|
|
use :pagination
|
|
|
|
end
|
|
|
|
get ':id/milestones/:milestone_id/merge_requests' do
|
|
|
|
authorize! :read_milestone, user_project
|
|
|
|
|
|
|
|
milestone_issuables_for(user_project, :merge_request)
|
|
|
|
end
|
2019-07-07 11:18:12 +05:30
|
|
|
|
|
|
|
desc 'Promote a milestone to group milestone' do
|
|
|
|
detail 'This feature was introduced in GitLab 11.9'
|
|
|
|
end
|
|
|
|
post ':id/milestones/:milestone_id/promote' do
|
|
|
|
authorize! :admin_milestone, user_project
|
|
|
|
authorize! :admin_milestone, user_project.group
|
|
|
|
|
|
|
|
milestone = user_project.milestones.find(params[:milestone_id])
|
|
|
|
Milestones::PromoteService.new(user_project, current_user).execute(milestone)
|
|
|
|
|
|
|
|
status(200)
|
|
|
|
rescue Milestones::PromoteService::PromoteMilestoneError => error
|
|
|
|
render_api_error!(error.message, 400)
|
|
|
|
end
|
2017-09-10 17:25:29 +05:30
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2019-12-04 20:38:33 +05:30
|
|
|
|
2021-06-08 01:23:25 +05:30
|
|
|
API::ProjectMilestones.prepend_mod_with('API::ProjectMilestones')
|