routes.rb 20.7 KB
Newer Older
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
1
require 'sidekiq/web'
2
require 'sidekiq/cron/web'
3
require 'api/api'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
4

Valery Sizov's avatar
Valery Sizov committed
5
Rails.application.routes.draw do
6 7 8 9 10 11 12 13 14 15 16 17 18
  if Gitlab::Sherlock.enabled?
    namespace :sherlock do
      resources :transactions, only: [:index, :show] do
        resources :queries, only: [:show]
        resources :file_samples, only: [:show]

        collection do
          delete :destroy_all
        end
      end
    end
  end

19 20 21 22 23 24 25 26 27 28 29 30
  # Make the built-in Rails routes available in development, otherwise they'd
  # get swallowed by the `namespace/project` route matcher below.
  #
  # See https://git.io/va79N
  if Rails.env.development?
    get '/rails/mailers'         => 'rails/mailers#index'
    get '/rails/mailers/:path'   => 'rails/mailers#preview'
    get '/rails/info/properties' => 'rails/info#properties'
    get '/rails/info/routes'     => 'rails/info#routes'
    get '/rails/info'            => 'rails/info#index'
  end

31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
  namespace :ci do
    # CI API
    Ci::API::API.logger Rails.logger
    mount Ci::API::API => '/api'

    resource :lint, only: [:show, :create]

    resources :projects do
      member do
        get :status, to: 'projects#badge'
        get :integration
      end
    end

    root to: 'projects#index'
  end

Valery Sizov's avatar
Valery Sizov committed
48
  use_doorkeeper do
49 50 51
    controllers applications: 'oauth/applications',
                authorized_applications: 'oauth/authorized_applications',
                authorizations: 'oauth/authorizations'
Valery Sizov's avatar
Valery Sizov committed
52
  end
53

54 55 56 57
  # Autocomplete
  get '/autocomplete/users' => 'autocomplete#users'
  get '/autocomplete/users/:id' => 'autocomplete#user'

Annabel Dunstone's avatar
Annabel Dunstone committed
58 59
  # Emojis
  resources :emojis, only: :index
60

61
  # Search
62 63
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
Valery Sizov's avatar
Valery Sizov committed
64

65
  # API
66 67
  API::API.logger Rails.logger
  mount API::API => '/api'
68

69
  constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
70
  constraints constraint do
71
    mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
72
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
73

74
  # Enable Grack support
