group.rb 4.74 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
# frozen_string_literal: true

constraints(::Constraints::GroupUrlConstrainer.new) do
  scope(path: 'groups/*id',
        controller: :groups,
        constraints: { id: Gitlab::PathRegex.full_namespace_route_regex, format: /(html|json|atom|ics)/ }) do
    scope(path: '-') do
      get :subgroups, as: :subgroups_group
    end
  end

  scope(path: 'groups/*group_id/-',
        module: :groups,
        as: :group,
        constraints: { group_id: Gitlab::PathRegex.full_namespace_route_regex }) do
    resources :group_members, only: [], concerns: :access_requestable do
      patch :override, on: :member
    end

    resource :analytics, only: [:show]
Gosia Ksionek's avatar
Gosia Ksionek committed
21 22 23 24 25 26 27 28 29 30 31 32 33
    resource :cycle_analytics, only: [:show]
    namespace :cycle_analytics do
      scope :events, controller: 'events' do
        get :issue
        get :plan
        get :code
        get :test
        get :review
        get :staging
        get :production
      end
    end

34 35 36 37 38 39
    resource :ldap, only: [] do
      member do
        put :sync
      end
    end

40 41
    resource :issues_analytics, only: [:show]

42
    resource :insights, only: [:show], trailing_slash: true do
43 44 45 46 47
      collection do
        post :query
      end
    end

48 49 50 51
    resource :notification_setting, only: [:update]

    resources :ldap_group_links, only: [:index, :create, :destroy]
    resources :audit_events, only: [:index]
52
    resources :usage_quotas, only: [:index]
53

54
    resources :hooks, only: [:index, :create, :edit, :update, :destroy], constraints: { id: /\d+/ } do
55 56 57 58 59 60 61 62
      member do
        post :test
      end
    end

    resources :autocomplete_sources, only: [] do
      collection do
        get 'members'
63 64
        get 'issues'
        get 'merge_requests'
65 66 67
        get 'labels'
        get 'epics'
        get 'commands'
68
        get 'milestones'
69 70 71 72 73 74
      end
    end

    resources :billings, only: [:index]
    resources :epics, concerns: :awardable, constraints: { id: /\d+/ } do
      member do
75
        get '/descriptions/:version_id/diff', action: :description_diff, as: :description_diff
76 77 78 79 80 81
        get :discussions, format: :json
        get :realtime_changes
        post :toggle_subscription
      end

      resources :epic_issues, only: [:index, :create, :destroy, :update], as: 'issues', path: 'issues'
Jarka Košanová's avatar
Jarka Košanová committed
82
      resources :epic_links, only: [:index, :create, :destroy, :update], as: 'links', path: 'links'
83 84 85 86

      scope module: :epics do
        resources :notes, only: [:index, :create, :destroy, :update], concerns: :awardable, constraints: { id: /\d+/ }
      end
87 88 89 90

      collection do
        post :bulk_update
      end
91 92
    end

93
    resources :issues, only: [] do
Eugenia Grieff's avatar
Eugenia Grieff committed
94 95 96 97 98 99
      collection do
        post :bulk_update
      end
    end

    resources :merge_requests, only: [] do
100 101 102 103 104
      collection do
        post :bulk_update
      end
    end

105
    resources :todos, only: [:create]
106 107 108 109 110
    resources :boards, only: [:create, :update, :destroy] do
      collection do
        get :recent
      end
    end
111 112 113

    namespace :security do
      resource :dashboard, only: [:show], controller: :dashboard
114
      resources :vulnerable_projects, only: [:index]
115 116 117 118 119 120 121 122 123 124 125 126
      # We have to define both legacy and new routes for Vulnerability Findings
      # because they are loaded upon application initialization and preloaded by
      # web server.
      # TODO: remove this comment and `resources :vulnerabilities` when feature flag is removed
      # see https://gitlab.com/gitlab-org/gitlab/issues/33488
      resources :vulnerabilities, only: [:index] do
        collection do
          get :summary
          get :history
        end
      end
      resources :vulnerability_findings, only: [:index] do
127 128
        collection do
          get :summary
129
          get :history
130 131 132 133 134
        end
      end
    end

    resource :saml_providers, path: 'saml', only: [:show, :create, :update] do
135 136
      callback_methods = Rails.env.test? ? [:get, :post] : [:post]
      match :callback, to: 'omniauth_callbacks#group_saml', via: callback_methods
137
      get :sso, to: 'sso#saml'
138
      delete :unlink, to: 'sso#unlink'
139 140
    end

James Lopez's avatar
James Lopez committed
141 142
    resource :scim_oauth, only: [:show, :create], controller: :scim_oauth

143 144 145
    get :sign_up, to: 'sso#sign_up_form'
    post :sign_up, to: 'sso#sign_up'

146 147
    resource :roadmap, only: [:show], controller: 'roadmap'

148
    resource :dependency_proxy, only: [:show, :update]
149
    resources :packages, only: [:index]
150 151
  end
end
152 153 154

# Dependency proxy for containers
# Because docker adds v2 prefix to URI this need to be outside of usual group routes
155
scope format: false do
156
  get 'v2', to: proc { [200, {}, ['']] }
157 158 159 160 161

  constraints image: Gitlab::PathRegex.container_image_regex do
    get 'v2/*group_id/dependency_proxy/containers/*image/manifests/*tag' => 'groups/dependency_proxy_for_containers#manifest'
    get 'v2/*group_id/dependency_proxy/containers/*image/blobs/:sha' => 'groups/dependency_proxy_for_containers#blob'
  end
162
end