Merge branch '8784-dir-listings'
[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       end
34       resources :humans
35       resources :job_tasks
36       resources :containers do
37         get 'auth', on: :member
38         post 'lock', on: :member
39         post 'unlock', on: :member
40         get 'current', on: :collection
41       end
42       resources :container_requests
43       resources :jobs do
44         get 'queue', on: :collection
45         get 'queue_size', on: :collection
46         post 'cancel', on: :member
47         post 'lock', on: :member
48       end
49       resources :keep_disks do
50         post 'ping', on: :collection
51       end
52       resources :keep_services do
53         get 'accessible', on: :collection
54       end
55       resources :links
56       resources :logs
57       resources :nodes do
58         post 'ping', on: :member
59       end
60       resources :pipeline_instances do
61         post 'cancel', on: :member
62       end
63       resources :pipeline_templates
64       resources :workflows
65       resources :repositories do
66         get 'get_all_permissions', on: :collection
67       end
68       resources :specimens
69       resources :traits
70       resources :user_agreements do
71         get 'signatures', on: :collection
72         post 'sign', on: :collection
73       end
74       resources :users do
75         get 'current', on: :collection
76         get 'system', on: :collection
77         post 'activate', on: :member
78         post 'setup', on: :collection
79         post 'unsetup', on: :member
80       end
81       resources :virtual_machines do
82         get 'logins', on: :member
83         get 'get_all_logins', on: :collection
84       end
85       get '/permissions/:uuid', to: 'links#get_permissions'
86     end
87   end
88
89   if Rails.env == 'test'
90     post '/database/reset', to: 'database#reset'
91   end
92
93   # omniauth
94   match '/auth/:provider/callback', to: 'user_sessions#create', via: [:get, :post]
95   match '/auth/failure', to: 'user_sessions#failure', via: [:get, :post]
96   # not handled by omniauth provider -> 403 with no CORS headers.
97   get '/auth/*a', to: 'user_sessions#cross_origin_forbidden'
98
99   # Custom logout
100   match '/login', to: 'user_sessions#login', via: [:get, :post]
101   match '/logout', to: 'user_sessions#logout', via: [:get, :post]
102
103   match '/discovery/v1/apis/arvados/v1/rest', to: 'arvados/v1/schema#index', via: [:get, :post]
104
105   match '/static/login_failure', to: 'static#login_failure', as: :login_failure, via: [:get, :post]
106
107   # Send unroutable requests to an arbitrary controller
108   # (ends up at ApplicationController#render_not_found)
109   match '*a', to: 'static#render_not_found', via: [:get, :post, :put, :patch, :delete, :options]
110
111   root to: 'static#home'
112 end