routes.rb 20.2 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 31 32 33 34 35
  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
36
  use_doorkeeper do
37 38 39
    controllers applications: 'oauth/applications',
                authorized_applications: 'oauth/authorized_applications',
                authorizations: 'oauth/authorizations'
Valery Sizov's avatar
Valery Sizov committed
40
  end
41

42 43 44 45
  # Autocomplete
  get '/autocomplete/users' => 'autocomplete#users'
  get '/autocomplete/users/:id' => 'autocomplete#user'

Annabel Dunstone's avatar
Annabel Dunstone committed
46 47
  # Emojis
  resources :emojis, only: :index
48

49
  # Search
50 51
  get 'search' => 'search#show'
  get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
Valery Sizov's avatar
Valery Sizov committed
52

53
  # API
54 55
  API::API.logger Rails.logger
  mount API::API => '/api'
56

57
  constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
58
  constraints constraint do
59
    mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
60
  end
Ariejan de Vroom's avatar
Ariejan de Vroom committed
61

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

65
  # Help
Job van der Voort's avatar
Job van der Voort committed
66
  get 'help'                  => 'help#index'
67
  get 'help/:category/:file'  => 'help#show', as: :help_page, constraints: { category: /.*/, file: /[^\/\.]+/ }
Marin Jankovski's avatar
Marin Jankovski committed
68
  get 'help/shortcuts'
69
  get 'help/ui'               => 'help#ui'
70

Andrew8xx8's avatar
Andrew8xx8 committed
71 72 73 74 75
  #
  # Global snippets
  #
  resources :snippets do
    member do
76
      get 'raw'
Andrew8xx8's avatar
Andrew8xx8 committed
77 78
    end
  end
79 80

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

Douwe Maan's avatar
Douwe Maan committed
82 83 84 85 86 87 88
  #
  # Invites
  #

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

93
  resources :sent_notifications, only: [], constraints: { id: /\h{32}/ } do
94 95 96 97 98
    member do
      get :unsubscribe
    end
  end

99 100 101
  # Spam reports
  resources :abuse_reports, only: [:new, :create]

Valery Sizov's avatar
Valery Sizov committed
102
  #
103
  # Import
Valery Sizov's avatar
Valery Sizov committed
104
  #
105 106
  namespace :import do
    resource :github, only: [:create, :new], controller: :github do
107 108 109 110 111
      get :status
      get :callback
      get :jobs
    end

112
    resource :gitlab, only: [:create, :new], controller: :gitlab do
113 114 115 116
      get :status
      get :callback
      get :jobs
    end
Marcin Kulik's avatar
Marcin Kulik committed
117

Douwe Maan's avatar
Douwe Maan committed
118 119 120 121 122
    resource :bitbucket, only: [:create, :new], controller: :bitbucket do
      get :status
      get :callback
      get :jobs
    end
123

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

    resource :google_code, only: [:create, :new], controller: :google_code do
      get :status
      post :callback
      get :jobs
134 135 136

      get   :new_user_map,    path: :user_map
      post  :create_user_map, path: :user_map
137
    end
Jared Szechy's avatar
Jared Szechy committed
138 139 140 141 142 143 144 145 146

    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
147
  end
148

149 150 151
  #
  # Uploads
  #
152

153 154
  scope path: :uploads do
    # Note attachments and User/Group/Project avatars
155 156
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
157
        constraints:  { model: /note|user|group|project/, mounted_as: /avatar|attachment/, filename: /[^\/]+/ }
158

159 160 161 162 163
    # Appearance
    get ":model/:mounted_as/:id/:filename",
        to:           "uploads#show",
        constraints:  { model: /appearance/, mounted_as: /logo|header_logo/, filename: /.+/ }

164
    # Project markdown uploads
165
    get ":namespace_id/:project_id/:secret/:filename",
166
      to:           "projects/uploads#show",
167
      constraints:  { namespace_id: /[a-zA-Z.0-9_\-]+/, project_id: /[a-zA-Z.0-9_\-]+/, filename: /[^\/]+/ }
168
  end
