elasticsearch-api 7.4.0 → 7.5.0.pre.pre

Sign up to get free protection for your applications and to get access to all the features.
Files changed (185) hide show
  1. checksums.yaml +4 -4
  2. data/Rakefile +16 -23
  3. data/lib/elasticsearch/api/actions/abort_benchmark.rb +1 -2
  4. data/lib/elasticsearch/api/actions/benchmark.rb +2 -3
  5. data/lib/elasticsearch/api/actions/bulk.rb +35 -68
  6. data/lib/elasticsearch/api/actions/cat/aliases.rb +30 -52
  7. data/lib/elasticsearch/api/actions/cat/allocation.rb +36 -50
  8. data/lib/elasticsearch/api/actions/cat/count.rb +25 -46
  9. data/lib/elasticsearch/api/actions/cat/fielddata.rb +31 -33
  10. data/lib/elasticsearch/api/actions/cat/health.rb +27 -37
  11. data/lib/elasticsearch/api/actions/cat/help.rb +14 -10
  12. data/lib/elasticsearch/api/actions/cat/indices.rb +45 -62
  13. data/lib/elasticsearch/api/actions/cat/master.rb +24 -34
  14. data/lib/elasticsearch/api/actions/cat/nodeattrs.rb +20 -16
  15. data/lib/elasticsearch/api/actions/cat/nodes.rb +34 -46
  16. data/lib/elasticsearch/api/actions/cat/params_registry.rb +0 -1
  17. data/lib/elasticsearch/api/actions/cat/pending_tasks.rb +29 -35
  18. data/lib/elasticsearch/api/actions/cat/plugins.rb +21 -18
  19. data/lib/elasticsearch/api/actions/cat/recovery.rb +40 -56
  20. data/lib/elasticsearch/api/actions/cat/repositories.rb +21 -24
  21. data/lib/elasticsearch/api/actions/cat/segments.rb +29 -22
  22. data/lib/elasticsearch/api/actions/cat/shards.rb +38 -59
  23. data/lib/elasticsearch/api/actions/cat/snapshots.rb +32 -27
  24. data/lib/elasticsearch/api/actions/cat/tasks.rb +25 -19
  25. data/lib/elasticsearch/api/actions/cat/templates.rb +26 -18
  26. data/lib/elasticsearch/api/actions/cat/thread_pool.rb +36 -46
  27. data/lib/elasticsearch/api/actions/clear_scroll.rb +21 -8
  28. data/lib/elasticsearch/api/actions/cluster/allocation_explain.rb +15 -13
  29. data/lib/elasticsearch/api/actions/cluster/get_settings.rb +18 -18
  30. data/lib/elasticsearch/api/actions/cluster/health.rb +42 -44
  31. data/lib/elasticsearch/api/actions/cluster/params_registry.rb +0 -1
  32. data/lib/elasticsearch/api/actions/cluster/pending_tasks.rb +15 -17
  33. data/lib/elasticsearch/api/actions/cluster/put_settings.rb +20 -17
  34. data/lib/elasticsearch/api/actions/cluster/remote_info.rb +8 -6
  35. data/lib/elasticsearch/api/actions/cluster/reroute.rb +25 -37
  36. data/lib/elasticsearch/api/actions/cluster/state.rb +37 -41
  37. data/lib/elasticsearch/api/actions/cluster/stats.rb +20 -12
  38. data/lib/elasticsearch/api/actions/count.rb +52 -39
  39. data/lib/elasticsearch/api/actions/create.rb +25 -26
  40. data/lib/elasticsearch/api/actions/delete.rb +43 -36
  41. data/lib/elasticsearch/api/actions/delete_by_query.rb +74 -62
  42. data/lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb +39 -0
  43. data/lib/elasticsearch/api/actions/delete_by_rethrottle.rb +4 -3
  44. data/lib/elasticsearch/api/actions/delete_script.rb +19 -13
  45. data/lib/elasticsearch/api/actions/exists.rb +44 -34
  46. data/lib/elasticsearch/api/actions/exists_source.rb +43 -25
  47. data/lib/elasticsearch/api/actions/explain.rb +46 -51
  48. data/lib/elasticsearch/api/actions/field_caps.rb +27 -20
  49. data/lib/elasticsearch/api/actions/get.rb +42 -41
  50. data/lib/elasticsearch/api/actions/get_script.rb +19 -14
  51. data/lib/elasticsearch/api/actions/get_source.rb +38 -44
  52. data/lib/elasticsearch/api/actions/index.rb +60 -89
  53. data/lib/elasticsearch/api/actions/indices/analyze.rb +19 -48
  54. data/lib/elasticsearch/api/actions/indices/clear_cache.rb +29 -41
  55. data/lib/elasticsearch/api/actions/indices/clone.rb +21 -21
  56. data/lib/elasticsearch/api/actions/indices/close.rb +28 -32
  57. data/lib/elasticsearch/api/actions/indices/create.rb +22 -70
  58. data/lib/elasticsearch/api/actions/indices/delete.rb +23 -35
  59. data/lib/elasticsearch/api/actions/indices/delete_alias.rb +24 -20
  60. data/lib/elasticsearch/api/actions/indices/delete_template.rb +18 -20
  61. data/lib/elasticsearch/api/actions/indices/exists.rb +32 -34
  62. data/lib/elasticsearch/api/actions/indices/exists_alias.rb +33 -29
  63. data/lib/elasticsearch/api/actions/indices/exists_template.rb +21 -16
  64. data/lib/elasticsearch/api/actions/indices/exists_type.rb +29 -29
  65. data/lib/elasticsearch/api/actions/indices/flush.rb +28 -28
  66. data/lib/elasticsearch/api/actions/indices/flush_synced.rb +23 -12
  67. data/lib/elasticsearch/api/actions/indices/forcemerge.rb +26 -41
  68. data/lib/elasticsearch/api/actions/indices/freeze.rb +7 -8
  69. data/lib/elasticsearch/api/actions/indices/get.rb +25 -19
  70. data/lib/elasticsearch/api/actions/indices/get_alias.rb +31 -23
  71. data/lib/elasticsearch/api/actions/indices/get_field_mapping.rb +42 -38
  72. data/lib/elasticsearch/api/actions/indices/get_mapping.rb +39 -31
  73. data/lib/elasticsearch/api/actions/indices/get_settings.rb +34 -37
  74. data/lib/elasticsearch/api/actions/indices/get_template.rb +21 -23
  75. data/lib/elasticsearch/api/actions/indices/get_upgrade.rb +48 -0
  76. data/lib/elasticsearch/api/actions/indices/open.rb +24 -21
  77. data/lib/elasticsearch/api/actions/indices/params_registry.rb +0 -1
  78. data/lib/elasticsearch/api/actions/indices/put_alias.rb +25 -27
  79. data/lib/elasticsearch/api/actions/indices/put_mapping.rb +40 -39
  80. data/lib/elasticsearch/api/actions/indices/put_settings.rb +30 -37
  81. data/lib/elasticsearch/api/actions/indices/put_template.rb +23 -23
  82. data/lib/elasticsearch/api/actions/indices/recovery.rb +20 -23
  83. data/lib/elasticsearch/api/actions/indices/refresh.rb +22 -26
  84. data/lib/elasticsearch/api/actions/indices/rollover.rb +28 -19
  85. data/lib/elasticsearch/api/actions/indices/segments.rb +24 -17
  86. data/lib/elasticsearch/api/actions/indices/shard_stores.rb +27 -15
  87. data/lib/elasticsearch/api/actions/indices/shrink.rb +23 -17
  88. data/lib/elasticsearch/api/actions/indices/split.rb +23 -17
  89. data/lib/elasticsearch/api/actions/indices/stats.rb +53 -104
  90. data/lib/elasticsearch/api/actions/indices/unfreeze.rb +7 -7
  91. data/lib/elasticsearch/api/actions/indices/update_aliases.rb +15 -32
  92. data/lib/elasticsearch/api/actions/indices/upgrade.rb +26 -16
  93. data/lib/elasticsearch/api/actions/indices/validate_query.rb +46 -59
  94. data/lib/elasticsearch/api/actions/info.rb +9 -6
  95. data/lib/elasticsearch/api/actions/ingest/delete_pipeline.rb +18 -12
  96. data/lib/elasticsearch/api/actions/ingest/get_pipeline.rb +21 -11
  97. data/lib/elasticsearch/api/actions/ingest/params_registry.rb +0 -1
  98. data/lib/elasticsearch/api/actions/ingest/processor_grok.rb +12 -13
  99. data/lib/elasticsearch/api/actions/ingest/put_pipeline.rb +19 -14
  100. data/lib/elasticsearch/api/actions/ingest/simulate.rb +23 -13
  101. data/lib/elasticsearch/api/actions/mget.rb +37 -44
  102. data/lib/elasticsearch/api/actions/msearch.rb +54 -54
  103. data/lib/elasticsearch/api/actions/msearch_template.rb +46 -35
  104. data/lib/elasticsearch/api/actions/mtermvectors.rb +39 -35
  105. data/lib/elasticsearch/api/actions/nodes/hot_threads.rb +30 -25
  106. data/lib/elasticsearch/api/actions/nodes/info.rb +29 -63
  107. data/lib/elasticsearch/api/actions/nodes/params_registry.rb +0 -1
  108. data/lib/elasticsearch/api/actions/nodes/reload_secure_settings.rb +24 -22
  109. data/lib/elasticsearch/api/actions/nodes/shutdown.rb +4 -4
  110. data/lib/elasticsearch/api/actions/nodes/stats.rb +43 -36
  111. data/lib/elasticsearch/api/actions/nodes/usage.rb +31 -10
  112. data/lib/elasticsearch/api/actions/params_registry.rb +0 -1
  113. data/lib/elasticsearch/api/actions/ping.rb +12 -13
  114. data/lib/elasticsearch/api/actions/put_script.rb +26 -30
  115. data/lib/elasticsearch/api/actions/rank_eval.rb +24 -15
  116. data/lib/elasticsearch/api/actions/reindex.rb +25 -48
  117. data/lib/elasticsearch/api/actions/reindex_rethrottle.rb +18 -12
  118. data/lib/elasticsearch/api/actions/remote/info.rb +1 -2
  119. data/lib/elasticsearch/api/actions/render_search_template.rb +17 -15
  120. data/lib/elasticsearch/api/actions/scripts_painless_execute.rb +8 -6
  121. data/lib/elasticsearch/api/actions/scroll.rb +28 -51
  122. data/lib/elasticsearch/api/actions/search.rb +104 -165
  123. data/lib/elasticsearch/api/actions/search_shards.rb +31 -28
  124. data/lib/elasticsearch/api/actions/search_template.rb +48 -40
  125. data/lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb +44 -0
  126. data/lib/elasticsearch/api/actions/snapshot/create.rb +22 -29
  127. data/lib/elasticsearch/api/actions/snapshot/create_repository.rb +19 -24
  128. data/lib/elasticsearch/api/actions/snapshot/delete.rb +20 -22
  129. data/lib/elasticsearch/api/actions/snapshot/delete_repository.rb +16 -18
  130. data/lib/elasticsearch/api/actions/snapshot/get.rb +22 -31
  131. data/lib/elasticsearch/api/actions/snapshot/get_repository.rb +21 -25
  132. data/lib/elasticsearch/api/actions/snapshot/params_registry.rb +0 -1
  133. data/lib/elasticsearch/api/actions/snapshot/restore.rb +21 -32
  134. data/lib/elasticsearch/api/actions/snapshot/status.rb +23 -24
  135. data/lib/elasticsearch/api/actions/snapshot/verify_repository.rb +18 -13
  136. data/lib/elasticsearch/api/actions/tasks/cancel.rb +19 -13
  137. data/lib/elasticsearch/api/actions/tasks/get.rb +16 -13
  138. data/lib/elasticsearch/api/actions/tasks/list.rb +20 -18
  139. data/lib/elasticsearch/api/actions/tasks/params_registry.rb +0 -1
  140. data/lib/elasticsearch/api/actions/termvectors.rb +52 -70
  141. data/lib/elasticsearch/api/actions/update.rb +53 -98
  142. data/lib/elasticsearch/api/actions/update_by_query.rb +77 -66
  143. data/lib/elasticsearch/api/actions/update_by_query_rethrottle.rb +17 -11
  144. data/lib/elasticsearch/api/version.rb +1 -1
  145. data/spec/elasticsearch/api/actions/cat/segments_spec.rb +9 -11
  146. data/spec/elasticsearch/api/actions/cluster/put_settings_spec.rb +1 -1
  147. data/spec/elasticsearch/api/actions/count_spec.rb +8 -8
  148. data/spec/elasticsearch/api/actions/delete_by_query_spec.rb +12 -7
  149. data/spec/elasticsearch/api/actions/delete_script_spec.rb +0 -14
  150. data/spec/elasticsearch/api/actions/exists_document_spec.rb +1 -1
  151. data/spec/elasticsearch/api/actions/get_document_source_spec.rb +1 -1
  152. data/spec/elasticsearch/api/actions/index_document_spec.rb +6 -15
  153. data/spec/elasticsearch/api/actions/indices/analyze_spec.rb +0 -4
  154. data/spec/elasticsearch/api/actions/indices/clear_cache_spec.rb +1 -5
  155. data/spec/elasticsearch/api/actions/indices/clone_spec.rb +1 -1
  156. data/spec/elasticsearch/api/actions/indices/delete_alias_spec.rb +2 -2
  157. data/spec/elasticsearch/api/actions/indices/get_spec.rb +0 -11
  158. data/spec/elasticsearch/api/actions/indices/put_alias_spec.rb +3 -3
  159. data/spec/elasticsearch/api/actions/indices/put_mapping_spec.rb +3 -3
  160. data/spec/elasticsearch/api/actions/indices/stats_spec.rb +0 -1
  161. data/spec/elasticsearch/api/actions/nodes/hot_threads_spec.rb +3 -3
  162. data/spec/elasticsearch/api/actions/put_script_spec.rb +20 -15
  163. data/spec/elasticsearch/api/actions/render_search_template_spec.rb +23 -7
  164. data/spec/elasticsearch/api/actions/scroll_spec.rb +37 -0
  165. data/spec/elasticsearch/api/actions/search_spec.rb +0 -15
  166. data/spec/elasticsearch/api/actions/tasks/list_spec.rb +0 -11
  167. data/spec/elasticsearch/api/actions/update_document_spec.rb +3 -7
  168. data/spec/rest_yaml_tests_helper.rb +12 -0
  169. data/utils/Gemfile +1 -0
  170. data/utils/Thorfile +0 -1
  171. data/utils/thor/generate_source.rb +192 -85
  172. data/utils/thor/generator/endpoint_specifics.rb +157 -0
  173. data/utils/thor/generator/files_helper.rb +37 -0
  174. data/utils/thor/lister.rb +3 -4
  175. data/utils/thor/templates/_documentation_top.erb +27 -0
  176. data/utils/thor/templates/_method_setup.erb +35 -0
  177. data/utils/thor/templates/_params_registry.erb +12 -0
  178. data/utils/thor/templates/_perform_request.erb +37 -0
  179. data/utils/thor/templates/method.erb +59 -0
  180. data/utils/thor/templates/{ruby/test.erb → test.erb} +0 -0
  181. data/utils/thor/templates/{ruby/test_helper.rb → test_helper.rb} +0 -0
  182. metadata +19 -11
  183. data/spec/elasticsearch/api/actions/scoll_spec.rb +0 -21
  184. data/utils/thor/generate_api.rb +0 -193
  185. data/utils/thor/templates/ruby/method.erb +0 -62
