BigW Consortium Gitlab

deployments.rb 1.23 KB
Newer Older
1
module API
2 3 4 5
  module V3
    # Deployments RESTful API endpoints
    class Deployments < Grape::API
      include PaginationParams
6

7
      before { authenticate! }
8 9

      params do
10
        requires :id, type: String, desc: 'The project ID'
11
      end
12
      resource :projects, requirements: { id: %r{[^/]+} } do
13 14 15 16 17 18 19 20 21
        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
22

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

26 27 28 29 30 31 32 33 34
        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
35

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

38 39
          present deployment, with: ::API::V3::Deployments
        end
40 41 42 43
      end
    end
  end
end