Sha256: 31989f5c0ddacfaa911a5a983b252f44fb9ccc66d34041d157fdbe3717d11c7a

Contents?: true

Size: 1.51 KB

Versions: 23

Compression:

Stored size: 1.51 KB

Contents

module Rhoconnect
  module Controller  
    class SourcesController < Rhoconnect::Controller::APIBase
      set_default :admin_required, true
      set_default :login_required, false
      set_default :source_required, false
      set_default :client_required, false

      register Rhoconnect::EndPoint
      
      # get source's params
      get "/:source_id", \
                  :deprecated_route => {:verb => :post, :url => ['/api/get_source_params', '/api/source/get_source_params']} do
        Source.load(params[:source_id],{:app_id => APP_NAME,:user_id => '*'}).to_array.to_json
      end
      
      # get all sources with particular partition type
      get "/type/:partition_type", \
                  :deprecated_route => {:verb => :post, :url => ['/api/list_sources', '/api/source/list_sources']}  do
        sources = App.load(APP_NAME).sources
        if params['partition_type'].nil? or params['partition_type'] == 'all'
          sources.to_json 
        else
          res = []
          sources.each do |name|
            s = Source.load(name,{:app_id => APP_NAME,:user_id => '*'})
            if s and s.partition_type and s.partition_type == params['partition_type'].to_sym
              res << name 
            end
          end  
          res.to_json
        end  
      end
      
      # update source's params
      put "/:source_id" do
        source = Source.load(params[:source_id],
          {:app_id => APP_NAME, :user_id => '*'})
        source.update_fields(params[:data])
        ''
      end
    end
  end
end

Version data entries

23 entries across 23 versions & 1 rubygems

Version Path
rhoconnect-7.6.0 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-7.5.1 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-7.4.1 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-7.1.17 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-6.2.0 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-6.0.11 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.18 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.17 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.15 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.0.22 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.2 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.0.7 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.0.3 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.5.0 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-5.1.1 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-4.0.4 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-4.0.3 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-4.0.2 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-4.0.1 lib/rhoconnect/controller/sources_controller.rb
rhoconnect-4.0.0 lib/rhoconnect/controller/sources_controller.rb