Marin Jankovski's avatar
Marin Jankovski committed
75
  mount Grack::AuthSpawner, at: '/', constraints: lambda { |request| /[-\/\w\.]+\.git\//.match(request.path_info) }, via: [:get, :post, :put]
76

77
  # Help
Job van der Voort's avatar
Job van der Voort committed
78
  get 'help'                  => 'help#index'
79
  get 'help/:category/:file'  => 'help#show', as: :help_page, constraints: { category: /.*/, file: /[^\/\.]+/ }
Marin Jankovski's avatar
Marin Jankovski committed
80
  get 'help/shortcuts'
81
  get 'help/ui'               => 'help#ui'
82

Andrew8xx8's avatar
Andrew8xx8 committed
83 84 85 86 87
  #
  # Global snippets
  #
  resources :snippets do
    member do
88
      get 'raw'
Andrew8xx8's avatar
Andrew8xx8 committed
89 90
    end
  end
91 92

  get '/s/:username' => 'snippets#index', as: :user_snippets, constraints: { username: /.*/ }
Andrew8xx8's avatar
Andrew8xx8 committed
93

Douwe Maan's avatar
Douwe Maan committed
94 95 96 97 98 99 100
  #
  # Invites
  #

  resources :invites, only: [:show], constraints: { id: /[A-Za-z0-9_-]+/ } do
    member do
      post :accept
Douwe Maan's avatar
Douwe Maan committed
101
      match :decline, via: [:get, :post]
Douwe Maan's avatar
Douwe Maan committed
102 103
    end
  end
104

105
  resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
106 107 108 109 110
    member do
      get :unsubscribe
    end
  end

111 112 113
  # Spam reports
  resources :abuse_reports, only: [:new, :create]

Valery Sizov's avatar
Valery Sizov committed
114
  #
115
  # Import
Valery Sizov's avatar
Valery Sizov committed
116
  #
117 118
  namespace :import do
    resource :github, only: [:create, :new], controller: :github do
119 120 121 122 123
      get :status
      get :callback
      get :jobs
    end

124
    resource :gitlab, only: [:create, :new], controller: :gitlab do
125 126 127 128
      get :status
      get :callback
      get :jobs
    end
Marcin Kulik's avatar
Marcin Kulik committed
129

Douwe Maan's avatar
Douwe Maan committed
130 131 132 133 134
    resource :bitbucket, only: [:create, :new], controller: :bitbucket do
      get :status
      get :callback
      get :jobs
    end
135

Marcin Kulik's avatar
Marcin Kulik committed
136 137 138 139 140
    resource :gitorious, only: [:create, :new], controller: :gitorious do
      get :status
      get :callback
      get :jobs
    end
141 142 143 144 145

    resource :google_code, only: [:create, :new], controller: :google_code do
      get :status
      post :callback
      get :jobs
146 147 148

      get   :new_user_map,    path: :user_map
      post  :create_user_map, path: :user_map
149
    end
Jared Szechy's avatar
Jared Szechy committed
150 151 152 153 154 155 156 157 158

    resource :fogbugz, only: [:create, :new], controller: :fogbugz do
      get :status
      post :callback
      get :jobs

      get   :new_user_map,    path: :user_map
      post  :create_user_map, path: :user_map
    end
Valery Sizov's avatar
Valery Sizov committed
159
  end
160

161 162 163
  #
  # Uploads
  #
164

165 166
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
167 168
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
169
        constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /[^\/]+/ }
170

171 172 173 174 175
    # Appearance
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
        constraints:  { model: /appearance/, mounted_as: /logo|header_logo/, filename: /.+/ }

176
    # Project markdown uploads
177
    get ":namespace_id/:project_id/:secret/:filename",
178
      to:           "projects/uploads#show",
179
      constraints:  { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: /[^\/]+/ }
180
  end
Valery Sizov's avatar
Valery Sizov committed
181

182
  # Redirect old note attachments path to new uploads path.
183 184
  get "files/note/:id/:filename",
    to:           redirect("uploads/note/attachment/%{id}/%{filename}"),
185
    constraints:  { filename: /[^\/]+/ }
186

187
  #
Yatish Mehta's avatar
Yatish Mehta committed
188
  # Explore area
189
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
190 191 192 193
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
194
        get :starred
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
195 196 197
      end
    end

198
    resources :groups, only: [:index]
199
    resources :snippets, only: [:index]
200
    root to: 'projects#trending'
201 202
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
203
  # Compatibility with old routing
204 205
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
206

207 208 209
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
210
  namespace :admin do
211
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
212
      resources :keys, only: [:show, :destroy]
213
      resources :identities, except: [:show]
214

215
      delete 'stop_impersonation' => 'impersonation#destroy', on: :collection
216

217
      member do
218 219 220
        get :projects
        get :keys
        get :groups
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
221
        put :team_update
222 223
        put :block
        put :unblock
224
        put :unlock
225
        put :confirm
226
        post 'impersonate' => 'impersonation#create'
227
        patch :disable_two_factor
228
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
229 230
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
231

232
    resources :abuse_reports, only: [:index, :destroy]
233 234
    resources :spam_logs, only: [:index, :destroy]

Valery Sizov's avatar
Valery Sizov committed
235 236
    resources :applications

237 238
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
239
        put :members_update
240
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
241
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
242

243
    resources :deploy_keys, only: [:index, :new, :create, :destroy]
244

245
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
246 247
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
248

249 250 251 252
    resources :broadcast_messages, only: [:index, :edit, :create, :update, :destroy] do
      post :preview, on: :collection
    end

253
    resource :logs, only: [:show]
254
    resource :background_jobs, controller: 'background_jobs', only: [:show]
255

Vinnie Okada's avatar
Vinnie Okada committed
256 257 258
    resources :namespaces, path: '/projects', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
      root to: 'projects#index', as: :projects

