elastomer-client 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (36) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/CHANGELOG.md +4 -0
  4. data/lib/elastomer/client/bulk.rb +1 -1
  5. data/lib/elastomer/client/cluster.rb +10 -22
  6. data/lib/elastomer/client/docs.rb +46 -55
  7. data/lib/elastomer/client/index.rb +33 -33
  8. data/lib/elastomer/client/multi_percolate.rb +9 -9
  9. data/lib/elastomer/client/multi_search.rb +5 -5
  10. data/lib/elastomer/client/native_delete_by_query.rb +2 -22
  11. data/lib/elastomer/client/nodes.rb +8 -22
  12. data/lib/elastomer/client/percolator.rb +5 -5
  13. data/lib/elastomer/client/repository.rb +7 -7
  14. data/lib/elastomer/client/rest_api_spec/api_spec.rb +119 -0
  15. data/lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb +2232 -0
  16. data/lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb +2250 -0
  17. data/lib/elastomer/client/rest_api_spec/api_spec_v5_6.rb +2491 -0
  18. data/lib/elastomer/client/rest_api_spec/rest_api.rb +59 -0
  19. data/lib/elastomer/client/rest_api_spec.rb +44 -0
  20. data/lib/elastomer/client/scroller.rb +10 -10
  21. data/lib/elastomer/client/snapshot.rb +7 -7
  22. data/lib/elastomer/client/tasks.rb +45 -51
  23. data/lib/elastomer/client/template.rb +8 -8
  24. data/lib/elastomer/client/warmer.rb +11 -4
  25. data/lib/elastomer/client.rb +31 -7
  26. data/lib/elastomer/version.rb +1 -1
  27. data/lib/elastomer/version_support.rb +35 -46
  28. data/script/generate-rest-api-spec +152 -0
  29. data/test/client/rest_api_spec/api_spec_test.rb +55 -0
  30. data/test/client/rest_api_spec/rest_api_test.rb +96 -0
  31. data/test/client/stubbed_client_test.rb +1 -19
  32. data/test/middleware/opaque_id_test.rb +1 -3
  33. data/test/notifications_test.rb +0 -5
  34. data/test/test_helper.rb +5 -4
  35. data/test/version_support_test.rb +3 -21
  36. metadata +13 -2
@@ -2,21 +2,6 @@ module Elastomer
2
2
  # VersionSupport holds methods that (a) encapsulate version differences; or
3
3
  # (b) give an intention-revealing name to a conditional check.
4
4
  class VersionSupport
5
- COMMON_INDEXING_PARAMETER_NAMES = %i[
6
- index
7
- type
8
- id
9
- version
10
- version_type
11
- op_type
12
- routing
13
- parent
14
- refresh
15
- ].freeze
16
- ES_2_X_INDEXING_PARAMETER_NAMES = %i[consistency ttl timestamp].freeze
17
- ES_5_X_INDEXING_PARAMETER_NAMES = %i[wait_for_active_shards].freeze
18
- KNOWN_INDEXING_PARAMETER_NAMES =
19
- (COMMON_INDEXING_PARAMETER_NAMES + ES_2_X_INDEXING_PARAMETER_NAMES + ES_5_X_INDEXING_PARAMETER_NAMES).freeze
20
5
 
21
6
  attr_reader :version
22
7
 
@@ -43,6 +28,18 @@ module Elastomer
43
28
  es_version_5_x?
44
29
  end
45
30
 
31
+ # COMPATIBILITY: Return a boolean indicating if this version supports the
32
+ # `tasks.get` API - https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html
33
+ def supports_tasks_get?
34
+ es_version_5_x?
35
+ end
36
+
37
+ # COMPATIBILITY: Return a boolean indicating if this version supports the
38
+ # `parent_task_id` param in the tasks API - https://www.elastic.co/guide/en/elasticsearch/reference/5.x/tasks.html
39
+ def supports_parent_task_id?
40
+ es_version_5_x?
41
+ end
42
+
46
43
  # COMPATIBILITY: Return a "text"-type mapping for a field.
47
44
  #
