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