259 260
      resources(:projects,
                path: '/',
Vinnie Okada's avatar
Vinnie Okada committed
261 262 263 264 265 266 267
                constraints: { id: /[a-zA-Z.0-9_\-]+/ },
                only: [:index, :show]) do
        root to: 'projects#show'

        member do
          put :transfer
        end
268 269

        resources :runner_projects
270 271 272
      end
    end

273 274 275 276 277 278 279
    resource :appearances, path: 'appearance' do
      member do
        get :preview
        delete :logo
        delete :header_logos
      end
    end
280

281 282
    resource :application_settings, only: [:show, :update] do
      resources :services
283
      put :reset_runners_token
284
    end
285

Valery Sizov's avatar
Valery Sizov committed
286 287
    resources :labels

288 289 290 291 292 293 294 295 296 297 298 299 300
    resources :runners, only: [:index, :show, :update, :destroy] do
      member do
        get :resume
        get :pause
      end
    end

    resources :builds, only: :index do
      collection do
        post :cancel_all
      end
    end

301
    root to: 'dashboard#index'
gitlabhq's avatar
gitlabhq committed
302 303
  end

randx's avatar
randx committed
304 305 306
  #
  # Profile Area
  #
307 308
  resource :profile, only: [:show, :update] do
    member do
309
      get :audit_log
310
      get :applications, to: 'oauth/applications#index'
311 312 313 314

      put :reset_private_token
      put :update_username
    end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
315

316
    scope module: :profiles do
317 318 319 320 321
      resource :account, only: [:show, :update] do
        member do
          delete :unlink
        end
      end
322
      resource :notifications, only: [:show, :update]
323 324 325 326 327
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
328
      resource :preferences, only: [:show, :update]
329
      resources :keys, except: [:new]
330
      resources :emails, only: [:index, :create, :destroy]
331
      resource :avatar, only: [:destroy]
332 333
      resource :two_factor_auth, only: [:new, :create, :destroy] do
        member do
334
          post :codes
335
          patch :skip
336 337
        end
      end
338
    end
339
  end
340

341
  get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
342 343 344 345
      constraints: { username: /.*/ }

  get 'u/:username/calendar_activities' => 'users#calendar_activities', as: :user_calendar_activities,
      constraints: { username: /.*/ }
346

347 348 349
  get 'u/:username/groups' => 'users#groups', as: :user_groups,
      constraints: { username: /.*/ }

350
  get 'u/:username/projects' => 'users#projects', as: :user_projects,
351 352
      constraints: { username: /.*/ }

353
  get 'u/:username/contributed' => 'users#contributed', as: :user_contributed_projects,
354 355
      constraints: { username: /.*/ }

356
  get '/u/:username' => 'users#show', as: :user,
357
      constraints: { username: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
358

randx's avatar
randx committed
359 360 361
  #
  # Dashboard Area
  #
362 363 364 365
  resource :dashboard, controller: 'dashboard', only: [] do
    get :issues
    get :merge_requests
    get :activity
Douwe Maan's avatar
Douwe Maan committed
366 367 368

    scope module: :dashboard do
      resources :milestones, only: [:index, :show]
369
      resources :labels, only: [:index]
370

371
      resources :groups, only: [:index]
372
      resources :snippets, only: [:index]
373 374 375 376 377 378

      resources :todos, only: [:index, :destroy] do
        collection do
          delete :destroy_all
        end
      end
379

380
      resources :projects, only: [:index] do
381 382 383 384
        collection do
          get :starred
        end
      end
Douwe Maan's avatar
Douwe Maan committed
385
    end
386 387

    root to: "dashboard/projects#index"
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
388
  end
gitlabhq's avatar
gitlabhq committed
389

randx's avatar
randx committed
390 391 392
  #
  # Groups Area
  #
393
  resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }  do
randx's avatar
randx committed
394 395 396
    member do
      get :issues
      get :merge_requests
397
      get :projects
398
      get :activity
randx's avatar
randx committed
399
    end
400

Steven Thonus's avatar
Steven Thonus committed
401
    scope module: :groups do