48
45
  # On ES 2.x, this will be a string field. On ES 5+, it will be a text field.
@@ -78,7 +75,18 @@ module Elastomer
78
75
  {enabled: b}
79
76
  else
80
77
  b
81
- end
78
+ end
79
+ end
80
+
81
+ # COMPATIBILITY: handle _op_type -> op_type request param conversion for put-if-absent bnehavior
82
+ # Returns the (possibly mutated) params hash supplied by the caller.
83
+ #
84
+ # https://www.elastic.co/guide/en/elasticsearch/reference/current/docs-index_.html#operation-type
85
+ def op_type(params = {})
86
+ if es_version_5_x? && (params.key?(:_op_type) || params.key?("_op_type"))
87
+ params[:op_type] = params.delete(:_op_type)
88
+ end
89
+ params
82
90
  end
83
91
 
84
92
  # Elasticsearch 2.0 changed some request formats in a non-backward-compatible
@@ -124,34 +132,22 @@ module Elastomer
124
132
  end
125
133
 
126
134
  # COMPATIBILITY
127
- # ES 5.X supports `delete_by_query` natively again.
128
- alias :native_delete_by_query? :es_version_5_x?
135
+ #
136
+ # ES5 doesn't accept/ignore ambiguous or unexpected req params any more
137
+ alias :strict_request_params? :es_version_5_x?
129
138
 
130
139
  # COMPATIBILITY
131
- # Return a Hash of indexing request parameters that are valid for this
132
- # version of Elasticsearch.
133
- def indexing_directives
134
- return @indexing_directives if defined?(@indexing_directives)
135
-
136
- @indexing_directives = indexing_parameter_names.each_with_object({}) do |key, h|
137
- h[key] = "_#{key}"
138
- end
139
- @indexing_directives.freeze
140
- end
140
+ # ES 5.X supports `delete_by_query` natively again.
141
+ alias :native_delete_by_query? :es_version_5_x?
141
142
 
142
143
  # COMPATIBILITY
143
- # Return a Hash of indexing request parameters that are known to
144
- # elastomer-client, but not supported by the current version of
145
- # Elasticsearch.
146
- def unsupported_indexing_directives
147
- return @unsupported_indexing_directives if defined?(@unsupported_indexing_directives)
148
-
149
- unsupported_keys = KNOWN_INDEXING_PARAMETER_NAMES - indexing_parameter_names
150
-
151
- @unsupported_indexing_directives = unsupported_keys.each_with_object({}) do |key, h|
152
- h[key] = "_#{key}"
144
+ # Internal: VersionSupport maintains dynamically-created lists of acceptable and unacceptable
145
+ # request params by ES version. This just shims that list since those params have leading
146
+ # underscores by default. If we end up with >1 such param, let's make a real thing to handle this.
147
+ def fix_op_type!(params = {})
148
+ if es_version_5_x? && params.key?(:op_type)
149
+ params[:op_type] = "op_type"
153
150
  end
154
- @unsupported_indexing_directives.freeze
155
151
  end
156
152
 
157
153
  # COMPATIBILITY
@@ -177,12 +173,5 @@ module Elastomer
177
173
  end
178
174
  end
179
175
 
180
- def indexing_parameter_names
181
- if es_version_2_x?
182
- COMMON_INDEXING_PARAMETER_NAMES + ES_2_X_INDEXING_PARAMETER_NAMES
183
- else
184
- COMMON_INDEXING_PARAMETER_NAMES + ES_5_X_INDEXING_PARAMETER_NAMES
185
- end
186
- end
187
176
  end
188
177
  end
