diff options
Diffstat (limited to 'lib/api/environments.rb')
-rw-r--r-- | lib/api/environments.rb | 17 |
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 |