2018-12-05 23:21:45 +05:30
# frozen_string_literal: true
2016-09-13 17:45:13 +05:30
module API
2017-08-17 22:00:37 +05:30
# Deployments RESTful API endpoints
2016-09-13 17:45:13 +05:30
class Deployments < Grape :: API
2017-08-17 22:00:37 +05:30
include PaginationParams
2016-09-13 17:45:13 +05:30
before { authenticate! }
params do
requires :id , type : String , desc : 'The project ID'
end
2019-02-13 22:33:31 +05:30
resource :projects , requirements : API :: NAMESPACE_OR_PROJECT_REQUIREMENTS do
2016-09-13 17:45:13 +05:30
desc 'Get all deployments of the project' do
detail 'This feature was introduced in GitLab 8.11.'
success Entities :: Deployment
end
params do
2017-08-17 22:00:37 +05:30
use :pagination
2018-03-17 18:26:18 +05:30
optional :order_by , type : String , values : %w[ id iid created_at ref ] , default : 'id' , desc : 'Return deployments ordered by `id` or `iid` or `created_at` or `ref`'
optional :sort , type : String , values : %w[ asc desc ] , default : 'asc' , desc : 'Sort by asc (ascending) or desc (descending)'
2016-09-13 17:45:13 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: disable CodeReuse/ActiveRecord
2016-09-13 17:45:13 +05:30
get ':id/deployments' do
authorize! :read_deployment , user_project
2018-03-17 18:26:18 +05:30
present paginate ( user_project . deployments . order ( params [ :order_by ] = > params [ :sort ] ) ) , with : Entities :: Deployment
2016-09-13 17:45:13 +05:30
end
2018-12-05 23:21:45 +05:30
# rubocop: enable CodeReuse/ActiveRecord
2016-09-13 17:45:13 +05:30
desc 'Gets a specific deployment' do
detail 'This feature was introduced in GitLab 8.11.'
success Entities :: Deployment
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 : Entities :: Deployment
end
end
end
end