diff options
Diffstat (limited to 'lib/api/deployments.rb')
-rw-r--r-- | lib/api/deployments.rb | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/lib/api/deployments.rb b/lib/api/deployments.rb index 8db5f54b45a..ee0a026d7ac 100644 --- a/lib/api/deployments.rb +++ b/lib/api/deployments.rb @@ -119,9 +119,9 @@ module API end params do requires :status, - type: String, - desc: 'The new status of the deployment', - values: %w[running success failed canceled] + type: String, + desc: 'The new status of the deployment', + values: %w[running success failed canceled] end put ':id/deployments/:deployment_id' do authorize!(:read_deployment, user_project) @@ -143,6 +143,27 @@ module API end end + desc 'Deletes an existing deployment' do + detail 'This feature was introduced in GitLab 15.3' + http_codes [[204, 'Deployment was deleted'], [403, 'Forbidden'], [400, 'Cannot destroy']] + end + params do + requires :deployment_id, type: Integer, desc: 'The deployment ID' + end + delete ':id/deployments/:deployment_id' do + deployment = user_project.deployments.find(params[:deployment_id]) + + authorize!(:destroy_deployment, deployment) + + destroy_conditionally!(deployment) do + result = ::Ci::Deployments::DestroyService.new(user_project, current_user).execute(deployment) + + if result[:status] == :error + render_api_error!(result[:message], result[:http_status] || 400) + end + end + end + helpers Helpers::MergeRequestsHelpers desc 'Get all merge requests of a deployment' do |