Valery Sizov's avatar
Valery Sizov committed
169

170
  # Redirect old note attachments path to new uploads path.
171 172
  get "files/note/:id/:filename",
    to:           redirect("uploads/note/attachment/%{id}/%{filename}"),
173
    constraints:  { filename: /[^\/]+/ }
174

175
  #
Yatish Mehta's avatar
Yatish Mehta committed
176
  # Explore area
177
  #
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
178 179 180 181
  namespace :explore do
    resources :projects, only: [:index] do
      collection do
        get :trending
182
        get :starred
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
183 184 185
      end
    end

186
    resources :groups, only: [:index]
187
    resources :snippets, only: [:index]
188
    root to: 'projects#trending'
189 190
  end

Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
191
  # Compatibility with old routing
192 193
  get 'public' => 'explore/projects#index'
  get 'public/projects' => 'explore/projects#index'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
194

195 196 197
  #
  # Admin Area
  #
Nihad Abbasov's avatar
Nihad Abbasov committed
198
  namespace :admin do
199
    resources :users, constraints: { id: /[a-zA-Z.\/0-9_\-]+/ } do
200
      resources :keys, only: [:show, :destroy]
201
      resources :identities, except: [:show]
202

203
      delete 'stop_impersonation' => 'impersonation#destroy', on: :collection
204

205
      member do
206 207 208
        get :projects
        get :keys
        get :groups
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
209
        put :team_update
210 211
        put :block
        put :unblock
212
        put :unlock
213
        put :confirm
214
        post 'impersonate' => 'impersonation#create'
215
        patch :disable_two_factor
216
        delete 'remove/:email_id', action: 'remove_email', as: 'remove_email'
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
217 218
      end
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
219

220
    resources :abuse_reports, only: [:index, :destroy]
221 222
    resources :spam_logs, only: [:index, :destroy]

Valery Sizov's avatar
Valery Sizov committed
223 224
    resources :applications

225 226
    resources :groups, constraints: { id: /[^\/]+/ } do
      member do
227
        put :members_update
228
      end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
229
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
230

231
    resources :deploy_keys, only: [:index, :new, :create, :destroy]
232

233
    resources :hooks, only: [:index, :create, :destroy] do
Valeriy Sizov's avatar
Valeriy Sizov committed
234 235
      get :test
    end
Andrey Kumanyaev's avatar
Andrey Kumanyaev committed
236

237 238 239 240
    resources :broadcast_messages, only: [:index, :edit, :create, :update, :destroy] do
      post :preview, on: :collection
    end

241
    resource :logs, only: [:show]
242
    resource :background_jobs, controller: 'background_jobs', only: [:show]
243

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

247 248
      resources(:projects,
                path: '/',
Vinnie Okada's avatar
Vinnie Okada committed
249 250 251 252 253 254 255
                constraints: { id: /[a-zA-Z.0-9_\-]+/ },
                only: [:index, :show]) do
        root to: 'projects#show'

        member do
          put :transfer
        end
256 257

        resources :runner_projects
258 259 260
      end
    end

261 262 263 264 265 266 267
    resource :appearances, path: 'appearance' do
      member do
        get :preview
        delete :logo
        delete :header_logos
      end
    end
268

269 270
    resource :application_settings, only: [:show, :update] do
      resources :services
271
      put :reset_runners_token
272
    end
273

Valery Sizov's avatar
Valery Sizov committed
274 275
    resources :labels

276 277 278 279 280 281 282 283 284 285 286 287 288
    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

289
    root to: 'dashboard#index'
gitlabhq's avatar
gitlabhq committed
290 291
  end

randx's avatar
randx committed
292 293 294
  #
  # Profile Area
  #
295 296
  resource :profile, only: [:show, :update] do
    member do
297
      get :audit_log
298
      get :applications, to: 'oauth/applications#index'
299 300 301 302

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

304
    scope module: :profiles do
305 306 307 308 309
      resource :account, only: [:show, :update] do
        member do
          delete :unlink
        end
      end
310
      resource :notifications, only: [:show, :update]