@@ -0,0 +1,157 @@
1
+ # frozen_string_literal: true
2
+
3
+ # Licensed to Elasticsearch B.V under one or more agreements.
4
+ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
5
+ # See the LICENSE file in the project root for more information
6
+
7
+ module Elasticsearch
8
+ module API
9
+ # Handles specific exceptional parameters and code snippets that need to be
10
+ # included in the generated code. This module is included in SourceGenerator
11
+ # so its methods can be used from the ERB template (method.erb). This will
12
+ # potentially be refactored into different templates.
13
+ module EndpointSpecifics
14
+ # Endpoints that need Utils.__rescue_from_not_found
15
+ IGNORE_404 = %w[
16
+ exists
17
+ indices.exists
18
+ indices.exists_alias
19
+ indices.exists_template
20
+ indices.exists_type
21
+ ].freeze
22
+
23
+ # Endpoints that need Utils.__rescue_from_not_found if the ignore
24
+ # parameter is included
25
+ COMPLEX_IGNORE_404 = %w[
26
+ delete
27
+ get
28
+ indices.flush_synced
29
+ indices.delete_template
30
+ indices.delete
31
+ security.get_role
32
+ security.get_user
33
+ snapshot.status
34
+ snapshot.get
35
+ snapshot.get_repository
36
+ snapshot.delete_repository
37
+ snapshot.delete
38
+ update
39
+ watcher.delete_watch
40
+ ].freeze
41
+
42
+ # Endpoints that need params[:h] listified
43
+ H_PARAMS = %w[aliases allocation count health indices nodes pending_tasks
44
+ recovery shards thread_pool].freeze
45
+
46
+ # Function that adds the listified h param code
47
+ def specific_params(namespace)
48
+ params = []
49
+ if H_PARAMS.include?(@method_name) && namespace == 'cat'
50
+ if @method_name == 'nodes'
51
+ params << 'params[:h] = Utils.__listify(params[:h], escape: false) if params[:h]'
52
+ else
53
+ params << 'params[:h] = Utils.__listify(params[:h]) if params[:h]'
54
+ end
55
+ end
56
+ params
57
+ end
58
+
59
+ def needs_ignore_404?(endpoint)
60
+ IGNORE_404.include? endpoint
61
+ end
62
+
63
+ def needs_complex_ignore_404?(endpoint)
64
+ COMPLEX_IGNORE_404.include? endpoint
65
+ end
66
+
67
+ def termvectors_path
68
+ <<~SRC
69
+ if _index && _type && _id
70
+ "\#{Utils.__listify(_index)}/\#{Utils.__listify(_type)}/\#{Utils.__listify(_id)}/\#{endpoint}"
71
+ elsif _index && _type
72
+ "\#{Utils.__listify(_index)}/\#{Utils.__listify(_type)}/\#{endpoint}"
73
+ elsif _index && _id
74
+ "\#{Utils.__listify(_index)}/\#{endpoint}/\#{Utils.__listify(_id)}"
75
+ else
76
+ "\#{Utils.__listify(_index)}/\#{endpoint}"
77
+ end
78
+ SRC
79
+ end
80
+
81
+ def ping_perform_request
82
+ <<~SRC
83
+ begin
84
+ perform_request(method, path, params, body).status == 200 ? true : false
85
+ rescue Exception => e
86
+ if e.class.to_s =~ /NotFound|ConnectionFailed/ || e.message =~ /Not\s*Found|404|ConnectionFailed/i
87
+ false
88
+ else
89
+ raise e
90
+ end
91
+ end
92
+ SRC
93
+ end
94
+
95
+ def indices_stats_params_registry
96
+ <<~SRC
97
+ ParamsRegistry.register(:stats_params, [
98
+ #{@spec['params'].keys.map { |k| ":#{k}" }.join(",\n")}
99
+ ].freeze)
100
+
101
+ ParamsRegistry.register(:stats_parts, [
102
+ #{@parts['metric']['options'].push('metric').map { |k| ":#{k}" }.join(",\n")}
103
+ ].freeze)
104
+ SRC
105
+ end
106
+
107
+ def msearch_body_helper
108
+ <<~SRC
109
+ case
110
+ when body.is_a?(Array) && body.any? { |d| d.has_key? :search }
111
+ payload = body.
112
+ inject([]) do |sum, item|
113
+ meta = item
114
+ data = meta.delete(:search)
115
+
116
+ sum << meta
117
+ sum << data
118
+ sum
119
+ end.
120
+ map { |item| Elasticsearch::API.serializer.dump(item) }
121
+ payload << "" unless payload.empty?
122
+ payload = payload.join("\n")
123
+ when body.is_a?(Array)
124
+ payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
125
+ payload << "" unless payload.empty?
126
+ payload = payload.join("\n")
127
+ else
128
+ payload = body
129
+ end
130
+ SRC
131
+ end
132
+
133
+ def msearch_template_body_helper
134
+ <<~SRC
135
+ case
136
+ when body.is_a?(Array)
137
+ payload = body.map { |d| d.is_a?(String) ? d : Elasticsearch::API.serializer.dump(d) }
138
+ payload << "" unless payload.empty?
139
+ payload = payload.join("\n")
140
+ else
141
+ payload = body
142
+ end
143
+ SRC
144
+ end
145
+
146
+ def bulk_body_helper
147
+ <<~SRC
148
+ if body.is_a? Array
149
+ payload = Utils.__bulkify(body)
150
+ else
151
+ payload = body
152
+ end
153
+ SRC
154
+ end
155
+ end
156
+ end
157
+ end
@@ -0,0 +1,37 @@
1
+ require 'pathname'
2
+
3
+ module Elasticsearch
4
+ module API
5
+ module FilesHelper
6
+ OSS_SRC_PATH = '../../../../../tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/api/'.freeze
7
+ OSS_OUTPUT_DIR = '../../elasticsearch-api/lib/elasticsearch/api/actions'.freeze
8
+
9
+ XPACK_SRC_PATH = '../../../../../tmp/elasticsearch/x-pack/plugin/src/test/resources/rest-api-spec/api'.freeze
10
+ XPACK_OUTPUT_DIR = '../../elasticsearch-xpack/lib/elasticsearch/xpack/api/actions'.freeze
11
+
12
+ # Path to directory with JSON API specs
13
+ def self.input_dir(xpack = false)
14
+ input_dir = if xpack
15
+ File.expand_path(XPACK_SRC_PATH, __FILE__)
16
+ else
17
+ File.expand_path(OSS_SRC_PATH, __FILE__)
18
+ end
19
+ Pathname(input_dir)
20
+ end
21
+
22
+ # Path to directory to copy generated files
23
+ def self.output_dir(xpack = false)
24
+ xpack ? Pathname(XPACK_OUTPUT_DIR) : Pathname(OSS_OUTPUT_DIR)
25
+ end
26
+
27
+ # Only get JSON files and remove hidden files
28
+ def self.files(xpack = false)
29
+ Dir.entries(input_dir(xpack).to_s).reject do |f|
30
+ f.start_with?('.') ||
31
+ f.start_with?('_') ||
32
+ File.extname(f) != '.json'
33
+ end
34
+ end
35
+ end
36
+ end
37
+ end
data/utils/thor/lister.rb CHANGED
@@ -9,16 +9,16 @@ require 'thor'
9
9
  require 'pathname'
