2776: Added 'accessable' route to 'keep_services'
authorPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 20 May 2014 17:54:21 +0000 (13:54 -0400)
committerPeter Amstutz <peter.amstutz@curoverse.com>
Tue, 20 May 2014 17:54:21 +0000 (13:54 -0400)
doc/api/methods/keep_services.html.textile.liquid
services/api/app/controllers/arvados/v1/keep_services_controller.rb
services/api/config/routes.rb

index 016e566c2a678cac2a33b936c52c7346b6b4ca89..321dd152aaaf74a72827eedc96bcf5f708aebceb 100644 (file)
@@ -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.
index 5c0375fc18002197e0ce262a058e46589980e9fc..43ce94d490533541ce548d934de15f72fc7a8467 100644 (file)
@@ -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
index d5ef141ef3caaf58405c56b031615a76e65bb11f..c1549d082af3a6d3d4fe75be18a7608682d3bf03 100644 (file)
@@ -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