Merge branch 'master' into 10112-workflow-show
[arvados.git] / services / api / config / routes.rb
1 Server::Application.routes.draw do
2   themes_for_rails
3
4   # OPTIONS requests are not allowed at routes that use cookies.
5   ['/auth/*a', '/login', '/logout'].each do |nono|
6     match nono, to: 'user_sessions#cross_origin_forbidden', via: 'OPTIONS'
7   end
8   # OPTIONS at discovery and API paths get an empty response with CORS headers.
9   match '/discovery/v1/*a', to: 'static#empty', via: 'OPTIONS'
10   match '/arvados/v1/*a', to: 'static#empty', via: 'OPTIONS'
11
12   namespace :arvados do
13     namespace :v1 do
14       resources :api_client_authorizations do
15         post 'create_system_auth', on: :collection
16         get 'current', on: :collection
17       end
18       resources :api_clients
19       resources :authorized_keys
20       resources :collections do
21         get 'provenance', on: :member
22         get 'used_by', on: :member
23         post 'trash', on: :member
24       end
25       resources :groups do
26         get 'contents', on: :collection
27         get 'contents', on: :member
28       end
29       resources :humans
30       resources :job_tasks
31       resources :containers do
32         get 'auth', on: :member
33         post 'lock', on: :member
34         post 'unlock', on: :member
35         get 'current', on: :collection
36       end
37       resources :container_requests
38       resources :jobs do
39         get 'queue', on: :collection
40         get 'queue_size', on: :collection
41         post 'cancel', on: :member
42         post 'lock', on: :member
43       end
44       resources :keep_disks do
45         post 'ping', on: :collection
46       end
47       resources :keep_services do
48         get 'accessible', on: :collection
49       end
50       resources :links
51       resources :logs
52       resources :nodes do
53         post 'ping', on: :member
54       end
55       resources :pipeline_instances do
56         post 'cancel', on: :member
57       end
58       resources :pipeline_templates
59       resources :workflows
60       resources :repositories do
61         get 'get_all_permissions', on: :collection
62       end
63       resources :specimens
64       resources :traits
65       resources :user_agreements do
66         get 'signatures', on: :collection
67         post 'sign', on: :collection
68       end
69       resources :users do
70         get 'current', on: :collection
71         get 'system', on: :collection
72         post 'activate', on: :member
73         post 'setup', on: :collection
74         post 'unsetup', on: :member
75       end
76       resources :virtual_machines do
77         get 'logins', on: :member
78         get 'get_all_logins', on: :collection
79       end
80       get '/permissions/:uuid', to: 'links#get_permissions'
81     end
82   end
83
84   if Rails.env == 'test'
85     post '/database/reset', to: 'database#reset'
86   end
87
88   # omniauth
89   match '/auth/:provider/callback', to: 'user_sessions#create', via: [:get, :post]
90   match '/auth/failure', to: 'user_sessions#failure', via: [:get, :post]
91   # not handled by omniauth provider -> 403 with no CORS headers.
92   get '/auth/*a', to: 'user_sessions#cross_origin_forbidden'
93
94   # Custom logout
95   match '/login', to: 'user_sessions#login', via: [:get, :post]
96   match '/logout', to: 'user_sessions#logout', via: [:get, :post]
97
98   match '/discovery/v1/apis/arvados/v1/rest', to: 'arvados/v1/schema#index', via: [:get, :post]
99
100   match '/static/login_failure', to: 'static#login_failure', as: :login_failure, via: [:get, :post]
101
102   # Send unroutable requests to an arbitrary controller
103   # (ends up at ApplicationController#render_not_found)
104   match '*a', to: 'static#render_not_found', via: [:get, :post, :put, :patch, :delete, :options]
105
106   root to: 'static#home'
107 end