10
10
 
11
11
  module Elasticsearch
12
-
13
12
  module API
14
-
15
13
  class Lister < Thor
16
14
  namespace 'api'
17
15
 
16
+ DEFAULT_PATH = '../../tmp/elasticsearch/rest-api-spec/src/main/resources/rest-api-spec/api/'.freeze
17
+
18
18
  desc "list <PATH DIRECTORY WITH JSON SPEC FILES>", "List all the REST API endpoints from the JSON specification"
19
19
  method_option :verbose, type: :boolean, default: false, desc: 'Output more information'
20
20
  method_option :format, default: 'text', desc: 'Output format (text, json)'
21
- def list(directory)
21
+ def list(directory = DEFAULT_PATH)
22
22
  input = Pathname(directory).join('*.json')
23
23
  apis = Dir[input.to_s].map do |f|
24
24
  File.basename(f, '.json')
@@ -40,6 +40,5 @@ module Elasticsearch
40
40
  end
41
41
  end
42
42
  end
43
-
44
43
  end
45
44
  end
@@ -0,0 +1,27 @@
1
+ <%- if @spec['documentation']['description'] -%>
2
+ <%= ' '*(@namespace_depth+3) %># <%= @spec['documentation']['description'].gsub("\n", "\n#{' '*(@namespace_depth+3)}# ") -%>
3
+ <%- else %>
4
+ <%= ' '*(@namespace_depth+3) %># TODO: Description
5
+ <%- end %>
6
+ <%= ' '*(@namespace_depth+3) %>#
7
+ <%- unless @parts.nil? || @parts.empty? %><%# URL parts -%>
8
+ <%- @parts.each do |name, info| -%>
9
+ <%= docs_helper(name, info) -%>
10
+ <%- end -%>
11
+ <%- end -%><%# Body -%>
12
+ <%# URL parameters -%>
13
+ <%- @params.each do |name, info| -%>
14
+ <%= docs_helper(name, info) -%>
15
+ <%- end %>
16
+ <%= ' '*(@namespace_depth+3) + '# @option arguments [Hash] :body ' + (@spec['body']['description'] ? @spec['body']['description'].strip : 'TODO: Description') + (@spec['body']['required'] ? ' (*Required*)' : '') + "\n" if @spec['body'] -%>
17
+ <% if @deprecation_note -%>
18
+ #
19
+ # *Deprecation notice*:
20
+ # <%= @deprecation_note['description'] %>
21
+ # Deprecated since version <%= @deprecation_note['version'] %>
22
+ #
23
+ <% end -%>
24
+ <%= ' '*(@namespace_depth+3) -%>#
25
+ <%# Documentation link -%>
26
+ <%= ' '*(@namespace_depth+3) %># @see <%= @spec['documentation']['url'] ? @spec['documentation']['url'].gsub!(/\/(current|master)\//, '/7.5/') : "[TODO]" %>
27
+ <%= ' '*(@namespace_depth+3) %>#
@@ -0,0 +1,35 @@
1
+ <%- if @endpoint_name == 'indices.stats' %>
2
+ method = HTTP_GET
3
+ parts = Utils.__extract_parts arguments, ParamsRegistry.get(:stats_parts)
4
+ path = Utils.__pathify Utils.__listify(arguments[:index]), '_stats', Utils.__listify(parts)
5
+ params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(:stats_params)
6
+ params[:fields] = Utils.__listify(params[:fields], :escape => false) if params[:fields]
7
+ params[:groups] = Utils.__listify(params[:groups], :escape => false) if params[:groups]
8
+ <%- else %>
9
+ <%= ' '*(@namespace_depth+4) %>arguments = arguments.clone
10
+ <%- if @method_name == 'mtermvectors' -%>
11
+ ids = arguments.delete(:ids)
12
+ <%- end -%>
13
+ <%- if @method_name == 'search' -%>
14
+ arguments[:index] = UNDERSCORE_ALL if ! arguments[:index] && arguments[:type]
15
+ <%- end -%>
16
+ <%- @parts.each do |name, _| %>
17
+ <%- unless @method_name == 'get_field_mapping' && name == 'fields' %>
18
+ <%= ' '*(@namespace_depth+3) + "_#{name}" %> = arguments.delete(:<%=name %>)
19
+ <%- end -%>
20
+ <%- end -%>
21
+
22
+ <%= ' '*(@namespace_depth+4) %>method = <%= @http_method %>
23
+ <%- if @method_name == 'termvectors' %>
24
+ endpoint = arguments.delete(:endpoint) || '_termvectors'
25
+ <%- end -%>
26
+ <%= ' '*(@namespace_depth+4) %>path = <%= @http_path %>
27
+ <%- unless @params.empty? -%>
28
+ <%= ' '*(@namespace_depth+4) %>params = <%= __utils %>.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
29
+ <%- else -%>
30
+ <%= ' '*(@namespace_depth+4) %>params = {}
31
+ <%- end -%>
32
+ <%- @specific_params.each do |param| -%>
33
+ <%= param %>
34
+ <%- end -%>
35
+ <%- end -%>
@@ -0,0 +1,12 @@
1
+ <%- unless @params.empty? -%>
2
+ <%= ' '*(@namespace_depth+3) %># Register this action with its valid params when the module is loaded.
3
+ <%= ' '*(@namespace_depth+3) %>#
4
+ <%= ' '*(@namespace_depth+3) %># @since 6.2.0
5
+ <%- if @endpoint_name == 'indices.stats' -%>
6
+ <%= indices_stats_params_registry %>
7
+ <%- else -%>
8
+ <%= ' '*(@namespace_depth+3) %>ParamsRegistry.register(:<%= @method_name %>, [
9
+ <%= ' '*(@namespace_depth+4) %><%= @params.keys.map { |k| ":#{k}" }.join(",\n#{' '*(@namespace_depth+4)}") %>
10
+ <%= ' '*(@namespace_depth+3) %>].freeze)
11
+ <%- end -%>
12
+ <%- end -%>
@@ -0,0 +1,37 @@
1
+ <%-
2
+ case @endpoint_name
3
+ when 'mtermvectors'
4
+ -%>
5
+ if ids
6
+ body = { :ids => ids }
7
+ else
8
+ body = arguments[:body]
9
+ end
10
+ <%- when 'cluster.reroute', 'cluster.put_settings' %>
11
+ body = arguments[:body] || {}
12
+ <%- when 'ml.find_file_structure' %>
13
+ body = <%= __utils %>.__bulkify(arguments.delete(:body))
14
+ <%- else -%>
15
+ <%= ' '*(@namespace_depth+3) %>body = <%= @spec['body'].nil? ? 'nil' : 'arguments[:body]' %>
16
+ <%- end -%>
17
+ <%- if ['bulk', 'msearch', 'msearch_template'].include? @method_name -%>
18
+ <%= self.send("#{@method_name}_body_helper".to_s) %>
19
+ <%= ' '*(@namespace_depth+4) %>perform_request(method, path, params, payload, {"Content-Type" => "application/x-ndjson"}).body
20
+ <%- elsif @method_name == 'ping' -%>
21
+ <%= ping_perform_request %>
22
+ <%- else -%>
23
+ <%- if needs_ignore_404?(@endpoint_name) %>
24
+ <%= __utils %>.__rescue_from_not_found do
25
+ perform_request(method, path, params, body).status == 200 ? true : false
26
+ end
27
+ <%- elsif needs_complex_ignore_404?(@endpoint_name) -%>
28
+ if Array(arguments[:ignore]).include?(404)
29
+ <%= __utils %>.__rescue_from_not_found { perform_request(method, path, params, body).body }
30
+ else
31
+ perform_request(method, path, params, body).body
32
+ end
33
+ <%- else -%>
34
+ perform_request(method, path, params, body).body
35
+ <%- end -%>
36
+ <%- end -%>
37
+ <%= ' '*(@namespace_depth+3) %>end
@@ -0,0 +1,59 @@
1
+ # Licensed to Elasticsearch B.V under one or more agreements.
2
+ # Elasticsearch B.V licenses this file to you under the Apache 2.0 License.
3
+ # See the LICENSE file in the project root for more information
4
+
5
+ module Elasticsearch
6
+ <%- if @xpack -%>
7
+ <%= ' '*(@namespace_depth) %>module XPack
8
+ <%- end %>
9
+ <%= ' '*(@namespace_depth) %>module API
10
+ <%- @module_namespace.each_with_index do |name, i| -%>
11
+ <%= ' '*i %>module <%= name.split("_").map(&:capitalize).join %>
12
+ <%- end -%>
13
+ <%= ' '*(@namespace_depth+2) %>module Actions
14
+ <%= ERB.new(File.new("./thor/templates/_documentation_top.erb").read, trim_mode: '-').result(binding) -%>
15
+ <%# Method definition -%>
16
+ <%= ' '*(@namespace_depth+3) -%>def <%= @method_name %>(arguments={})
17
+ <%- if @endpoint_name == 'create' -%>
18
+ <%= ' '*(@namespace_depth+3) %>if arguments[:id]
19
+ <%= ' '*(@namespace_depth+3) %> index arguments.update op_type: 'create'
20
+ <%= ' '*(@namespace_depth+3) %>else
21
+ <%= ' '*(@namespace_depth+3) %> index arguments
22
+ <%= ' '*(@namespace_depth+3) %>end
23
+ <%= ' '*(@namespace_depth+2) %>end
24
+ <%- else -%>
25
+ <%- if @method_name == 'get_field_mapping' %>
26
+ _fields = arguments.delete(:field) || arguments.delete(:fields)
27
+ raise ArgumentError, "Required argument 'field' missing" unless _fields
28
+ <%- else -%>
29
+ <%- @required_parts.each do |required| %><%# Arguments -%>
30
+ <%= ' '*(@namespace_depth+3) + "raise ArgumentError, \"Required argument '#{required}' missing\" unless arguments[:#{required}]" + "\n" -%>
31
+ <%- end -%>
32
+ <%- end -%>
33
+ <%- # Method setup -%>
34
+ <%= ERB.new(File.new("./thor/templates/_method_setup.erb").read, trim_mode: '-').result(binding) %>
35
+ <%- # Perform request -%>
36
+ <%= ERB.new(File.new("./thor/templates/_perform_request.erb").read, trim_mode: '-').result(binding) %>
37
+ <%- end -%>
38
+ <%- if @method_name.match?(/^exists\S*/) -%>
39
+ alias_method :<%= @method_name %>?, :<%= @method_name %>
40
+ <%- end -%>
41
+ <%- if @method_name == 'termvectors' %>
42
+
43
+ # Deprecated: Use the plural version, {#termvectors}
44
+ #
45
+ def termvector(arguments={})
46
+ termvectors(arguments.merge endpoint: '_termvector')
47
+ end
48
+ <%- end -%>
49
+ <%# Params Registry Template -%>
50
+ <%- unless @endpoint_name == 'create' -%>
51
+ <%= ERB.new(File.new("./thor/templates/_params_registry.erb").read, trim_mode: '-').result(binding) %>
52
+ <%- end -%>
53
+
54
+ <%- @namespace_depth.downto(1) do |i| -%>
55
+ <%= ' '*(i-1) %>end
56
+ <%- end if @namespace_depth > 0 -%>
57
+ end
58
+ end
59
+ end
File without changes
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: 7.4.0
4
+ version: 7.5.0.pre.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: 2019-11-05 00:00:00.000000000 Z
11
+ date: 2020-02-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -334,7 +334,7 @@ dependencies:
334
334
  version: '2'