311 312 313 314 315
      resource :password, only: [:new, :create, :edit, :update] do
        member do
          put :reset
        end
      end
316
      resource :preferences, only: [:show, :update]
317
      resources :keys, except: [:new]
318
      resources :emails, only: [:index, :create, :destroy]
319
      resource :avatar, only: [:destroy]
320 321
      resource :two_factor_auth, only: [:new, :create, :destroy] do
        member do
322
          post :codes
323
          patch :skip
324 325
        end
      end
326
    end
327
  end
328

329
  get 'u/:username/calendar' => 'users#calendar', as: :user_calendar,
330 331 332 333
      constraints: { username: /.*/ }

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

335 336 337
  get 'u/:username/groups' => 'users#groups', as: :user_groups,
      constraints: { username: /.*/ }

338
  get 'u/:username/projects' => 'users#projects', as: :user_projects,
339 340
      constraints: { username: /.*/ }

341
  get 'u/:username/contributed' => 'users#contributed', as: :user_contributed_projects,
342 343
      constraints: { username: /.*/ }

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

randx's avatar
randx committed
347 348 349
  #
  # Dashboard Area
  #
350 351 352 353
  resource :dashboard, controller: 'dashboard', only: [] do
    get :issues
    get :merge_requests
    get :activity
354 355
    get :labels
    get :milestones
Douwe Maan's avatar
Douwe Maan committed
356 357 358

    scope module: :dashboard do
      resources :milestones, only: [:index, :show]
359

360
      resources :groups, only: [:index]
361
      resources :snippets, only: [:index]
362 363 364 365 366 367

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

369
      resources :projects, only: [:index] do
370 371 372 373
        collection do
          get :starred
        end
      end
Douwe Maan's avatar
Douwe Maan committed
374
    end
375 376

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

randx's avatar
randx committed
379 380 381
  #
  # Groups Area
  #
382
  resources :groups, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }  do
randx's avatar
randx committed
383 384 385
    member do
      get :issues
      get :merge_requests
386
      get :projects
387
      get :activity
randx's avatar
randx committed
388
    end
389

Steven Thonus's avatar
Steven Thonus committed
390
    scope module: :groups do
391
      resources :group_members, only: [:index, :create, :update, :destroy] do
392
        post :resend_invite, on: :member
393
        delete :leave, on: :collection
394
      end
395

Steven Thonus's avatar
Steven Thonus committed
396
      resource :avatar, only: [:destroy]
397
      resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :update, :new, :create]
Steven Thonus's avatar
Steven Thonus committed
398
    end
randx's avatar
randx committed
399 400
  end

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

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

405
  devise_scope :user do
406
    get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
407
  end
Vinnie Okada's avatar
Vinnie Okada committed
408

409
  root to: "root#index"
Vinnie Okada's avatar
Vinnie Okada committed
410

411 412 413
  #
  # Project Area
  #
Vinnie Okada's avatar
Vinnie Okada committed
414
  resources :namespaces, path: '/', constraints: { id: /[a-zA-Z.0-9_\-]+/ }, only: [] do
415
    resources(:projects, constraints: { id: /[a-zA-Z.0-9_\-]+(?<!\.atom)/ }, except:
Vinnie Okada's avatar
Vinnie Okada committed
416 417 418
              [:new, :create, :index], path: "/") do
      member do
        put :transfer
419
        delete :remove_fork
Vinnie Okada's avatar
Vinnie Okada committed
420 421
        post :archive
        post :unarchive
422
        post :housekeeping
Vinnie Okada's avatar
Vinnie Okada committed
423 424 425
        post :toggle_star
        post :markdown_preview
        get :autocomplete_sources
426
        get :activity
skv's avatar
skv committed
427
      end
428

Vinnie Okada's avatar
Vinnie Okada committed
429 430 431 432 433 434 435 436 437
      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
438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454
          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 }
          )
455 456 457 458 459 460 461 462 463 464
          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
465
        end
466

Vinnie Okada's avatar
Vinnie Okada committed
467 468 469 470 471 472 473
        scope do
          get(
            '/raw/*id',
            to: 'raw#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :raw
          )
