diff options
author | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-08-16 08:45:23 +0200 |
---|---|---|
committer | Z.J. van de Weg <zegerjan@gitlab.com> | 2016-08-18 21:10:52 +0200 |
commit | 47d6f286eb565ae582def5a28af2cb450b2ee479 (patch) | |
tree | bff99a661fb7420ac4cc51fb2ee2c38361cf7fe3 /lib | |
parent | fffe5c2b577b39be2254525d4320cf396b7ff58b (diff) | |
download | gitlab-ce-47d6f286eb565ae582def5a28af2cb450b2ee479.tar.gz |
Add deployment endpoints
Diffstat (limited to 'lib')
-rw-r--r-- | lib/api/api.rb | 1 | ||||
-rw-r--r-- | lib/api/deployments.rb | 40 | ||||
-rw-r--r-- | lib/api/entities.rb | 12 |
3 files changed, 53 insertions, 0 deletions
diff --git a/lib/api/api.rb b/lib/api/api.rb index d9261c97908..6b8bfbbdae6 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -43,6 +43,7 @@ module API mount ::API::CommitStatuses mount ::API::Commits mount ::API::DeployKeys + mount ::API::Deployments mount ::API::Environments mount ::API::Files mount ::API::Groups diff --git a/lib/api/deployments.rb b/lib/api/deployments.rb new file mode 100644 index 00000000000..f782bcaf7e9 --- /dev/null +++ b/lib/api/deployments.rb @@ -0,0 +1,40 @@ +module API + # Deployments RESTfull API endpoints + class Deployments < Grape::API + before { authenticate! } + + params do + requires :id, type: String, desc: 'The project ID' + end + resource :projects do + desc 'Get all deployments of the project' do + detail 'This feature was introduced in GitLab 8.11.' + success Entities::Deployment + end + params do + optional :page, type: Integer, desc: 'Page number of the current request' + optional :per_page, type: Integer, desc: 'Number of items per page' + end + get ':id/deployments' do + authorize! :read_deployment, user_project + + present paginate(user_project.deployments), with: Entities::Deployment + end + + 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 diff --git a/lib/api/entities.rb b/lib/api/entities.rb index b575af53850..9ae68947379 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -514,6 +514,18 @@ module API expose :id, :name, :external_url end + class EnvironmentBasic < Grape::Entity + expose :id, :name, :external_url + end + + class Deployment < Grape::Entity + expose :id, :iid, :ref, :sha, :created_at + expose :project, using: Entities::Project + expose :user, using: Entities::UserBasic + expose :environment, using: Entities::EnvironmentBasic + expose :deployable, using: Entities::Build + end + class RepoLicense < Grape::Entity expose :key, :name, :nickname expose :featured, as: :popular |