BigW Consortium Gitlab

merge_request_diffs.rb 1.54 KB
Newer Older
1
module API
Toon Claes committed
2 3 4 5 6
  module V3
    # MergeRequestDiff API
    class MergeRequestDiffs < Grape::API
      before { authenticate! }

7 8 9 10
      params do
        requires :id, type: String, desc: 'The ID of a project'
      end
      resource :projects, requirements: { id: %r{[^/]+} } do
Toon Claes committed
11 12 13 14 15 16 17 18 19 20 21 22
        desc 'Get a list of merge request diff versions' do
          detail 'This feature was introduced in GitLab 8.12.'
          success ::API::Entities::MergeRequestDiff
        end

        params do
          requires :merge_request_id, type: Integer, desc: 'The ID of a merge request'
        end

        get ":id/merge_requests/:merge_request_id/versions" do
          merge_request = find_merge_request_with_access(params[:merge_request_id])

23
          present merge_request.merge_request_diffs.order_id_desc, with: ::API::Entities::MergeRequestDiff
Toon Claes committed
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40
        end

        desc 'Get a single merge request diff version' do
          detail 'This feature was introduced in GitLab 8.12.'
          success ::API::Entities::MergeRequestDiffFull
        end

        params do
          requires :merge_request_id, type: Integer, desc: 'The ID of a merge request'
          requires :version_id, type: Integer, desc: 'The ID of a merge request diff version'
        end

        get ":id/merge_requests/:merge_request_id/versions/:version_id" do
          merge_request = find_merge_request_with_access(params[:merge_request_id])

          present merge_request.merge_request_diffs.find(params[:version_id]), with: ::API::Entities::MergeRequestDiffFull
        end
41 42 43 44
      end
    end
  end
end