@@ -0,0 +1,152 @@
1
+ #!/usr/bin/env ruby
2
+ # Usage:
3
+ #
4
+ # script/generate-rest-api-spec <elasticsearch-version>
5
+ #
6
+ # Use this script to generate a REST API spec for the given
7
+ # `elasticserach-version`. This will create a new `ApiSpec` class configured
8
+ # to validate the request parameters for the particular Elasticsearch version.
9
+
10
+ require "erb"
11
+ require "rubygems"
12
+ require "bundler/setup"
13
+
14
+ $LOAD_PATH.unshift "lib"
15
+ require "elastomer/client"
16
+
17
+ class RestApiSpecGenerator
18
+ WORKING_DIR = "vendor/elasticsearch"
19
+
20
+ attr_reader :version, :short_version, :class_version
21
+
22
+ def initialize(version = "5.6")
23
+ @version = version
24
+
25
+ sliced = @version.split(".").slice(0,2)
26
+ @short_version = sliced.join(".")
27
+ @class_version = sliced.join("_")
28
+ end
29
+
30
+ # Setup the working directory and generate the Ruby API spec for the
31
+ # elasticsearch version.
32
+ def run
33
+ setup
34
+ File.open(ruby_spec_filename, "w") do |fd|
35
+ fd.puts ERB.new(DATA.read, 0, "-").result(binding)
36
+ end
37
+ ensure
38
+ reset
39
+ end
40
+
41
+ # The name of the Ruby API spec file for this particular Elasticsearch version.
42
+ def ruby_spec_filename
43
+ "lib/elastomer/client/rest_api_spec/api_spec_v#{class_version}.rb"
44
+ end
45
+
46
+ # Returns true if the elasticserach working directory exists.
47
+ def working_dir_exists?
48
+ File.directory?(WORKING_DIR) && File.exists?(WORKING_DIR)
49
+ end
50
+
51
+ # Iterate over each of the REST API specs yield the name and the descriptor
52
+ # hash for that particular API spec.
53
+ def each_api
54
+ Dir.glob("#{WORKING_DIR}/rest-api-spec/src/main/resources/rest-api-spec/api/*.json").each do |filename|
55
+ next if filename =~ /\/_common\.json\Z/
56
+
57
+ hash = MultiJson.load(File.read(filename))
58
+ key = hash.keys.first
59
+ value = hash.values.first
60
+ yield(key, value)
61
+ end
62
+ end
63
+
64
+ # Iterate over each of the common request parameters and yield them as key /
65
+ # value pairs.
66
+ def each_common
67
+ filename = "#{WORKING_DIR}/rest-api-spec/src/main/resources/rest-api-spec/api/_common.json"
68
+ if File.exists? filename
69
+ hash = MultiJson.load(File.read(filename))
70
+ hash["params"].each {|k,v| yield(k,v)}
71
+ end
72
+ end
73
+
74
+ # Perform a sparse checkout of the elasticsearch git repository and then check
75
+ # out the branch corresponding to the ES version passed to this script.
76
+ def setup
77
+ if !working_dir_exists?
78
+ system <<-SH
79
+ mkdir -p #{WORKING_DIR} &&
80
+ cd #{WORKING_DIR} &&
81
+ git init . &&
82
+ git remote add -f origin https://github.com/elastic/elasticsearch.git &&
83
+ git config core.sparsecheckout true &&
84
+ echo /rest-api-spec/src/main/resources/rest-api-spec/api/ >> .git/info/sparse-checkout &&
85
+ git pull origin master
86
+ SH
87
+ end
88
+
89
+ system <<-SH
90
+ cd #{WORKING_DIR} &&
91
+ git pull origin master &&
92
+ git checkout -q origin/#{short_version}
93
+ SH
94
+ end
95
+
96
+ # Reset the elasticsearch working directory back to the master branch of the
97
+ # git repository.
98
+ def reset
99
+ system <<-SH
100
+ cd #{WORKING_DIR} &&
101
+ git checkout master
102
+ SH
103
+ end
104
+ end
105
+
106
+ puts RestApiSpecGenerator.new(*ARGV).run
107
+
108
+ __END__
109
+ # Generated REST API spec file - DO NOT EDIT!
110
+ # Date: <%= Time.now.strftime("%Y-%m-%d") %>
111
+ # ES version: <%= version %>
112
+
113
+ module Elastomer::Client::RestApiSpec
114
+ class ApiSpecV<%= class_version %> < ApiSpec
115
+ def initialize
116
+ @rest_apis = {
117
+ <% each_api do |name,data| -%>
118
+ "<%= name %>" => RestApi.new(
119
+ documentation: "<%= data["documentation"].to_s %>",
120
+ methods: <%= Array(data["methods"]).to_s %>,
121
+ body: <%= data["body"] ? data["body"].to_s : "nil" %>,
122
+ <% url = data["url"] -%>
123
+ url: {
124
+ path: "<%= url["path"] %>",
125
+ paths: <%= Array(url["paths"]).to_s %>,
126
+ <% if (parts = url["parts"]) && !parts.empty? -%>
127
+ parts: {
128
+ <% parts.each do |k,v| -%>
129
+ "<%= k %>" => <%= v.to_s %>,
130
+ <% end -%>
131
+ },
132
+ <% end -%>
133
+ <% if (params = url["params"]) && !params.empty? -%>
134
+ params: {
135
+ <% params.each do |k,v| -%>
136
+ "<%= k %>" => <%= v.to_s %>,
137
+ <% end -%>
138
+ }
139
+ <% end -%>
140
+ }
141
+ ),
142
+ <% end -%>
143
+ }
144
+ @common_params = {
145
+ <% each_common do |k,v| -%>
146
+ "<%= k %>" => <%= v.to_s %>,
147
+ <% end -%>
148
+ }
149
+ super
150
+ end
151
+ end
152
+ end
@@ -0,0 +1,55 @@
1
+ require_relative "../../test_helper"
2
+
3
+ describe Elastomer::Client::RestApiSpec::ApiSpec do
4
+ before do
5
+ @api_spec = Elastomer::Client::RestApiSpec.api_spec("5.6.4")
6
+ end
7
+
8
+ it "selects valid path parts" do
9
+ parts = {index: "test", "type" => "doc", foo: "bar"}
10
+ result = @api_spec.select_parts(api: "search", from: parts)
11
+
12
+ assert_equal({index: "test", "type" => "doc"}, result)
13
+ end
14
+
15
+ it "identifies valid path parts" do
16
+ assert @api_spec.valid_part?(api: "search", part: "index")
17
+ assert @api_spec.valid_part?(api: "search", part: :type)
18
+ refute @api_spec.valid_part?(api: "search", part: :id)
19
+ end
20
+
21
+ it "selects valid request params" do
22
+ params = {explain: true, "preference" => "local", nope: "invalid"}
23
+ result = @api_spec.select_params(api: "search", from: params)
24
+
25
+ assert_equal({explain: true, "preference" => "local"}, result)
26
+ end
27
+
28
+ it "identifies valid request params" do
29
+ assert @api_spec.valid_param?(api: "search", param: "explain")
30
+ assert @api_spec.valid_param?(api: "search", param: :preference)
31
+ assert @api_spec.valid_param?(api: "search", param: :routing)
32
+ refute @api_spec.valid_param?(api: "search", param: "pretty")
33
+ end
34
+
35
+ it "selects common request params" do
36
+ params = {pretty: true, "human" => true, nope: "invalid"}
37
+ result = @api_spec.select_common_params(from: params)
38
+
39
+ assert_equal({pretty: true, "human" => true}, result)
40
+ end
41
+
42
+ it "identifies common request params" do
43
+ assert @api_spec.valid_common_param?("pretty")
44
+ assert @api_spec.valid_common_param?(:human)
45
+ assert @api_spec.valid_common_param?(:source)
46
+ refute @api_spec.valid_common_param?("nope")
47
+ end
48
+
49
+ it "validates request params" do
50
+ assert_raises(Elastomer::Client::IllegalArgument, "'nope' is not a valid parameter for the 'search' API") {
51
+ params = {q: "*:*", pretty: true, "nope": false}
52
+ @api_spec.validate_params!(api: "search", params: params)
53
+ }
54
+ end
55
+ end
@@ -0,0 +1,96 @@
1
+ require_relative "../../test_helper"
2
+
3
+ describe Elastomer::Client::RestApiSpec::RestApi do
4
+ before do
5
+ @rest_api = Elastomer::Client::RestApiSpec::RestApi.new \
6
+ documentation: "https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-state.html",
7
+ methods: ["GET"],
8
+ body: nil,
9
+ url: {
10
+ path: "/_cluster/state",
11
+ paths: ["/_cluster/state", "/_cluster/state/{metric}", "/_cluster/state/{metric}/{index}"],
12
+ parts: {
13
+ "index" => {"type"=>"list", "description"=>"A comma-separated list of index names; use `_all` or empty string to perform the operation on all indices"},
14
+ "metric" => {"type"=>"list", "options"=>["_all", "blocks", "metadata", "nodes", "routing_table", "routing_nodes", "master_node", "version"], "description"=>"Limit the information returned to the specified metrics"},
15
+ },
16
+ params: {
17
+ "local" => {"type"=>"boolean", "description"=>"Return local information, do not retrieve the state from master node (default: false)"},
18
+ "master_timeout" => {"type"=>"time", "description"=>"Specify timeout for connection to master"},
19
+ "flat_settings" => {"type"=>"boolean", "description"=>"Return settings in flat format (default: false)"},
20
+ "ignore_unavailable" => {"type"=>"boolean", "description"=>"Whether specified concrete indices should be ignored when unavailable (missing or closed)"},
21
+ "allow_no_indices" => {"type"=>"boolean", "description"=>"Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified)"},
22
+ "expand_wildcards" => {"type"=>"enum", "options"=>["open", "closed", "none", "all"], "default"=>"open", "description"=>"Whether to expand wildcard expression to concrete indices that are open, closed or both."},
23
+ }
24
+ }
25
+ end
26
+
27
+ it "selects valid path parts" do
28
+ hash = {
29
+ index: "test",
30
+ "metric" => "os",
31
+ nope: "not selected"
32
+ }
33
+ selected = @rest_api.select_parts(from: hash)
34
+
35
+ refute selected.key?(:nope)
36
+ assert selected.key?(:index)
37
+ assert selected.key?("metric")
38
+ end
39
+
40
+ it "identifies valid parts" do
41
+ assert @rest_api.valid_part? :index
42
+ assert @rest_api.valid_part? "metric"
43
+ refute @rest_api.valid_part? :nope
44
+ end
45
+
46
+ it "selects valid request params" do
47
+ hash = {
48
+ local: true,
49
+ "flat_settings" => true,
50
+ expand_wildcards: "all",
51
+ nope: "not selected"
52
+ }
53
+ selected = @rest_api.select_params(from: hash)
54
+
55
+ refute selected.key?(:nope)
56
+ assert selected.key?(:local)
57
+ assert selected.key?("flat_settings")
58
+ assert selected.key?(:expand_wildcards)
59
+ end
60
+
61
+ it "identifies valid params" do
62
+ assert @rest_api.valid_param? :local
63
+ assert @rest_api.valid_param? "flat_settings"
64
+ refute @rest_api.valid_param? :nope
65
+ end
66
+
67
+ it "accesses the documentation url" do
68
+ assert_equal "https://www.elastic.co/guide/en/elasticsearch/reference/5.x/cluster-state.html", @rest_api.documentation
69
+ end
70
+
71
+ it "exposes the HTTP methods as an Array" do
72
+ assert_equal %w[GET], @rest_api.methods
73
+ end
74
+
75
+ it "accesses the body settings" do
76
+ assert_nil @rest_api.body
77
+ end
78
+
79
+ describe "accessing the url" do
80
+ it "accesses the path" do
81
+ assert_equal "/_cluster/state", @rest_api.url.path
82
+ end
83
+
84
+ it "exposes the paths as an Array" do
85
+ assert_equal %w[/_cluster/state /_cluster/state/{metric} /_cluster/state/{metric}/{index}], @rest_api.url.paths
86
+ end
87
+
88
+ it "accesses the path parts" do
89
+ assert_equal %w[index metric], @rest_api.url.parts.keys
90
+ end
91
+
92
+ it "accesses the request params" do
93
+ assert_equal %w[local master_timeout flat_settings ignore_unavailable allow_no_indices expand_wildcards], @rest_api.url.params.keys
94
+ end
95
+ end
96
+ end
@@ -4,6 +4,7 @@ describe "stubbed client tests" do
4
4
  before do
