summaryrefslogtreecommitdiff
path: root/lib/api/remote_mirrors.rb
blob: 8a085517ce90342a348d66beb88db5828324d446 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
# frozen_string_literal: true

module API
  class RemoteMirrors < Grape::API
    include PaginationParams

    before do
      # TODO: Remove flag: https://gitlab.com/gitlab-org/gitlab/issues/38121
      not_found! unless Feature.enabled?(:remote_mirrors_api, user_project)
    end

    params do
      requires :id, type: String, desc: 'The ID of a project'
    end
    resource :projects, requirements: API::NAMESPACE_OR_PROJECT_REQUIREMENTS do
      desc "List the project's remote mirrors" do
        success Entities::RemoteMirror
      end
      params do
        use :pagination
      end
      get ':id/remote_mirrors' do
        unauthorized! unless can?(current_user, :admin_remote_mirror, user_project)

        present paginate(user_project.remote_mirrors),
          with: Entities::RemoteMirror
      end
    end
  end
end