402
      resources :group_members, only: [:index, :create, :update, :destroy] do
403
        post :resend_invite, on: :member
404
        delete :leave, on: :collection
405
      end
406

Steven Thonus's avatar
Steven Thonus committed
407
      resource :avatar, only: [:destroy]
408
      resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :update, :new, :create]
Steven Thonus's avatar
Steven Thonus committed
409
    end
randx's avatar
randx committed
410 411
  end

412
  resources :projects, constraints: { id: /[^\/]+/ }, only: [:index, :new, :create]
413

414
  devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
gitlabhq's avatar
gitlabhq committed
415

416
  devise_scope :user do
417
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
418
  end
Vinnie Okada's avatar
Vinnie Okada committed
419

420
  root to: "root#index"
Vinnie Okada's avatar
Vinnie Okada committed
421

422 423 424
  #
  # Project Area
  #
Vinnie Okada's avatar
Vinnie Okada committed
425
  resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
426
    resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }, except:
Vinnie Okada's avatar
Vinnie Okada committed
427 428 429
              [:new, :create, :index], path: "/") do
      member do
        put :transfer
430
        delete :remove_fork
Vinnie Okada's avatar
Vinnie Okada committed
431 432
        post :archive
        post :unarchive
433
        post :housekeeping
Vinnie Okada's avatar
Vinnie Okada committed
434 435 436
        post :toggle_star
        post :markdown_preview
        get :autocomplete_sources
437
        get :activity
skv's avatar
skv committed
438
      end
439

Vinnie Okada's avatar
Vinnie Okada committed
440 441 442 443 444 445 446 447 448
      scope module: :projects do
        # Blob routes:
        get '/new/*id', to: 'blob#new', constraints: { id: /.+/ }, as: 'new_blob'
        post '/create/*id', to: 'blob#create', constraints: { id: /.+/ }, as: 'create_blob'
        get '/edit/*id', to: 'blob#edit', constraints: { id: /.+/ }, as: 'edit_blob'
        put '/update/*id', to: 'blob#update', constraints: { id: /.+/ }, as: 'update_blob'
        post '/preview/*id', to: 'blob#preview', constraints: { id: /.+/ }, as: 'preview_blob'

        scope do
449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465
          get(
            '/blob/*id/diff',
            to: 'blob#diff',
            constraints: { id: /.+/, format: false },
            as: :blob_diff
          )
          get(
            '/blob/*id',
            to: 'blob#show',
            constraints: { id: /.+/, format: false },
            as: :blob
          )
          delete(
            '/blob/*id',
            to: 'blob#destroy',
            constraints: { id: /.+/, format: false }
          )
466 467 468 469 470 471 472 473 474 475
          put(
            '/blob/*id',
            to: 'blob#update',
            constraints: { id: /.+/, format: false }
          )
          post(
            '/blob/*id',
            to: 'blob#create',
            constraints: { id: /.+/, format: false }
          )
Vinnie Okada's avatar
Vinnie Okada committed
476
        end
477

Vinnie Okada's avatar
Vinnie Okada committed
478 479 480 481 482 483 484
        scope do
          get(
            '/raw/*id',
            to: 'raw#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :raw
          )
485
        end
486

Vinnie Okada's avatar
Vinnie Okada committed
487 488 489 490 491 492 493 494 495
        scope do
          get(
            '/tree/*id',
            to: 'tree#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :tree
          )
        end

496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513
        scope do
          get(
            '/find_file/*id',
            to: 'find_file#show',
            constraints: { id: /.+/, format: /html/ },
            as: :find_file
          )
        end

        scope do
          get(
            '/files/*id',
            to: 'find_file#list',
            constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ },
            as: :files
          )
        end

Stan Hu's avatar
Stan Hu committed
514 515
        scope do
          post(
Gabriel Mazetto's avatar
Gabriel Mazetto committed
516
            '/create_dir/*id',
Stan Hu's avatar
Stan Hu committed
517 518 519 520 521 522
              to: 'tree#create_dir',
              constraints: { id: /.+/ },
              as: 'create_dir'
          )
        end

