elasticsearch-api 2.0.2 → 5.0.0.pre

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 (66) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +11 -8
  3. data/elasticsearch-api.gemspec +1 -1
  4. data/lib/elasticsearch/api/actions/bulk.rb +20 -18
  5. data/lib/elasticsearch/api/actions/cat/aliases.rb +7 -1
  6. data/lib/elasticsearch/api/actions/cat/allocation.rb +3 -1
  7. data/lib/elasticsearch/api/actions/cat/count.rb +3 -1
  8. data/lib/elasticsearch/api/actions/cat/fielddata.rb +2 -0
  9. data/lib/elasticsearch/api/actions/cat/health.rb +3 -1
  10. data/lib/elasticsearch/api/actions/cat/indices.rb +8 -3
  11. data/lib/elasticsearch/api/actions/cat/master.rb +3 -1
  12. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +4 -6
  13. data/lib/elasticsearch/api/actions/cat/nodes.rb +3 -1
  14. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +3 -1
  15. data/lib/elasticsearch/api/actions/cat/plugins.rb +4 -3
  16. data/lib/elasticsearch/api/actions/cat/recovery.rb +3 -1
  17. data/lib/elasticsearch/api/actions/cat/repositories.rb +3 -4
  18. data/lib/elasticsearch/api/actions/cat/segments.rb +5 -3
  19. data/lib/elasticsearch/api/actions/cat/shards.rb +3 -1
  20. data/lib/elasticsearch/api/actions/cat/snapshots.rb +4 -5
  21. data/lib/elasticsearch/api/actions/cat/tasks.rb +4 -6
  22. data/lib/elasticsearch/api/actions/cat/templates.rb +39 -0
  23. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +6 -4
  24. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +6 -5
  25. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +0 -3
  26. data/lib/elasticsearch/api/actions/cluster/health.rb +7 -1
  27. data/lib/elasticsearch/api/actions/cluster/reroute.rb +0 -3
  28. data/lib/elasticsearch/api/actions/delete_by_query.rb +0 -2
  29. data/lib/elasticsearch/api/actions/explain.rb +3 -1
  30. data/lib/elasticsearch/api/actions/get.rb +3 -1
  31. data/lib/elasticsearch/api/actions/index.rb +0 -3
  32. data/lib/elasticsearch/api/actions/indices/create.rb +3 -1
  33. data/lib/elasticsearch/api/actions/indices/get.rb +0 -3
  34. data/lib/elasticsearch/api/actions/indices/get_settings.rb +0 -3
  35. data/lib/elasticsearch/api/actions/indices/put_settings.rb +0 -3
  36. data/lib/elasticsearch/api/actions/indices/rollover.rb +41 -0
  37. data/lib/elasticsearch/api/actions/indices/shrink.rb +45 -0
  38. data/lib/elasticsearch/api/actions/indices/stats.rb +2 -2
  39. data/lib/elasticsearch/api/actions/indices/validate_query.rb +1 -5
  40. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +1 -5
  41. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +2 -7
  42. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +1 -5
  43. data/lib/elasticsearch/api/actions/ingest/simulate.rb +3 -6
  44. data/lib/elasticsearch/api/actions/mget.rb +3 -1
  45. data/lib/elasticsearch/api/actions/nodes/info.rb +2 -1
  46. data/lib/elasticsearch/api/actions/ping.rb +1 -1
  47. data/lib/elasticsearch/api/actions/scroll.rb +3 -9
  48. data/lib/elasticsearch/api/actions/search.rb +7 -0
  49. data/lib/elasticsearch/api/actions/search_exists.rb +1 -3
  50. data/lib/elasticsearch/api/actions/snapshot/get.rb +2 -0
  51. data/lib/elasticsearch/api/actions/snapshot/status.rb +2 -0
  52. data/lib/elasticsearch/api/actions/tasks/list.rb +0 -3
  53. data/lib/elasticsearch/api/actions/update.rb +7 -0
  54. data/lib/elasticsearch/api/actions/update_by_query.rb +0 -3
  55. data/lib/elasticsearch/api/utils.rb +6 -6
  56. data/lib/elasticsearch/api/version.rb +1 -1
  57. data/test/integration/yaml_test_runner.rb +44 -11
  58. data/test/unit/cat/templates_test.rb +26 -0
  59. data/test/unit/indices/rollover_test.rb +38 -0
  60. data/test/unit/indices/shrink_test.rb +33 -0
  61. data/test/unit/ingest/get_pipeline_test.rb +0 -6
  62. data/test/unit/search_exists_test.rb +0 -32
  63. data/utils/thor/generate_source.rb +12 -0
  64. data/utils/thor/templates/ruby/method.erb +5 -9
  65. data/utils/thor/templates/ruby/test.erb +3 -3
  66. metadata +14 -5
