gitlab-org--gitlab-foss/lib/api/v3/deployments.rb

44 lines
1.2 KiB
Ruby
Raw Normal View History

2017-02-23 06:41:07 -05:00
module API
module V3
# Deployments RESTful API endpoints
class Deployments < Grape::API
include PaginationParams
2017-02-23 06:41:07 -05:00
before { authenticate! }
2017-02-23 06:41:07 -05:00
params do
requires :id, type: String, desc: 'The project ID'
2017-02-23 06:41:07 -05:00
end
resource :projects, requirements: { id: %r{[^/]+} } 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
2017-02-23 06:41:07 -05:00
present paginate(user_project.deployments), with: ::API::V3::Deployments
end
2017-02-23 06:41:07 -05:00
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
2017-02-23 06:41:07 -05:00
deployment = user_project.deployments.find(params[:deployment_id])
2017-02-23 06:41:07 -05:00
present deployment, with: ::API::V3::Deployments
end
2017-02-23 06:41:07 -05:00
end
end
end
end