5
5
  @stubs = Faraday::Adapter.lookup_middleware(:test)::Stubs.new
6
6
  @client = Elastomer::Client.new :adapter => [:test, @stubs]
7
+ @client.instance_variable_set(:@version, "5.6.4")
7
8
  end
8
9
 
9
10
  describe Elastomer::Client::Cluster do
@@ -17,24 +18,5 @@ describe "stubbed client tests" do
17
18
  h = @client.cluster.reroute commands, :dry_run => true
18
19
  assert_acknowledged h
19
20
  end
20
-
21
- it "performs a shutdown of the cluster" do
22
- @stubs.post("/_shutdown") { [200, {"Content-Type" => "application/json"}, '{"cluster_name":"elasticsearch"}'] }
23
- h = @client.cluster.shutdown
24
- assert_equal "elasticsearch", h["cluster_name"]
25
- end
26
- end
27
-
28
- describe Elastomer::Client::Nodes do
29
- it "performs a shutdown of the node(s)" do
30
- @stubs.post("/_cluster/nodes/_all/_shutdown") { [200, {"Content-Type" => "application/json"}, '{"nodes":{"1":{"name":"Node1"}}}'] }
31
- @stubs.post("/_cluster/nodes/node2/_shutdown") { [200, {"Content-Type" => "application/json"}, '{"nodes":{"2":{"name":"Node2"}}}'] }
32
-
33
- h = @client.nodes("_all").shutdown
34
- assert_equal "Node1", h["nodes"]["1"]["name"]
35
-
36
- h = @client.nodes("node2").shutdown
37
- assert_equal "Node2", h["nodes"]["2"]["name"]
38
- end
39
21
  end