Vinnie Okada's avatar
Vinnie Okada committed
523 524 525 526 527 528 529
        scope do
          get(
            '/blame/*id',
            to: 'blame#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :blame
          )
530
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
531

532 533 534 535
        scope do
          get(
            '/commits/*id',
            to: 'commits#show',
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
536
            constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
537 538 539 540 541
            as: :commits
          )
        end

        resource  :avatar, only: [:show, :destroy]
542
        resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do
543 544
          member do
            get :branches
Kamil Trzcinski's avatar
Kamil Trzcinski committed
545 546 547
            get :builds
            post :cancel_builds
            post :retry_builds
548
            post :revert
549
          end
550 551 552 553 554 555
        end

        resources :compare, only: [:index, :create]
        resources :network, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ }

        resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do
Vinnie Okada's avatar
Vinnie Okada committed
556 557
          member do
            get :commits
558
            get :ci
559
            get :languages
Vinnie Okada's avatar
Vinnie Okada committed
560
          end
561
        end
562

Vinnie Okada's avatar
Vinnie Okada committed
563 564
        get '/compare/:from...:to' => 'compare#show', :as => 'compare',
            :constraints => { from: /.+/, to: /.+/ }
565

Vinnie Okada's avatar
Vinnie Okada committed
566 567 568 569
        resources :snippets, constraints: { id: /\d+/ } do
          member do
            get 'raw'
          end
570
        end
571

572
        WIKI_SLUG_ID = { id: /\S+/ } unless defined? WIKI_SLUG_ID
573

Stan Hu's avatar
Stan Hu committed
574 575 576 577 578 579 580 581 582 583 584 585
        scope do
          # Order matters to give priority to these matches
          get '/wikis/git_access', to: 'wikis#git_access'
          get '/wikis/pages', to: 'wikis#pages', as: 'wiki_pages'
          post '/wikis', to: 'wikis#create'

          get '/wikis/*id/history', to: 'wikis#history', as: 'wiki_history', constraints: WIKI_SLUG_ID
          get '/wikis/*id/edit', to: 'wikis#edit', as: 'wiki_edit', constraints: WIKI_SLUG_ID

          get '/wikis/*id', to: 'wikis#show', as: 'wiki', constraints: WIKI_SLUG_ID
          delete '/wikis/*id', to: 'wikis#destroy', constraints: WIKI_SLUG_ID
          put '/wikis/*id', to: 'wikis#update', constraints: WIKI_SLUG_ID
586
        end
587

Vinnie Okada's avatar
Vinnie Okada committed
588 589 590 591 592
        resource :repository, only: [:show, :create] do
          member do
            get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
          end
        end
miks's avatar
miks committed
593

Vinnie Okada's avatar
Vinnie Okada committed
594 595 596 597
        resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
          member do
            get :test
          end
598
        end
gitlabhq's avatar
gitlabhq committed
599

600
        resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create] do
Vinnie Okada's avatar
Vinnie Okada committed
601 602 603 604
          member do
            put :enable
            put :disable
          end
605
        end
gitlabhq's avatar
gitlabhq committed
606

607
        resources :forks, only: [:index, :new, :create]
Vinnie Okada's avatar
Vinnie Okada committed
608 609 610 611 612 613 614 615 616 617
        resource :import, only: [:new, :create, :show]

        resources :refs, only: [] do
          collection do
            get 'switch'
          end

          member do
            # tree viewer logs
            get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
618 619
            # Directories with leading dots erroneously get rejected if git
            # ref regex used in constraints. Regex verification now done in controller.
620
            get 'logs_tree/*path' => 'refs#logs_tree', as: :logs_file, constraints: {
621
              id: /.*/,
Vinnie Okada's avatar
Vinnie Okada committed
622 623 624
              path: /.*/
            }
          end
625
        end
626

