summaryrefslogtreecommitdiff
path: root/lib/api/group_milestones.rb
blob: 93fa0b958574fdfebcef64beeccc47dbab6d0db4 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
module API
  class GroupMilestones < Grape::API
    include MilestoneResponses
    include PaginationParams

    before do
      authenticate!
    end

    params do
      requires :id, type: String, desc: 'The ID of a group'
    end
    resource :groups, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do
      desc 'Get a list of group milestones' do
        success Entities::Milestone
      end
      params do
        use :list_params
      end
      get ":id/milestones" do
        list_milestones_for(user_group)
      end

      desc 'Get a single group milestone' do
        success Entities::Milestone
      end
      params do
        requires :milestone_id, type: Integer, desc: 'The ID of a group milestone'
      end
      get ":id/milestones/:milestone_id" do
        authorize! :read_group, user_group

        get_milestone_for(user_group)
      end

      desc 'Create a new group 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_milestones, user_group

        create_milestone_for(user_group)
      end

      desc 'Update an existing group milestone' do
        success Entities::Milestone
      end
      params do
        use :update_params
      end
      put ":id/milestones/:milestone_id" do
        authorize! :admin_milestones, user_group

        update_milestone_for(user_group)
      end

      desc 'Get all issues for a single group milestone' do
        success Entities::IssueBasic
      end
      params do
        requires :milestone_id, type: Integer, desc: 'The ID of a group milestone'
        use :pagination
      end
      get ":id/milestones/:milestone_id/issues" do
        milestone_issuables_for(user_group, :issue)
      end

      desc 'Get all merge requests for a single group 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 group milestone'
        use :pagination
      end
      get ':id/milestones/:milestone_id/merge_requests' do
        milestone_issuables_for(user_group, :merge_request)
      end
    end
  end
end