summaryrefslogtreecommitdiff
path: root/lib/api/v3/deployments.rb
blob: 95114ad1fe1f254e96ad4a84ada05a1cc049bbe0 (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
module API
  module V3
    # Deployments RESTful API endpoints
    class Deployments < Grape::API
      include PaginationParams

      before { authenticate! }

      params do
        requires :id, type: String, desc: 'The project ID'
      end
      resource :projects do
        desc 'Get all deployments of the project' do
          detail 'This feature was introduced in GitLab 8.11.'
          success ::API::V3::Deployments
        end
        params do
          use :pagination
        end
        get ':id/deployments' do
          authorize! :read_deployment, user_project

          present paginate(user_project.deployments), with: ::API::V3::Deployments
        end

        desc 'Gets a specific deployment' do
          detail 'This feature was introduced in GitLab 8.11.'
          success ::API::V3::Deployments
        end
        params do
          requires :deployment_id, type: Integer,  desc: 'The deployment ID'
        end
        get ':id/deployments/:deployment_id' do
          authorize! :read_deployment, user_project

          deployment = user_project.deployments.find(params[:deployment_id])

          present deployment, with: ::API::V3::Deployments
        end
      end
    end
  end
end