summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-02-28 14:55:21 +0100
committerToon Claes <toon@gitlab.com>2017-02-28 15:34:38 +0100
commit8c569e21d5224128e28fcc2392dc4777f9b839c2 (patch)
treef54d755279e81d49a4db6828aa1dfaaa054de1a1 /lib
parent54f6357ba3d7f31bdb0009a041e48c3a6be8e2ff (diff)
downloadgitlab-ce-8c569e21d5224128e28fcc2392dc4777f9b839c2.tar.gz
Add endpoint to stop an environment through the API.
Diffstat (limited to 'lib')
-rw-r--r--lib/api/environments.rb17
1 files changed, 17 insertions, 0 deletions
diff --git a/lib/api/environments.rb b/lib/api/environments.rb
index dbdf29a9640..ebe8c3a5b2c 100644
--- a/lib/api/environments.rb
+++ b/lib/api/environments.rb
@@ -81,6 +81,23 @@ module API
environment.destroy
end
+
+ desc 'Stops an existing environment' do
+ success Entities::Environment
+ end
+ params do
+ requires :environment_id, type: Integer, desc: 'The environment ID'
+ end
+ post ':id/environments/:environment_id/stop' do
+ authorize! :create_deployment, user_project
+
+ environment = user_project.environments.find(params[:environment_id])
+
+ environment.stop_with_action!(current_user)
+
+ status 200
+ present environment, with: Entities::Environment
+ end
end
end
end