diff options
author | Krasimir Angelov <kangelov@gitlab.com> | 2019-04-09 09:16:57 +0000 |
---|---|---|
committer | Kamil TrzciĆski <ayufan@ayufan.eu> | 2019-04-09 09:16:57 +0000 |
commit | 724f19ba0a051bbe8e9dd89f208261abe0f8133a (patch) | |
tree | 111955bd4ca355100c3d97758b42e942ea4c1779 /lib/api/environments.rb | |
parent | e70fae8d8db6a4c4a8d5498bcac039424eb941c1 (diff) | |
download | gitlab-ce-724f19ba0a051bbe8e9dd89f208261abe0f8133a.tar.gz |
Add new API endpoint to expose single environment
This is resolving https://gitlab.com/gitlab-org/gitlab-ce/issues/30157.
Implement new API endpoint `/projects/:id/environments/:environment_id`
to expose single environment. Include information for environment's last
deployment if there is one.
Diffstat (limited to 'lib/api/environments.rb')
-rw-r--r-- | lib/api/environments.rb | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/lib/api/environments.rb b/lib/api/environments.rb index 5b0f3b914cb..6cd43923559 100644 --- a/lib/api/environments.rb +++ b/lib/api/environments.rb @@ -101,6 +101,21 @@ module API status 200 present environment, with: Entities::Environment, current_user: current_user end + + desc 'Get a single environment' do + success Entities::Environment + end + params do + requires :environment_id, type: Integer, desc: 'The environment ID' + end + get ':id/environments/:environment_id' do + authorize! :read_environment, user_project + + environment = user_project.environments.find(params[:environment_id]) + present environment, with: Entities::Environment, current_user: current_user, + except: [:project, { last_deployment: [:environment] }], + last_deployment: true + end end end end |