From ab710b74b2751f9a0d4eb5c5f950c6bb04865e79 Mon Sep 17 00:00:00 2001 From: Peter Amstutz Date: Tue, 20 May 2014 13:54:21 -0400 Subject: [PATCH 1/1] 2776: Added 'accessable' route to 'keep_services' --- doc/api/methods/keep_services.html.textile.liquid | 9 +++++++++ .../arvados/v1/keep_services_controller.rb | 12 +++++++++++- services/api/config/routes.rb | 4 +++- 3 files changed, 23 insertions(+), 2 deletions(-) diff --git a/doc/api/methods/keep_services.html.textile.liquid b/doc/api/methods/keep_services.html.textile.liquid index 016e566c2a..321dd152aa 100644 --- a/doc/api/methods/keep_services.html.textile.liquid +++ b/doc/api/methods/keep_services.html.textile.liquid @@ -12,6 +12,15 @@ API endpoint base: @https://{{ site.arvados_api_host }}/arvados/v1/keep_services Required arguments are displayed in %{background:#ccffcc}green%. +h2. accessable + +Get a list of keep services that are accessable to the requesting client. This +is context-sensitive, for example providing the list of actual Keep servers +when inside the cluster, but providing a proxy service if client contacts +Arvados from outside the cluster. + +Takes no arguments. + h2. create Create a new KeepService. diff --git a/services/api/app/controllers/arvados/v1/keep_services_controller.rb b/services/api/app/controllers/arvados/v1/keep_services_controller.rb index 5c0375fc18..43ce94d490 100644 --- a/services/api/app/controllers/arvados/v1/keep_services_controller.rb +++ b/services/api/app/controllers/arvados/v1/keep_services_controller.rb @@ -1,9 +1,19 @@ class Arvados::V1::KeepServicesController < ApplicationController def find_objects_for_index - # all users can list all keep disks + # all users can list all keep services @objects = model_class.where('1=1') super end + def accessable + if request.headers['X-Keep-Proxy-Required'] + @objects = model_class.where('service_type=?', 'proxy') + else + @objects = model_class.where('service_type=?', 'disk') + end + + render_list + end + end diff --git a/services/api/config/routes.rb b/services/api/config/routes.rb index d5ef141ef3..c1549d082a 100644 --- a/services/api/config/routes.rb +++ b/services/api/config/routes.rb @@ -27,7 +27,9 @@ Server::Application.routes.draw do resources :keep_disks do post 'ping', on: :collection end - resources :keep_services + resources :keep_services do + get 'accessable', on: :collection + end resources :links resources :logs resources :nodes do -- 2.30.2