474
        end
475

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

485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502
        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
503 504
        scope do
          post(
Gabriel Mazetto's avatar
Gabriel Mazetto committed
505
            '/create_dir/*id',
Stan Hu's avatar
Stan Hu committed
506 507 508 509 510 511
              to: 'tree#create_dir',
              constraints: { id: /.+/ },
              as: 'create_dir'
          )
        end

Vinnie Okada's avatar
Vinnie Okada committed
512 513 514 515 516 517 518
        scope do
          get(
            '/blame/*id',
            to: 'blame#show',
            constraints: { id: /.+/, format: /(html|js)/ },
            as: :blame
          )
519
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
520

521 522 523 524
        scope do
          get(
            '/commits/*id',
            to: 'commits#show',
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
525
            constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ },
526 527 528 529 530
            as: :commits
          )
        end

        resource  :avatar, only: [:show, :destroy]
531
        resources :commit, only: [:show], constraints: { id: /\h{7,40}/ } do
532 533
          member do
            get :branches
Kamil Trzcinski's avatar
Kamil Trzcinski committed
534 535 536
            get :builds
            post :cancel_builds
            post :retry_builds
537
            post :revert
538
          end
539 540 541 542 543 544
        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
545 546
          member do
            get :commits
547
            get :ci
548
            get :languages
Vinnie Okada's avatar
Vinnie Okada committed
549
          end
550
        end
551

Vinnie Okada's avatar
Vinnie Okada committed
552 553
        get '/compare/:from...:to' => 'compare#show', :as => 'compare',
            :constraints => { from: /.+/, to: /.+/ }
554

Vinnie Okada's avatar
Vinnie Okada committed
555 556 557 558
        resources :snippets, constraints: { id: /\d+/ } do
          member do
            get 'raw'
          end
559
        end
560

561
        WIKI_SLUG_ID = { id: /\S+/ } unless defined? WIKI_SLUG_ID
562

Stan Hu's avatar
Stan Hu committed
563 564 565 566 567 568 569 570 571 572 573 574
        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
575
        end
576

Vinnie Okada's avatar
Vinnie Okada committed
577 578 579 580 581
        resource :repository, only: [:show, :create] do
          member do
            get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
          end
        end
miks's avatar
miks committed
582

Vinnie Okada's avatar
Vinnie Okada committed
583 584 585 586
        resources :services, constraints: { id: /[^\/]+/ }, only: [:index, :edit, :update] do
          member do
            get :test
          end
587
        end
gitlabhq's avatar
gitlabhq committed
588

589
        resources :deploy_keys, constraints: { id: /\d+/ }, only: [:index, :new, :create] do
Vinnie Okada's avatar
Vinnie Okada committed
590 591 592 593
          member do
            put :enable
            put :disable
          end
594
        end
gitlabhq's avatar
gitlabhq committed
595

596
        resources :forks, only: [:index, :new, :create]
Vinnie Okada's avatar
Vinnie Okada committed
597 598 599 600 601 602 603 604 605 606
        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 }
607 608
            # Directories with leading dots erroneously get rejected if git
            # ref regex used in constraints. Regex verification now done in controller.
609
            get 'logs_tree/*path' => 'refs#logs_tree', as: :logs_file, constraints: {
610
              id: /.*/,
Vinnie Okada's avatar
Vinnie Okada committed
611 612 613
              path: /.*/
            }
          end
614
        end
615

Vinnie Okada's avatar
Vinnie Okada committed
616 617
        resources :merge_requests, constraints: { id: /\d+/ }, except: [:destroy] do
          member do
618
            get :commits
Vinnie Okada's avatar
Vinnie Okada committed
619
            get :diffs
620
            get :builds
621 622
            get :merge_check
            post :merge
623
            post :cancel_merge_when_build_succeeds
Vinnie Okada's avatar
Vinnie Okada committed
624
            get :ci_status
Valery Sizov's avatar
tests  
Valery Sizov committed
625
            post :toggle_subscription
626
            post :remove_wip
