summaryrefslogtreecommitdiff
path: root/lib/api/v3/pipelines.rb
diff options
context:
space:
mode:
authorToon Claes <toon@gitlab.com>2017-01-30 12:11:58 +0100
committerToon Claes <toon@gitlab.com>2017-03-03 09:52:04 +0100
commit59e7d04bc78a69137b649dc8ac470a6c3eedbd3c (patch)
tree77898668f22ecbf7f5a9ae8979e958d1f4427a60 /lib/api/v3/pipelines.rb
parentb18646040c9b17c69ac66fb687b02450e161808c (diff)
downloadgitlab-ce-59e7d04bc78a69137b649dc8ac470a6c3eedbd3c.tar.gz
Expose pipelines as PipelineBasic `projects/:id/pipelines`26847-api-pipelines-use-basic
The `projects/:id/pipelines` exposed a lot of extra details that are superfluous and it was taking extra resources to fetch them. To get more details about a pipeline, use `projects/:id/pipelines/:pipeline_id`.
Diffstat (limited to 'lib/api/v3/pipelines.rb')
-rw-r--r--lib/api/v3/pipelines.rb36
1 files changed, 36 insertions, 0 deletions
diff --git a/lib/api/v3/pipelines.rb b/lib/api/v3/pipelines.rb
new file mode 100644
index 00000000000..2c26a5f7d35
--- /dev/null
+++ b/lib/api/v3/pipelines.rb
@@ -0,0 +1,36 @@
+module API
+ module V3
+ class Pipelines < Grape::API
+ include PaginationParams
+
+ before { authenticate! }
+
+ params do
+ requires :id, type: String, desc: 'The project ID'
+ end
+ resource :projects do
+ desc 'Get all Pipelines of the project' do
+ detail 'This feature was introduced in GitLab 8.11.'
+ success ::API::Entities::Pipeline
+ end
+ params do
+ use :pagination
+ optional :scope, type: String, values: %w(running branches tags),
+ desc: 'Either running, branches, or tags'
+ end
+ get ':id/pipelines' do
+ authorize! :read_pipeline, user_project
+
+ pipelines = PipelinesFinder.new(user_project).execute(scope: params[:scope])
+ present paginate(pipelines), with: ::API::Entities::Pipeline
+ end
+ end
+
+ helpers do
+ def pipeline
+ @pipeline ||= user_project.pipelines.find(params[:pipeline_id])
+ end
+ end
+ end
+ end
+end