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

Instance Method Details

#bucket_list_path(options = {}) ⇒ URI

Returns a URL path for the “buckets list” resource.

Returns:

  • (URI)

    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(options={})
  if new_scheme?
    path(riak_kv_wm_buckets, options.merge(:buckets => true))
  else
    path(riak_kv_wm_raw, options.merge(:buckets => true))
  end
end

#bucket_properties_path(bucket, options = {}) ⇒ URI

Returns a URL path for the “bucket properties” resource.

Parameters:

  • bucket (String)

    the bucket name

Returns:

  • (URI)

    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, options={})
  if new_scheme?
    path(riak_kv_wm_buckets, escape(bucket), "props", options)
  else
    path(riak_kv_wm_raw, escape(bucket), options.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.

Parameters:

  • bucket (String)

    the bucket whose index to query

  • index (String)

    the name of the index to query

  • start (String, Integer)

    the start of the range

  • finish (String, Integer)

    the end of the range

Returns:

  • (URI)

    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, options={})
  raise t('indexes_unsupported') unless new_scheme?
  path(riak_kv_wm_buckets, escape(bucket), "index", escape(index), escape(value.to_s), options)
end

#index_range_path(bucket, index, start, finish, options = {}) ⇒ URI

Returns a URL path for the “index range query” resource.

Parameters:

  • bucket (String)

    the bucket whose index to query

  • index (String)

    the name of the index to query

  • start (String, Integer)

    the start of the range

  • finish (String, Integer)

    the end of the range

Returns:

  • (URI)

    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, options={})
  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), options)
end

#key_list_path(bucket, options = {:keys => true}) ⇒ URI

Returns a URL path for the “list keys” resource.

Parameters:

  • bucket (String)

    the bucket whose keys to list

  • options (Hash) (defaults to: {:keys => true})

    query parameters, e.g. keys=stream

Returns:

  • (URI)

    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, options={:keys => true})
  if new_scheme?
    path(riak_kv_wm_buckets, escape(bucket), "keys", options)
  else
    path(riak_kv_wm_raw, escape(bucket), options.merge(:props => false))
  end
end

Returns a URL path for the “link-walking” resource.

Parameters:

  • bucket (String)

    the bucket of the origin object

  • key (String)

    the key of the origin object

  • specs (Array<WalkSpec>)

    a list of walk specifications to traverse

Returns:

  • (URI)

    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.

Returns:

  • (URI)

    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.

Parameters:

  • options (Hash) (defaults to: {})

    query parameters, e.g. chunked=true

Returns:

  • (URI)

    a URL path to the “mapred” resource



26
27
28
# File 'lib/riak/client/http_backend/configuration.rb', line 26

def mapred_path(options={})
  path(riak_kv_wm_mapred, options)
end

#object_path(bucket, key, options = {}) ⇒ URI

Returns a URL path for the “object” resource.

Parameters:

  • bucket (String)

    the bucket of the object

  • key (String, nil)

    the key of the object, or nil for a server-assigned key when using POST

Returns:

  • (URI)

    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, options={})
  key = escape(key) if key
  if new_scheme?
    path([riak_kv_wm_buckets, escape(bucket), "keys", key, options].compact)
  else
    path([riak_kv_wm_raw, escape(bucket), key, options].compact)
  end
end

#ping_pathURI

Returns a URL path to the “ping” resource.

Returns:

  • (URI)

    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.

Parameters:

  • index (String)

    the index to query

  • query (String)

    the Lucene-style query string

  • options (Hash) (defaults to: {})

    additional query options

Returns:

  • (URI)

    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, options={})
  raise t('search_unsupported') unless riak_solr_searcher_wm
  options = {"q" => query, "wt" => "json"}.merge(options)
  if index
    path(riak_solr_searcher_wm, index, 'select', options)
  else
    path(riak_solr_searcher_wm, 'select', options)
  end
end

#solr_update_path(index) ⇒ URI

Returns a URL path for a Solr update resource.

Parameters:

  • index (String)

    the index to update

Returns:

  • (URI)

    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_pathURI

Returns a URL path to the “stats” resource.

Returns:

  • (URI)

    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