PageRenderTime 25ms CodeModel.GetById 14ms app.highlight 8ms RepoModel.GetById 1ms app.codeStats 0ms

/lib/api/deployments.rb

https://gitlab.com/vicvega/gitlab-ce
Ruby | 40 lines | 34 code | 5 blank | 1 comment | 0 complexity | 3614bfd1cf1148b2f34affd07f0f820b MD5 | raw file
 1module API
 2  # Deployments RESTfull API endpoints
 3  class Deployments < Grape::API
 4    before { authenticate! }
 5
 6    params do
 7      requires :id, type: String, desc: 'The project ID'
 8    end
 9    resource :projects do
10      desc 'Get all deployments of the project' do
11        detail 'This feature was introduced in GitLab 8.11.'
12        success Entities::Deployment
13      end
14      params do
15        optional :page,     type: Integer, desc: 'Page number of the current request'
16        optional :per_page, type: Integer, desc: 'Number of items per page'
17      end
18      get ':id/deployments' do
19        authorize! :read_deployment, user_project
20
21        present paginate(user_project.deployments), with: Entities::Deployment
22      end
23
24      desc 'Gets a specific deployment' do
25        detail 'This feature was introduced in GitLab 8.11.'
26        success Entities::Deployment
27      end
28      params do
29        requires :deployment_id, type: Integer,  desc: 'The deployment ID'
30      end
31      get ':id/deployments/:deployment_id' do
32        authorize! :read_deployment, user_project
33
34        deployment = user_project.deployments.find(params[:deployment_id])
35
36        present deployment, with: Entities::Deployment
37      end
38    end
39  end
40end