@@ -7,12 +7,6 @@ module Elasticsearch
7
7
  context "Ingest: Get pipeline" do
8
8
  subject { FakeClient.new }
9
9
 
10
- should "require the :id argument" do
11
- assert_raise ArgumentError do
12
- subject.ingest.get_pipeline
13
- end
14
- end
15
-
16
10
  should "perform correct request" do
17
11
  subject.expects(:perform_request).with do |method, url, params, body|
18
12
  assert_equal 'GET', method
@@ -19,38 +19,6 @@ module Elasticsearch
19
19
  subject.search_exists :q => 'foo'
20
20
  end
21
21
 
22
- should "perform request against an index" do
23
- subject.expects(:perform_request).with do |method, url, params, body|
24
- assert_equal 'POST', method
25
- assert_equal 'books/_search/exists', url
26
- assert_nil body
27
- true
28
- end.returns(FakeResponse.new)
29
-
30
- subject.search_exists :index => 'books'
31
- end
32
-
33
- should "perform request against an index and type" do
34
- subject.expects(:perform_request).with do |method, url, params, body|
35
- assert_equal 'POST', method
36
- assert_equal 'books/holly/_search/exists', url
37
- assert_nil body
38
- true
39
- end.returns(FakeResponse.new)
40
-
41
- subject.search_exists :index => 'books', :type => 'holly'
42
- end
43
-
44
- should "perform request against default index if type given" do
45
- subject.expects(:perform_request).with do |method, url, params, body|
46
- assert_equal 'POST', method
47
- assert_equal '_all/holly/_search/exists', url
48
- assert_nil body
49
- true
50
- end.returns(FakeResponse.new)
51
-
52
- subject.search_exists :type => 'holly'
53
- end
54
22
  end
55
23
 
56
24
  end
@@ -62,6 +62,18 @@ module Elasticsearch
62
62
  @namespace_depth = @full_namespace.size > 0 ? @full_namespace.size-1 : 0
63
63
  @module_namespace = @full_namespace[0, @namespace_depth]
64
64
  @method_name = @full_namespace.last
