File tree Expand file tree Collapse file tree 1 file changed +15
-10
lines changed
elasticsearch-api/utils/thor Expand file tree Collapse file tree 1 file changed +15
-10
lines changed Original file line number Diff line number Diff line change @@ -148,26 +148,31 @@ def __endpoint_parts
148
148
149
149
def __http_method
150
150
return '_id ? Elasticsearch::API::HTTP_PUT : Elasticsearch::API::HTTP_POST' if @endpoint_name == 'index'
151
+ return post_and_get if @endpoint_name == 'count'
151
152
152
153
default_method = @spec [ 'url' ] [ 'paths' ] . map { |a | a [ 'methods' ] } . flatten . first
153
154
if @spec [ 'body' ] && default_method == 'GET'
154
155
# When default method is GET and body is required, we should always use POST
155
156
if @spec [ 'body' ] [ 'required' ]
156
157
'Elasticsearch::API::HTTP_POST'
157
158
else
158
- <<~SRC
159
- if arguments[:body]
160
- Elasticsearch::API::HTTP_POST
161
- else
162
- Elasticsearch::API::HTTP_GET
163
- end
164
- SRC
159
+ post_and_get
165
160
end
166
161
else
167
162
"Elasticsearch::API::HTTP_#{ default_method } "
168
163
end
169
164
end
170
165
166
+ def post_and_get
167
+ <<~SRC
168
+ if arguments[:body]
169
+ Elasticsearch::API::HTTP_POST
170
+ else
171
+ Elasticsearch::API::HTTP_GET
172
+ end
173
+ SRC
174
+ end
175
+
171
176
def __http_path
172
177
return "\" #{ __parse_path ( @paths . first ) } \" " if @paths . size == 1
173
178
return termvectors_path if @method_name == 'termvectors'
@@ -194,9 +199,9 @@ def __http_path
194
199
195
200
def __parse_path ( path )
196
201
path . gsub ( /^\/ / , '' )
197
- . gsub ( /\/ $/ , '' )
198
- . gsub ( '{' , "\# {#{ __utils } .__listify(_" )
199
- . gsub ( '}' , ')}' )
202
+ . gsub ( /\/ $/ , '' )
203
+ . gsub ( '{' , "\# {Utils .__listify(_" )
204
+ . gsub ( '}' , ')}' )
200
205
end
201
206
202
207
def __path_variables
You can’t perform that action at this time.
0 commit comments