40
22
  end
@@ -15,9 +15,6 @@ describe Elastomer::Middleware::OpaqueId do
15
15
  ]
16
16
  }
17
17
 
18
- stub.get("/") { |env|
19
- [ 200, {}, {"version" => {"number" => "1.0.0"}} ]
20
- }
21
18
  stub.get("/_cluster/state") { |env|
22
19
  [ 200, {"X-Opaque-Id" => "00000000-0000-0000-0000-000000000000"}, %q[{"foo":"bar"}] ]
23
20
  }
@@ -28,6 +25,7 @@ describe Elastomer::Middleware::OpaqueId do
28
25
  :adapter => [:test, stubs]
29
26
 
30
27
  @client = Elastomer::Client.new opts
28
+ @client.instance_variable_set(:@version, "5.6.4")
31
29
  end
32
30
 
33
31
  it 'generates an "X-Opaque-Id" header' do
@@ -39,11 +39,6 @@ describe Elastomer::Notifications do
39
39
  nodes.hot_threads; assert_action_event("nodes.hot_threads")
40
40
  end
41
41
 
42
- it "instruments node shutdown" do
43
- client = stub_client(:post, "/_cluster/nodes/_shutdown")
44
- client.nodes.shutdown; assert_action_event("nodes.shutdown")
45
- end
46
-
47
42
  it "instruments index actions" do