335
335
  description: 'Ruby API for Elasticsearch. See the `elasticsearch` gem for full integration.
336
336
 
337
- '
337
+ '
338
338
  email:
339
339
  - karel.minarik@elasticsearch.org
340
340
  executables: []
@@ -390,6 +390,7 @@ files:
390
390
  - lib/elasticsearch/api/actions/create.rb
391
391
  - lib/elasticsearch/api/actions/delete.rb
392
392
  - lib/elasticsearch/api/actions/delete_by_query.rb
393
+ - lib/elasticsearch/api/actions/delete_by_query_rethrottle.rb
393
394
  - lib/elasticsearch/api/actions/delete_by_rethrottle.rb
394
395
  - lib/elasticsearch/api/actions/delete_script.rb
395
396
  - lib/elasticsearch/api/actions/exists.rb
@@ -422,6 +423,7 @@ files:
422
423
  - lib/elasticsearch/api/actions/indices/get_mapping.rb
423
424
  - lib/elasticsearch/api/actions/indices/get_settings.rb
424
425
  - lib/elasticsearch/api/actions/indices/get_template.rb
426
+ - lib/elasticsearch/api/actions/indices/get_upgrade.rb
425
427
  - lib/elasticsearch/api/actions/indices/open.rb
426
428
  - lib/elasticsearch/api/actions/indices/params_registry.rb