Vinnie Okada's avatar
Vinnie Okada committed
627 628 629 630 631 632 633
          end

          collection do
            get :branch_from
            get :branch_to
            get :update_branches
          end
634
        end
635

Vinnie Okada's avatar
Vinnie Okada committed
636
        resources :branches, only: [:index, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
637 638
        resources :tags, only: [:index, :show, :new, :create, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex } do
          resource :release, only: [:edit, :update]
639 640
        end

Vinnie Okada's avatar
Vinnie Okada committed
641
        resources :protected_branches, only: [:index, :create, :update, :destroy], constraints: { id: Gitlab::Regex.git_reference_regex }
642
        resource :variables, only: [:show, :update]
643
        resources :triggers, only: [:index, :create, :destroy]
644

645
        resources :builds, only: [:index, :show], constraints: { id: /\d+/ } do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
646
          collection do
Kamil Trzcinski's avatar
Kamil Trzcinski committed
647
            post :cancel_all
Kamil Trzcinski's avatar
Kamil Trzcinski committed
648 649
          end

650 651
          member do
            get :status
652
            post :cancel
653
            post :retry
654
            post :erase
655
          end
656

657 658
          resource :artifacts, only: [] do
            get :download
659 660
            get :browse, path: 'browse(/*path)', format: false
            get :file, path: 'file/*path', format: false
661
          end
662
        end
663

Vinnie Okada's avatar
Vinnie Okada committed
664 665 666 667
        resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do
          member do
            get :test
          end
668
        end
669

670
        resources :milestones, constraints: { id: /\d+/ } do
Vinnie Okada's avatar
Vinnie Okada committed
671 672 673 674
          member do
            put :sort_issues
            put :sort_merge_requests
          end
675
        end
676

Vinnie Okada's avatar
Vinnie Okada committed
677 678 679 680
        resources :labels, constraints: { id: /\d+/ } do
          collection do
            post :generate
          end
681 682 683 684

          member do
            post :toggle_subscription
          end
685
        end
686

Vinnie Okada's avatar
Vinnie Okada committed
687
        resources :issues, constraints: { id: /\d+/ }, except: [:destroy] do
Valery Sizov's avatar
Valery Sizov committed
688
          member do
Valery Sizov's avatar
tests  
Valery Sizov committed
689
            post :toggle_subscription
Valery Sizov's avatar
Valery Sizov committed
690
          end
Vinnie Okada's avatar
Vinnie Okada committed
691 692 693
          collection do
            post  :bulk_update
          end
694
        end
Robert Speicher's avatar
Robert Speicher committed
695

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

Vinnie Okada's avatar
Vinnie Okada committed
700 701 702 703 704
            # Used for import team
            # from another project
            get :import
            post :apply_import
          end
705 706 707 708

          member do
            post :resend_invite
          end
709
        end
Dmitriy Zaporozhets's avatar
Dmitriy Zaporozhets committed
710

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

Vinnie Okada's avatar
Vinnie Okada committed
713 714 715 716
        resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do
          member do
            delete :delete_attachment
          end
Valery Sizov's avatar
Valery Sizov committed
717 718 719 720

          collection do
            post :award_toggle
          end
721
        end
722 723 724

        resources :uploads, only: [:create] do
          collection do
725
            get ":secret/:filename", action: :show, as: :show, constraints: { filename: /[^\/]+/ }
726
          end
727
        end
728

729 730 731 732 733
        resources :runners, only: [:index, :edit, :update, :destroy, :show] do
          member do
            get :resume
            get :pause
          end
734 735 736 737

          collection do
            post :toggle_shared_runners
          end
738
        end
739 740

        resources :runner_projects, only: [:create, :destroy]
741 742 743 744 745 746
        resources :badges, only: [], path: 'badges/*ref',
                           constraints: { ref: Gitlab::Regex.git_reference_regex } do
          collection do
            get :build, constraints: { format: /svg/ }
          end
        end
747
      end
748
    end
gitlabhq's avatar
gitlabhq committed
749
  end
750

751 752 753
  # Get all keys of user
  get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }

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