Module: Riak::Client::HTTPBackend::Configuration
- Included in:
- Riak::Client::HTTPBackend
- Defined in:
- lib/riak/client/http_backend/configuration.rb
Overview
Riak 0.14 provides a root URL that enumerates all of the HTTP endpoints and their paths. This module adds methods to auto-discover those endpoints via the root URL. It also adds methods for generating URL paths for specific resources.
Instance Method Summary collapse
-
#bucket_list_path(options = {}) ⇒ URI
A URL path for the “buckets list” resource.
-
#bucket_properties_path(bucket, options = {}) ⇒ URI
A URL path for the “bucket properties” resource.
-
#index_eq_path(bucket, index, value, options = {}) ⇒ URI
A URL path for the “index range query” resource.
-
#index_range_path(bucket, index, start, finish, options = {}) ⇒ URI
A URL path for the “index range query” resource.
-
#key_list_path(bucket, options = {:keys => true}) ⇒ URI
A URL path for the “list keys” resource.
-
#link_walk_path(bucket, key, specs) ⇒ URI
A URL path for the “link-walking” resource.
-
#luwak_path(key) ⇒ URI
A URL path for the Luwak interface.
-
#mapred_path(options = {}) ⇒ URI
A URL path to the “mapred” resource.
-
#object_path(bucket, key, options = {}) ⇒ URI
A URL path for the “object” resource.
-
#ping_path ⇒ URI
A URL path to the “ping” resource.
-
#solr_select_path(index, query, options = {}) ⇒ URI
A URL path for a Solr query resource.
-
#solr_update_path(index) ⇒ URI
A URL path for a Solr update resource.
-
#stats_path ⇒ URI
A URL path to the “stats” resource.
Instance Method Details
#bucket_list_path(options = {}) ⇒ URI
Returns a URL path for the “buckets list” resource.
31 32 33 34 35 36 37 |
# File 'lib/riak/client/http_backend/configuration.rb', line 31 def bucket_list_path(={}) if new_scheme? path(riak_kv_wm_buckets, .merge(:buckets => true)) else path(riak_kv_wm_raw, .merge(:buckets => true)) end end |
#bucket_properties_path(bucket, options = {}) ⇒ URI
Returns a URL path for the “bucket properties” resource.
42 43 44 45 46 47 48 |
# File 'lib/riak/client/http_backend/configuration.rb', line 42 def bucket_properties_path(bucket, ={}) if new_scheme? path(riak_kv_wm_buckets, escape(bucket), "props", ) else path(riak_kv_wm_raw, escape(bucket), .merge(:props => true, :keys => false)) end end |
#index_eq_path(bucket, index, value, options = {}) ⇒ URI
Returns a URL path for the “index range query” resource.
105 106 107 108 |
# File 'lib/riak/client/http_backend/configuration.rb', line 105 def index_eq_path(bucket, index, value, ={}) raise t('indexes_unsupported') unless new_scheme? path(riak_kv_wm_buckets, escape(bucket), "index", escape(index), escape(value.to_s), ) end |
#index_range_path(bucket, index, start, finish, options = {}) ⇒ URI
Returns a URL path for the “index range query” resource.
94 95 96 97 |
# File 'lib/riak/client/http_backend/configuration.rb', line 94 def index_range_path(bucket, index, start, finish, ={}) raise t('indexes_unsupported') unless new_scheme? path(riak_kv_wm_buckets, escape(bucket), "index", escape(index), escape(start.to_s), escape(finish.to_s), ) end |
#key_list_path(bucket, options = {:keys => true}) ⇒ URI
Returns a URL path for the “list keys” resource.
53 54 55 56 57 58 59 |
# File 'lib/riak/client/http_backend/configuration.rb', line 53 def key_list_path(bucket, ={:keys => true}) if new_scheme? path(riak_kv_wm_buckets, escape(bucket), "keys", ) else path(riak_kv_wm_raw, escape(bucket), .merge(:props => false)) end end |
#link_walk_path(bucket, key, specs) ⇒ URI
Returns a URL path for the “link-walking” resource.
79 80 81 82 83 84 85 86 |
# File 'lib/riak/client/http_backend/configuration.rb', line 79 def link_walk_path(bucket, key, specs) specs = specs.map {|s| s.to_s } if new_scheme? path(riak_kv_wm_buckets, escape(bucket), "keys", escape(key), *specs) else path(riak_kv_wm_link_walker, escape(bucket), escape(key), *specs) end end |
#luwak_path(key) ⇒ URI
Returns a URL path for the Luwak interface.
136 137 138 139 140 141 142 143 |
# File 'lib/riak/client/http_backend/configuration.rb', line 136 def luwak_path(key) raise t('luwak_unsupported') unless luwak_wm_file if key path(luwak_wm_file, escape(key)) else path(luwak_wm_file) end end |
#mapred_path(options = {}) ⇒ URI
Returns a URL path to the “mapred” resource.
26 27 28 |
# File 'lib/riak/client/http_backend/configuration.rb', line 26 def mapred_path(={}) path(riak_kv_wm_mapred, ) end |
#object_path(bucket, key, options = {}) ⇒ URI
Returns a URL path for the “object” resource.
65 66 67 68 69 70 71 72 |
# File 'lib/riak/client/http_backend/configuration.rb', line 65 def object_path(bucket, key, ={}) key = escape(key) if key if new_scheme? path([riak_kv_wm_buckets, escape(bucket), "keys", key, ].compact) else path([riak_kv_wm_raw, escape(bucket), key, ].compact) end end |
#ping_path ⇒ URI
Returns a URL path to the “ping” resource.
15 16 17 |
# File 'lib/riak/client/http_backend/configuration.rb', line 15 def ping_path path(riak_kv_wm_ping) end |
#solr_select_path(index, query, options = {}) ⇒ URI
Returns a URL path for a Solr query resource.
114 115 116 117 118 119 120 121 122 |
# File 'lib/riak/client/http_backend/configuration.rb', line 114 def solr_select_path(index, query, ={}) raise t('search_unsupported') unless riak_solr_searcher_wm = {"q" => query, "wt" => "json"}.merge() if index path(riak_solr_searcher_wm, index, 'select', ) else path(riak_solr_searcher_wm, 'select', ) end end |
#solr_update_path(index) ⇒ URI
Returns a URL path for a Solr update resource.
126 127 128 129 130 131 132 133 |
# File 'lib/riak/client/http_backend/configuration.rb', line 126 def solr_update_path(index) raise t('search_unsupported') unless riak_solr_indexer_wm if index path(riak_solr_indexer_wm, index, 'update') else path(riak_solr_indexer_wm, 'update') end end |
#stats_path ⇒ URI
Returns a URL path to the “stats” resource.
20 21 22 |
# File 'lib/riak/client/http_backend/configuration.rb', line 20 def stats_path path(riak_kv_wm_stats) end |