427
429
  - lib/elasticsearch/api/actions/indices/put_alias.rb
@@ -471,6 +473,7 @@ files:
471
473
  - lib/elasticsearch/api/actions/search.rb
472
474
  - lib/elasticsearch/api/actions/search_shards.rb
473
475
  - lib/elasticsearch/api/actions/search_template.rb
476
+ - lib/elasticsearch/api/actions/snapshot/cleanup_repository.rb
474
477
  - lib/elasticsearch/api/actions/snapshot/create.rb
475
478
  - lib/elasticsearch/api/actions/snapshot/create_repository.rb
476
479
  - lib/elasticsearch/api/actions/snapshot/delete.rb
@@ -604,7 +607,7 @@ files:
604
607
  - spec/elasticsearch/api/actions/reindex_spec.rb
605
608
  - spec/elasticsearch/api/actions/remote/info_spec.rb
606
609
  - spec/elasticsearch/api/actions/render_search_template_spec.rb
607
- - spec/elasticsearch/api/actions/scoll_spec.rb
610
+ - spec/elasticsearch/api/actions/scroll_spec.rb
608
611
  - spec/elasticsearch/api/actions/search_shards_spec.rb
609
612
  - spec/elasticsearch/api/actions/search_spec.rb
610
613
  - spec/elasticsearch/api/actions/search_template_spec.rb