48
43
  @index.exists?; assert_action_event("index.exists")
49
44
  @index.create(default_index_settings)
data/test/test_helper.rb CHANGED
@@ -30,10 +30,11 @@ require "elastomer/client"
30
30
  # we are going to use the same client instance everywhere!
31
31
  # the client should always be stateless
32
32
  $client_params = {
33
- :port => ENV.fetch("ES_PORT", 9200),
34
- :read_timeout => 10,
35
- :open_timeout => 1,
36
- :opaque_id => false
33
+ port: ENV.fetch("ES_PORT", 9200),
34
+ read_timeout: 10,
35
+ open_timeout: 1,
36
+ opaque_id: false,
37
+ strict_params: true
37
38
  }
38
39
  $client = Elastomer::Client.new $client_params
39
40
 
@@ -61,18 +61,6 @@ describe Elastomer::VersionSupport do
61
61
  refute version_support.native_delete_by_query?, "ES 2.X does not have native delete_by_query support"
62
62
  end
63
63
  end
64
-
65
- describe "#indexing_directives" do
66
- it "returns a Hash of indexing parameter name to field name" do
67
- assert_includes(version_support.indexing_directives.to_a, [:consistency, "_consistency"])
68
- end
69
- end
70
-
71
- describe "#unsupported_indexing_directives" do
72
- it "returns a Hash of indexing parameter name to field name" do
73
- assert_includes(version_support.unsupported_indexing_directives.to_a, [:wait_for_active_shards, "_wait_for_active_shards"])
74
- end
75
- end
76
64
  end