65
+ @http_method = "HTTP_#{@spec['methods'].first}"
66
+ @http_path = unless @spec['url']['parts'].empty?
67
+ @spec['url']['path']
68
+ .split('/')
69
+ .compact
70
+ .reject { |p| p =~ /^\s*$/ }
71
+ .map { |p| p =~ /\{/ ? "\#\{arguments[:#{p.tr('{}', '')}]\}" : p }
72
+ .join('/')
73
+ .gsub(/^\//, '')
74
+ else
75
+ @spec['url']['path'].gsub(/^\//, '')
76
+ end
65
77
 
66
78
  # -- Ruby files
67
79
 
@@ -1,7 +1,7 @@
1
1
  module Elasticsearch
2
2
  module API
3
3
  <%- @module_namespace.each_with_index do |name, i| -%>
4
- <%= ' '*i %>module <%= name.capitalize %>
4
+ <%= ' '*i %>module <%= name == 'xpack' ? 'XPack' : name.capitalize %>
5
5
  <%- end -%>
6
6
  <%= ' '*@namespace_depth %>module Actions
7
7
 
@@ -35,17 +35,13 @@ module Elasticsearch
35
35
  <%= ' '*(@namespace_depth+1) + "raise ArgumentError, \"Required argument 'body' missing\" unless arguments[:body]" + "\n" -%>
36
36
  <%- end -%>
37
37
  <%# Method, path, params, body -%>
38
+ <%- unless @spec['url']['params'].empty? -%>
38
39
  <%= ' '*@namespace_depth %> valid_params = [
39
40
  <%= ' '*(@namespace_depth+2) %><%= @spec['url']['params'].keys.map { |k| ":#{k}" }.join(",\n#{' '*(@namespace_depth+5)}") %> ]
40
- <%= ' '*@namespace_depth %> method = '<%= @spec['methods'].first %>'
41
- <%- unless @spec['url']['parts'].empty? -%>
42
- <%= ' '*@namespace_depth %> path = "<%= @spec['url']['path'].split('/').compact.reject {|p| p =~ /^\s*$/}.map do |p|
43
- p =~ /\{/ ? "\#\{arguments[:#{p.tr('{}', '')}]\}" : p
44
- end.join('/') %>"
45
- <%- else -%>
46
- <%= ' '*@namespace_depth %> path = "<%= @spec['url']['path'] %>"
47
41
  <%- end -%>
48
- <%- unless @spec['url']['params'].keys.empty? -%>
42
+ <%= ' '*@namespace_depth %> method = <%= @http_method %>
43
+ <%= ' '*@namespace_depth %> path = "<%= @http_path %>"
44
+ <%- unless @spec['url']['params'].empty? -%>
49
45
  <%= ' '*@namespace_depth %> params = Utils.__validate_and_extract_params arguments, valid_params
50
46
  <%- else -%>
51
47
  <%= ' '*@namespace_depth %> params = {}
@@ -2,9 +2,9 @@ require 'test_helper'
2
2
 
3
3
  module Elasticsearch
4
4
  module Test
5
- class <%= @module_namespace.empty? ? @method_name.camelize : @module_namespace.map {|n| n.capitalize}.join + @method_name.camelize %>Test < ::Test::Unit::TestCase
5
+ class <%= @module_namespace.map {|n| n.capitalize}.map { |n| n == 'Xpack' ? 'XPack' : n }.join('') + @method_name.camelize %>Test < ::Test::Unit::TestCase
6
6
 
7
- context "<%= @module_namespace.empty? ? '' : @module_namespace.map {|n| n.capitalize}.join + ': ' %><%= @method_name.humanize %>" do
7
+ context "<%= @module_namespace.map {|n| n.capitalize}.map { |n| n == 'Xpack' ? 'XPack' : n }.join(' ') + ': ' %><%= @method_name.humanize %>" do
8
8
  subject { FakeClient.new }
9
9
 
10
10
  should "perform correct request" do
@@ -16,7 +16,7 @@ module Elasticsearch
16
16
  true
17
17
  end.returns(FakeResponse.new)
18
18
 
19
- subject.<%= @full_namespace.join('.') %>
19
+ subject.<%= @full_namespace.join('.') %> <%= @spec['url']['parts'].select { |name, info| info['required'] }.keys.map { |d| ":#{d} => 'foo'" }.join(', ') %>
20
20
  end
21
21
 
22
22
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: elasticsearch-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.2
4
+ version: 5.0.0.pre
5
5
  platform: ruby
6
6
  authors:
7
7
  - Karel Minarik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-04-07 00:00:00.000000000 Z
11
+ date: 2016-10-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -386,6 +386,7 @@ files:
386
386
  - lib/elasticsearch/api/actions/cat/shards.rb
387
387
  - lib/elasticsearch/api/actions/cat/snapshots.rb
388
388
  - lib/elasticsearch/api/actions/cat/tasks.rb
389
+ - lib/elasticsearch/api/actions/cat/templates.rb
389
390
  - lib/elasticsearch/api/actions/cat/thread_pool.rb
390
391
  - lib/elasticsearch/api/actions/clear_scroll.rb
391
392
  - lib/elasticsearch/api/actions/cluster/allocation_explain.rb
@@ -444,9 +445,11 @@ files:
444
445
  - lib/elasticsearch/api/actions/indices/put_warmer.rb
445
446
  - lib/elasticsearch/api/actions/indices/recovery.rb
446
447
  - lib/elasticsearch/api/actions/indices/refresh.rb
448
+ - lib/elasticsearch/api/actions/indices/rollover.rb
447
449
  - lib/elasticsearch/api/actions/indices/seal.rb
448
450
  - lib/elasticsearch/api/actions/indices/segments.rb
449
451
  - lib/elasticsearch/api/actions/indices/shard_stores.rb
452
+ - lib/elasticsearch/api/actions/indices/shrink.rb
450
453
  - lib/elasticsearch/api/actions/indices/snapshot_index.rb
451
454
  - lib/elasticsearch/api/actions/indices/stats.rb
452
455
  - lib/elasticsearch/api/actions/indices/status.rb
@@ -528,6 +531,7 @@ files:
528
531
  - test/unit/cat/shards_test.rb
529
532
  - test/unit/cat/snapshots_test.rb
530
533
  - test/unit/cat/tasks_test.rb
534
+ - test/unit/cat/templates_test.rb
531
535
  - test/unit/cat/thread_pool_test.rb
532
536
  - test/unit/clear_scroll_test.rb
533
537
  - test/unit/client_test.rb
@@ -588,9 +592,11 @@ files:
588
592
  - test/unit/indices/put_warmer_test.rb
589
593
  - test/unit/indices/recovery_test.rb
590
594
  - test/unit/indices/refresh_test.rb
595
+ - test/unit/indices/rollover_test.rb
591
596
  - test/unit/indices/seal_test.rb
592
597
  - test/unit/indices/segments_test.rb
593
598
  - test/unit/indices/shard_stores_test.rb
599
+ - test/unit/indices/shrink_test.rb
594
600
  - test/unit/indices/snapshot_index_test.rb
595
601
  - test/unit/indices/stats_test.rb
596
602
  - test/unit/indices/status_test.rb
@@ -664,12 +670,12 @@ required_ruby_version: !ruby/object:Gem::Requirement
664
670
  version: '0'
665
671
  required_rubygems_version: !ruby/object:Gem::Requirement
666
672
  requirements:
667
- - - ">="
673
+ - - ">"
668
674
  - !ruby/object:Gem::Version
669
- version: '0'
675
+ version: 1.3.1
670
676
  requirements: []
671
677
  rubyforge_project:
672
- rubygems_version: 2.6.10
678
+ rubygems_version: 2.5.1
673
679
  signing_key:
674
680
  specification_version: 4
675
681
  summary: Ruby API for Elasticsearch.
@@ -698,6 +704,7 @@ test_files:
698
704
  - test/unit/cat/shards_test.rb
699
705
  - test/unit/cat/snapshots_test.rb
700
706
  - test/unit/cat/tasks_test.rb
707
+ - test/unit/cat/templates_test.rb
701
708
  - test/unit/cat/thread_pool_test.rb
702
709
  - test/unit/clear_scroll_test.rb
703
710
  - test/unit/client_test.rb
@@ -758,9 +765,11 @@ test_files:
758
765
  - test/unit/indices/put_warmer_test.rb
759
766
  - test/unit/indices/recovery_test.rb
760
767
  - test/unit/indices/refresh_test.rb
768
+ - test/unit/indices/rollover_test.rb
761
769
  - test/unit/indices/seal_test.rb
762
770
  - test/unit/indices/segments_test.rb
763
771
  - test/unit/indices/shard_stores_test.rb
772
+ - test/unit/indices/shrink_test.rb
764
773
  - test/unit/indices/snapshot_index_test.rb
765
774
  - test/unit/indices/stats_test.rb
766
775
  - test/unit/indices/status_test.rb