627
        resources :merge_requests, constraints: { id: /\d+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
628
          member do
629
            get :commits
Vinnie Okada's avatar
Vinnie Okada committed
630
            get :diffs
631
            get :builds
632 633
            get :merge_check
            post :merge
634
            post :cancel_merge_when_build_succeeds
Vinnie Okada's avatar
Vinnie Okada committed
635
            get :ci_status
Valery Sizov's avatar
tests  
Valery Sizov committed
636
            post :toggle_subscription
637
            post :remove_wip
Vinnie Okada's avatar
Vinnie Okada committed
638 639 640 641 642 643 644
          end

          collection do
            get :branch_from
            get :branch_to
            get :update_branches
          end
645
        end
646

Vinnie Okada's avatar
Vinnie Okada committed
647
        resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
648 649
        resources :tags, only: [:index, :show, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
          resource :release, only: [:edit, :update]
650 651
        end

Vinnie Okada's avatar
Vinnie Okada committed
652
        resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
653
        resource :variables, only: [:show, :update]
654
        resources :triggers, only: [:index, :create, :destroy]
655

656
        resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
657
          collection do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
658
            post :cancel_all
Kamil Trzcinski's avatar
Kamil Trzcinski committed
659 660
          end

661 662
          member do
            get :status
663
            post :cancel
664
            post :retry
665
            post :erase
666
          end
667

668 669
          resource :artifacts, only: [] do
            get :download
670 671
            get :browse, path: 'browse(/*path)', format: false
            get :file, path: 'file/*path', format: false
672
          end
673
        end
674

Vinnie Okada's avatar
Vinnie Okada committed
675 676 677 678
        resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
          member do
            get :test
          end
679
        end
680

681
        resources :milestones, constraints: { id: /\d+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
682 683 684 685
          member do
            put :sort_issues
            put :sort_merge_requests
          end
686
        end
687

Vinnie Okada's avatar
Vinnie Okada committed
688 689 690 691
        resources :labels, constraints: { id: /\d+/ } do
          collection do
            post :generate
          end
692 693 694 695

          member do
            post :toggle_subscription
          end
696
        end
697

698
        resources :issues, constraints: { id: /\d+/ } do
Valery Sizov's avatar
Valery Sizov committed
699
          member do
Valery Sizov's avatar
tests  
Valery Sizov committed
700
            post :toggle_subscription
Valery Sizov's avatar
Valery Sizov committed
701
          end
Vinnie Okada's avatar
Vinnie Okada committed
702 703 704
          collection do
            post  :bulk_update
          end
705
        end
Robert Speicher's avatar
Robert Speicher committed
706

707
        resources :project_members, except: [:new, :edit], constraints: { id: /[a-zA-Z.\/0-9_\-#%+]+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
708 709
          collection do
            delete :leave
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
710

Vinnie Okada's avatar
Vinnie Okada committed
711 712 713 714 715
            # Used for import team
            # from another project
            get :import
            post :apply_import
          end
716 717 718 719

          member do
            post :resend_invite
          end
720
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
721

722 723
        resources :group_links, only: [:index, :create, :destroy], constraints: { id: /\d+/ }

Vinnie Okada's avatar
Vinnie Okada committed
724 725 726 727
        resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
          member do
            delete :delete_attachment
          end
Valery Sizov's avatar
Valery Sizov committed
728 729 730 731

          collection do
            post :award_toggle
          end
732
        end
733 734 735

        resources :uploads, only: [:create] do
          collection do
736
            get ":secret/:filename", action: :show, as: :show, constraints: { filename: /[^\/]+/ }
737
          end
738
        end
739

740 741 742 743 744
        resources :runners, only: [:index, :edit, :update, :destroy, :show] do
          member do
            get :resume
            get :pause
          end
745 746 747 748

          collection do
            post :toggle_shared_runners
          end
749
        end
750 751

        resources :runner_projects, only: [:create, :destroy]
752 753 754 755 756 757
        resources :badges, only: [], path: 'badges/*ref',
                           constraints: { ref: Gitlab::Regex.git_reference_regex } do
          collection do
            get :build, constraints: { format: /svg/ }
          end
        end
758
      end
759
    end
gitlabhq's avatar
gitlabhq committed
760
  end
761

762 763 764
  # Get all keys of user
  get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }

765
  get ':id' => 'namespaces#show', constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ }
gitlabhq's avatar
gitlabhq committed
766
end