@@ -633,12 +636,17 @@ files:
633
636
  - test/test_helper.rb
634
637
  - utils/Gemfile
635
638
  - utils/Thorfile
636
- - utils/thor/generate_api.rb
637
639
  - utils/thor/generate_source.rb
640
+ - utils/thor/generator/endpoint_specifics.rb
641
+ - utils/thor/generator/files_helper.rb
638
642
  - utils/thor/lister.rb
639
- - utils/thor/templates/ruby/method.erb
640
- - utils/thor/templates/ruby/test.erb
641
- - utils/thor/templates/ruby/test_helper.rb
643
+ - utils/thor/templates/_documentation_top.erb
644
+ - utils/thor/templates/_method_setup.erb
645
+ - utils/thor/templates/_params_registry.erb
646
+ - utils/thor/templates/_perform_request.erb
647
+ - utils/thor/templates/method.erb
648
+ - utils/thor/templates/test.erb
649
+ - utils/thor/templates/test_helper.rb
642
650
  homepage: https://github.com/elasticsearch/elasticsearch-ruby/tree/master/elasticsearch-api
643
651
  licenses:
644
652
  - Apache-2.0
@@ -655,9 +663,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
655
663
  version: '1.9'
656
664
  required_rubygems_version: !ruby/object:Gem::Requirement
657
665
  requirements:
658
- - - ">="
666
+ - - ">"
659
667
  - !ruby/object:Gem::Version
660
- version: '0'
668
+ version: 1.3.1
661
669
  requirements: []
662
670
  rubygems_version: 3.0.6
663
671
  signing_key:
@@ -768,7 +776,7 @@ test_files:
768
776
  - spec/elasticsearch/api/actions/reindex_spec.rb
769
777
  - spec/elasticsearch/api/actions/remote/info_spec.rb
770
778
  - spec/elasticsearch/api/actions/render_search_template_spec.rb
771
- - spec/elasticsearch/api/actions/scoll_spec.rb
779
+ - spec/elasticsearch/api/actions/scroll_spec.rb
772
780
  - spec/elasticsearch/api/actions/search_shards_spec.rb
773
781
  - spec/elasticsearch/api/actions/search_spec.rb
774
782
  - spec/elasticsearch/api/actions/search_template_spec.rb