77
65
 
78
66
  describe "ES 5.x" do
@@ -104,15 +92,9 @@ describe Elastomer::VersionSupport do
104
92
  end
105
93
  end
106
94
 
107
- describe "#indexing_directives" do
108
- it "returns a Hash of indexing parameter name to field name" do
109
- assert_includes(version_support.indexing_directives.to_a, [:wait_for_active_shards, "_wait_for_active_shards"])
110
- end
111
- end
112
-
113
- describe "#unsupported_indexing_directives" do
114
- it "returns an Hash of indexing parameter names to field name" do
115
- assert_includes(version_support.unsupported_indexing_directives.to_a, [:consistency, "_consistency"])
95
+ describe "#op_type_param" do
96
+ it "converts the supplied params key _op_type to op_type, if present" do
97
+ assert_equal(version_support.op_type(_op_type: "create"), {op_type: "create"})
116
98
  end
117
99
  end
118
100
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elastomer-client
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.0.1
4
+ version: 3.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Tim Pease
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2017-12-20 00:00:00.000000000 Z
12
+ date: 2018-01-20 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: addressable
@@ -249,6 +249,12 @@ files:
249
249
  - lib/elastomer/client/nodes.rb
250
250
  - lib/elastomer/client/percolator.rb
251
251
  - lib/elastomer/client/repository.rb
252
+ - lib/elastomer/client/rest_api_spec.rb
253
+ - lib/elastomer/client/rest_api_spec/api_spec.rb
254
+ - lib/elastomer/client/rest_api_spec/api_spec_v2_3.rb
255
+ - lib/elastomer/client/rest_api_spec/api_spec_v2_4.rb
256
+ - lib/elastomer/client/rest_api_spec/api_spec_v5_6.rb
257
+ - lib/elastomer/client/rest_api_spec/rest_api.rb
252
258
  - lib/elastomer/client/scroller.rb
253
259
  - lib/elastomer/client/snapshot.rb
254
260
  - lib/elastomer/client/tasks.rb
@@ -268,6 +274,7 @@ files:
268
274
  - script/cibuild-elastomer-client-es24
269
275
  - script/cibuild-elastomer-client-es56
270
276
  - script/console
277
+ - script/generate-rest-api-spec
271
278
  - script/poll-for-es
272
279
  - test/assertions.rb
273
280
  - test/client/app_delete_by_query_test.rb
@@ -283,6 +290,8 @@ files:
283
290
  - test/client/nodes_test.rb
284
291
  - test/client/percolator_test.rb
285
292
  - test/client/repository_test.rb
293
+ - test/client/rest_api_spec/api_spec_test.rb
294
+ - test/client/rest_api_spec/rest_api_test.rb
286
295
  - test/client/scroller_test.rb
287
296
  - test/client/snapshot_test.rb
288
297
  - test/client/stubbed_client_test.rb
@@ -336,6 +345,8 @@ test_files:
336
345
  - test/client/nodes_test.rb
337
346
  - test/client/percolator_test.rb
338
347
  - test/client/repository_test.rb
348
+ - test/client/rest_api_spec/api_spec_test.rb
349
+ - test/client/rest_api_spec/rest_api_test.rb
339
350
  - test/client/scroller_test.rb
340
351
  - test/client/snapshot_test.rb
341
352
  - test/client/stubbed_client_test.rb