File Coverage

blib/lib/Elasticsearch/Role/API.pm
Criterion Covered Total %
statement 13 14 92.8
branch n/a
condition 1 5 20.0
subroutine 5 5 100.0
pod 1 1 100.0
total 20 25 80.0


line stmt bran cond sub pod time code
1             package Elasticsearch::Role::API;
2             $Elasticsearch::Role::API::VERSION = '1.05';
3 42     42   44629 use Moo::Role;
  42         123  
  42         377  
4              
5 42     42   17069 use Elasticsearch::Util qw(throw);
  42         122  
  42         370  
6 42     42   48466 use Elasticsearch::Util::API::QS qw(qs_init);
  42         138  
  42         362  
7 42     42   12221 use namespace::clean;
  42         91  
  42         402  
8              
9             our %API;
10              
11             #===================================
12             sub api {
13             #===================================
14 42   50 42 1 387 my $name = $_[1] || return \%API;
15 0   0       return $API{$name}
16             || throw( 'Internal', "Unknown api name ($name)" );
17             }
18              
19             #===================================
20             %API = (
21             #===================================
22              
23             #=== AUTOGEN - START ===
24              
25             'bulk' => {
26             body => { required => 1 },
27             doc => "docs-bulk",
28             index_when_type => 1,
29             method => "POST",
30             parts => { index => {}, type => {} },
31             paths => [
32             [ { index => 0, type => 1 }, "{index}", "{type}", "_bulk" ],
33             [ { index => 0 }, "{index}", "_bulk" ],
34             [ {}, "_bulk" ],
35             ],
36             qs =>
37             [ "consistency", "refresh", "replication", "routing", "timeout" ],
38             serialize => "bulk",
39             },
40              
41             'clear_scroll' => {
42             doc => "search-request-scroll",
43             method => "DELETE",
44             parts => { scroll_id => { multi => 1, required => 1 } },
45             paths =>
46             [ [ { scroll_id => 2 }, "_search", "scroll", "{scroll_id}" ] ],
47             qs => [],
48             },
49              
50             'count' => {
51             body => {},
52             doc => "search-count",
53             method => "POST",
54             parts => { index => { multi => 1 }, type => { multi => 1 } },
55             paths => [
56             [ { index => 0, type => 1 }, "{index}", "{type}", "_count" ],
57             [ { type => 1 }, "_all", "{type}", "_count" ],
58             [ { index => 0 }, "{index}", "_count" ],
59             [ {}, "_count" ],
60             ],
61             qs => [
62             "allow_no_indices", "expand_wildcards",
63             "ignore_unavailable", "min_score",
64             "preference", "routing",
65             "source",
66             ],
67             },
68              
69             'count_percolate' => {
70             body => {},
71             doc => "search-percolate",
72             parts => {
73             id => {},
74             index => { required => 1 },
75             type => { required => 1 }
76             },
77             paths => [
78             [ { id => 2, index => 0, type => 1 }, "{index}",
79             "{type}", "{id}",
80             "_percolate", "count",
81             ],
82             [ { index => 0, type => 1 }, "{index}",
83             "{type}", "_percolate",
84             "count",
85             ],
86             ],
87             qs => [
88             "allow_no_indices", "expand_wildcards",
89             "ignore_unavailable", "percolate_index",
90             "percolate_type", "preference",
91             "routing", "version",
92             "version_type",
93             ],
94             },
95              
96             'delete' => {
97             doc => "docs-delete",
98             method => "DELETE",
99             parts => {
100             id => { required => 1 },
101             index => { required => 1 },
102             type => { required => 1 },
103             },
104             paths => [
105             [ { id => 2, index => 0, type => 1 }, "{index}",
106             "{type}", "{id}"
107             ],
108             ],
109             qs => [
110             "consistency", "parent", "refresh", "replication",
111             "routing", "timeout", "version", "version_type",
112             ],
113             },
114              
115             'delete_by_query' => {
116             body => {},
117             doc => "docs-delete-by-query",
118             method => "DELETE",
119             parts => {
120             index => { multi => 1, required => 1 },
121             type => { multi => 1 }
122             },
123             paths => [
124             [ { index => 0, type => 1 }, "{index}", "{type}", "_query" ],
125             [ { index => 0 }, "{index}", "_query" ],
126             ],
127             qs => [
128             "allow_no_indices", "analyzer",
129             "consistency", "default_operator",
130             "df", "expand_wildcards",
131             "ignore_unavailable", "q",
132             "replication", "routing",
133             "source", "timeout",
134             ],
135             },
136              
137             'exists' => {
138             doc => "docs-get",
139             method => "HEAD",
140             parts => {
141             id => { required => 1 },
142             index => { required => 1 },
143             type => { required => 1 },
144             },
145             paths => [
146             [ { id => 2, index => 0, type => 1 }, "{index}",
147             "{type}", "{id}"
148             ],
149             ],
150             qs => [ "parent", "preference", "realtime", "refresh", "routing" ],
151             },
152              
153             'explain' => {
154             body => {},
155             doc => "search-explain",
156             parts => {
157             id => { required => 1 },
158             index => { required => 1 },
159             type => { required => 1 },
160             },
161             paths => [
162             [ { id => 2, index => 0, type => 1 }, "{index}",
163             "{type}", "{id}",
164             "_explain",
165             ],
166             ],
167             qs => [
168             "_source", "_source_exclude",
169             "_source_include", "analyze_wildcard",
170             "analyzer", "default_operator",
171             "df", "fields",
172             "lenient", "lowercase_expanded_terms",
173             "parent", "preference",
174             "q", "routing",
175             "source",
176             ],
177             },
178              
179             'get' => {
180             doc => "docs-get",
181             parts => {
182             id => { required => 1 },
183             index => { required => 1 },
184             type => { required => 1 },
185             },
186             paths => [
187             [ { id => 2, index => 0, type => 1 }, "{index}",
188             "{type}", "{id}"
189             ],
190             ],
191             qs => [
192             "_source", "_source_exclude",
193             "_source_include", "fields",
194             "parent", "preference",
195             "realtime", "refresh",
196             "routing", "version",
197             "version_type",
198             ],
199             },
200              
201             'get_source' => {
202             doc => "docs-get",
203             parts => {
204             id => { required => 1 },
205             index => { required => 1 },
206             type => { required => 1 },
207             },
208             paths => [
209             [ { id => 2, index => 0, type => 1 },
210             "{index}", "{type}", "{id}", "_source",
211             ],
212             ],
213             qs => [
214             "_source", "_source_exclude",
215             "_source_include", "parent",
216             "preference", "realtime",
217             "refresh", "routing",
218             "version", "version_type",
219             ],
220             },
221              
222             'index' => {
223             body => { required => 1 },
224             doc => "docs-index_",
225             method => "POST",
226             parts => {
227             id => {},
228             index => { required => 1 },
229             type => { required => 1 }
230             },
231             paths => [
232             [ { id => 2, index => 0, type => 1 }, "{index}",
233             "{type}", "{id}"
234             ],
235             [ { index => 0, type => 1 }, "{index}", "{type}" ],
236             ],
237             qs => [
238             "consistency", "op_type", "parent", "refresh",
239             "replication", "routing", "timeout", "timestamp",
240             "ttl", "version", "version_type",
241             ],
242             },
243              
244             'info' => { doc => "", parts => {}, paths => [ [ {} ] ], qs => [] },
245              
246             'mget' => {
247             body => { required => 1 },
248             doc => "docs-multi-get",
249             index_when_type => 1,
250             parts => { index => {}, type => {} },
251             paths => [
252             [ { index => 0, type => 1 }, "{index}", "{type}", "_mget" ],
253             [ { index => 0 }, "{index}", "_mget" ],
254             [ {}, "_mget" ],
255             ],
256             qs => [
257             "_source", "_source_exclude",
258             "_source_include", "fields",
259             "preference", "realtime",
260             "refresh",
261             ],
262             },
263              
264             'mlt' => {
265             body => {},
266             doc => "search-more-like-this",
267             parts => {
268             id => { required => 1 },
269             index => { required => 1 },
270             type => { required => 1 },
271             },
272             paths => [
273             [ { id => 2, index => 0, type => 1 },
274             "{index}", "{type}", "{id}", "_mlt",
275             ],
276             ],
277             qs => [
278             "boost_terms", "max_doc_freq",
279             "max_query_terms", "max_word_length",
280             "min_doc_freq", "min_term_freq",
281             "min_word_length", "mlt_fields",
282             "percent_terms_to_match", "routing",
283             "search_from", "search_indices",
284             "search_query_hint", "search_scroll",
285             "search_size", "search_source",
286             "search_type", "search_types",
287             "stop_words",
288             ],
289             },
290              
291             'mpercolate' => {
292             body => { required => 1 },
293             doc => "search-percolate",
294             index_when_type => 1,
295             parts => { index => {}, type => {} },
296             paths => [
297             [ { index => 0, type => 1 }, "{index}", "{type}", "_mpercolate" ],
298             [ { index => 0 }, "{index}", "_mpercolate" ],
299             [ {}, "_mpercolate" ],
300             ],
301             qs =>
302             [ "allow_no_indices", "expand_wildcards", "ignore_unavailable" ],
303             serialize => "bulk",
304             },
305              
306             'msearch' => {
307             body => { required => 1 },
308             doc => "search-multi-search",
309             parts => { index => { multi => 1 }, type => { multi => 1 } },
310             paths => [
311             [ { index => 0, type => 1 }, "{index}", "{type}", "_msearch" ],
312             [ { type => 1 }, "_all", "{type}", "_msearch" ],
313             [ { index => 0 }, "{index}", "_msearch" ],
314             [ {}, "_msearch" ],
315             ],
316             qs => ["search_type"],
317             serialize => "bulk",
318             },
319              
320             'mtermvectors' => {
321             body => {},
322             doc => "docs-multi-termvectors",
323             index_when_type => 1,
324             parts => { id => {}, index => {}, type => {} },
325             paths => [
326             [ { index => 0, type => 1 }, "{index}",
327             "{type}", "_mtermvectors"
328             ],
329             [ { index => 0 }, "{index}", "_mtermvectors" ],
330             [ {}, "_mtermvectors" ],
331             ],
332             qs => [
333             "field_statistics", "fields",
334             "ids", "offsets",
335             "parent", "payloads",
336             "positions", "preference",
337             "routing", "term_statistics",
338             ],
339             },
340              
341             'percolate' => {
342             body => {},
343             doc => "search-percolate",
344             parts => {
345             id => {},
346             index => { required => 1 },
347             type => { required => 1 }
348             },
349             paths => [
350             [ { id => 2, index => 0, type => 1 }, "{index}",
351             "{type}", "{id}",
352             "_percolate",
353             ],
354             [ { index => 0, type => 1 }, "{index}", "{type}", "_percolate" ],
355             ],
356             qs => [
357             "allow_no_indices", "expand_wildcards",
358             "ignore_unavailable", "percolate_index",
359             "percolate_type", "preference",
360             "routing", "version",
361             "version_type",
362             ],
363             },
364              
365             'ping' => {
366             doc => "",
367             method => "HEAD",
368             parts => {},
369             paths => [ [ {} ] ],
370             qs => []
371             },
372              
373             'scroll' => {
374             body => {},
375             doc => "search-request-scroll",
376             parts => { scroll_id => {} },
377             paths => [
378             [ { scroll_id => 2 }, "_search", "scroll", "{scroll_id}" ],
379             [ {}, "_search", "scroll" ],
380             ],
381             qs => ["scroll"],
382             },
383              
384             'search' => {
385             body => {},
386             doc => "search-search",
387             parts => { index => { multi => 1 }, type => { multi => 1 } },
388             paths => [
389             [ { index => 0, type => 1 }, "{index}", "{type}", "_search" ],
390             [ { type => 1 }, "_all", "{type}", "_search" ],
391             [ { index => 0 }, "{index}", "_search" ],
392             [ {}, "_search" ],
393             ],
394             qs => [
395             "_source", "_source_exclude",
396             "_source_include", "allow_no_indices",
397             "analyze_wildcard", "analyzer",
398             "default_operator", "df",
399             "expand_wildcards", "explain",
400             "fields", "from",
401             "ignore_unavailable", "indices_boost",
402             "lenient", "lowercase_expanded_terms",
403             "preference", "q",
404             "routing", "scroll",
405             "search_type", "size",
406             "sort", "source",
407             "stats", "suggest_field",
408             "suggest_mode", "suggest_size",
409             "suggest_text", "timeout",
410             "version",
411             ],
412             },
413              
414             'suggest' => {
415             body => { required => 1 },
416             doc => "search-search",
417             method => "POST",
418             parts => { index => { multi => 1 } },
419             paths =>
420             [ [ { index => 0 }, "{index}", "_suggest" ], [ {}, "_suggest" ] ],
421             qs => [
422             "allow_no_indices", "expand_wildcards",
423             "ignore_unavailable", "preference",
424             "routing", "source",
425             ],
426             },
427              
428             'termvector' => {
429             body => {},
430             doc => "docs-termvectors",
431             parts => {
432             id => { required => 1 },
433             index => { required => 1 },
434             type => { required => 1 },
435             },
436             paths => [
437             [ { id => 2, index => 0, type => 1 }, "{index}",
438             "{type}", "{id}",
439             "_termvector",
440             ],
441             ],
442             qs => [
443             "field_statistics", "fields",
444             "offsets", "parent",
445             "payloads", "positions",
446             "preference", "routing",
447             "term_statistics",
448             ],
449             },
450              
451             'update' => {
452             body => {},
453             doc => "docs-update",
454             method => "POST",
455             parts => {
456             id => { required => 1 },
457             index => { required => 1 },
458             type => { required => 1 },
459             },
460             paths => [
461             [ { id => 2, index => 0, type => 1 },
462             "{index}", "{type}", "{id}", "_update",
463             ],
464             ],
465             qs => [
466             "consistency", "fields",
467             "lang", "parent",
468             "refresh", "replication",
469             "retry_on_conflict", "routing",
470             "script", "timeout",
471             "timestamp", "ttl",
472             "version", "version_type",
473             ],
474             },
475              
476             'cat.aliases' => {
477             doc => "cat-aliases",
478             parts => { name => { multi => 1 } },
479             paths => [
480             [ { name => 2 }, "_cat", "aliases", "{name}" ],
481             [ {}, "_cat", "aliases" ],
482             ],
483             qs => [ "h", "help", "local", "master_timeout", "v" ],
484             },
485              
486             'cat.allocation' => {
487             doc => "cat-allocation",
488             parts => { node_id => { multi => 1 } },
489             paths => [
490             [ { node_id => 2 }, "_cat", "allocation", "{node_id}" ],
491             [ {}, "_cat", "allocation" ],
492             ],
493             qs => [ "bytes", "h", "help", "local", "master_timeout", "v" ],
494             },
495              
496             'cat.count' => {
497             doc => "cat-count",
498             parts => { index => { multi => 1 } },
499             paths => [
500             [ { index => 2 }, "_cat", "count", "{index}" ],
501             [ {}, "_cat", "count" ],
502             ],
503             qs => [ "h", "help", "local", "master_timeout", "v" ],
504             },
505              
506             'cat.health' => {
507             doc => "cat-health",
508             parts => {},
509             paths => [ [ {}, "_cat", "health" ] ],
510             qs => [ "h", "help", "local", "master_timeout", "ts", "v" ],
511             },
512              
513             'cat.help' => {
514             doc => "cat",
515             parts => {},
516             paths => [ [ {}, "_cat" ] ],
517             qs => ["help"]
518             },
519              
520             'cat.indices' => {
521             doc => "cat-indices",
522             parts => { index => { multi => 1 } },
523             paths => [
524             [ { index => 2 }, "_cat", "indices", "{index}" ],
525             [ {}, "_cat", "indices" ],
526             ],
527             qs => [ "bytes", "h", "help", "local", "master_timeout", "pri", "v" ],
528             },
529              
530             'cat.master' => {
531             doc => "cat-master",
532             parts => {},
533             paths => [ [ {}, "_cat", "master" ] ],
534             qs => [ "h", "help", "local", "master_timeout", "v" ],
535             },
536              
537             'cat.nodes' => {
538             doc => "cat-nodes",
539             parts => {},
540             paths => [ [ {}, "_cat", "nodes" ] ],
541             qs => [ "h", "help", "local", "master_timeout", "v" ],
542             },
543              
544             'cat.pending_tasks' => {
545             doc => "cat-pending-tasks",
546             parts => {},
547             paths => [ [ {}, "_cat", "pending_tasks" ] ],
548             qs => [ "h", "help", "local", "master_timeout", "v" ],
549             },
550              
551             'cat.recovery' => {
552             doc => "cat-recovery",
553             parts => { index => { multi => 1 } },
554             paths => [
555             [ { index => 2 }, "_cat", "recovery", "{index}" ],
556             [ {}, "_cat", "recovery" ],
557             ],
558             qs => [ "bytes", "h", "help", "local", "master_timeout", "v" ],
559             },
560              
561             'cat.shards' => {
562             doc => "cat-shards",
563             parts => { index => { multi => 1 } },
564             paths => [
565             [ { index => 2 }, "_cat", "shards", "{index}" ],
566             [ {}, "_cat", "shards" ],
567             ],
568             qs => [ "h", "help", "local", "master_timeout", "v" ],
569             },
570              
571             'cat.thread_pool' => {
572             doc => "cat-thread-pool",
573             parts => {},
574             paths => [ [ {}, "_cat", "thread_pool" ] ],
575             qs => [ "full_id", "h", "help", "local", "master_timeout", "v" ],
576             },
577              
578             'cluster.get_settings' => {
579             doc => "cluster-update-settings",
580             parts => {},
581             paths => [ [ {}, "_cluster", "settings" ] ],
582             qs => [ "flat_settings", "master_timeout", "timeout" ],
583             },
584              
585             'cluster.health' => {
586             doc => "cluster-health",
587             parts => { index => {} },
588             paths => [
589             [ { index => 2 }, "_cluster", "health", "{index}" ],
590             [ {}, "_cluster", "health" ],
591             ],
592             qs => [
593             "level", "local",
594             "master_timeout", "timeout",
595             "wait_for_active_shards", "wait_for_nodes",
596             "wait_for_relocating_shards", "wait_for_status",
597             ],
598             },
599              
600             'cluster.pending_tasks' => {
601             doc => "cluster-pending",
602             parts => {},
603             paths => [ [ {}, "_cluster", "pending_tasks" ] ],
604             qs => [ "local", "master_timeout" ],
605             },
606              
607             'cluster.put_settings' => {
608             body => {},
609             doc => "cluster-update-settings",
610             method => "PUT",
611             parts => {},
612             paths => [ [ {}, "_cluster", "settings" ] ],
613             qs => ["flat_settings"],
614             },
615              
616             'cluster.reroute' => {
617             body => {},
618             doc => "cluster-reroute",
619             method => "POST",
620             parts => {},
621             paths => [ [ {}, "_cluster", "reroute" ] ],
622             qs => [
623             "dry_run", "explain",
624             "filter_metadata", "master_timeout",
625             "timeout",
626             ],
627             },
628              
629             'cluster.state' => {
630             doc => "cluster-state",
631             parts => { index => { multi => 1 }, metric => { multi => 1 } },
632             paths => [
633             [ { index => 3, metric => 2 }, "_cluster",
634             "state", "{metric}",
635             "{index}",
636             ],
637             [ { index => 3 }, "_cluster", "state", "_all", "{index}" ],
638             [ { metric => 2 }, "_cluster", "state", "{metric}" ],
639             [ {}, "_cluster", "state" ],
640             ],
641             qs =>
642             [ "flat_settings", "index_templates", "local", "master_timeout" ],
643             },
644              
645             'cluster.stats' => {
646             doc => "cluster-stats",
647             parts => { node_id => { multi => 1 } },
648             paths => [
649             [ { node_id => 3 }, "_cluster", "stats", "nodes", "{node_id}" ],
650             [ {}, "_cluster", "stats" ],
651             ],
652             qs => [ "flat_settings", "human" ],
653             },
654              
655             'indices.analyze' => {
656             body => {},
657             doc => "indices-analyze",
658             parts => { index => {} },
659             paths =>
660             [ [ { index => 0 }, "{index}", "_analyze" ], [ {}, "_analyze" ] ],
661             qs => [
662             "analyzer", "field", "filters", "format",
663             "prefer_local", "text", "tokenizer",
664             ],
665             },
666              
667             'indices.clear_cache' => {
668             doc => "indices-clearcache",
669             method => "POST",
670             parts => { index => { multi => 1 } },
671             paths => [
672             [ { index => 0 }, "{index}", "_cache", "clear" ],
673             [ {}, "_cache", "clear" ],
674             ],
675             qs => [
676             "allow_no_indices", "expand_wildcards",
677             "fielddata", "fields",
678             "filter", "filter_cache",
679             "filter_keys", "id",
680             "id_cache", "ignore_unavailable",
681             "recycler",
682             ],
683             },
684              
685             'indices.close' => {
686             doc => "indices-open-close",
687             method => "POST",
688             parts => { index => { required => 1 } },
689             paths => [ [ { index => 0 }, "{index}", "_close" ] ],
690             qs => [
691             "allow_no_indices", "expand_wildcards",
692             "ignore_unavailable", "master_timeout",
693             "timeout",
694             ],
695             },
696              
697             'indices.create' => {
698             body => {},
699             doc => "indices-create-index",
700             method => "PUT",
701             parts => { index => { required => 1 } },
702             paths => [ [ { index => 0 }, "{index}" ] ],
703             qs => [ "master_timeout", "timeout" ],
704             },
705              
706             'indices.delete' => {
707             doc => "indices-delete-index",
708             method => "DELETE",
709             parts => { index => { multi => 1 } },
710             paths => [ [ { index => 0 }, "{index}" ] ],
711             qs => [ "master_timeout", "timeout" ],
712             },
713              
714             'indices.delete_alias' => {
715             doc => "indices-aliases",
716             method => "DELETE",
717             parts => {
718             index => { multi => 1, required => 1 },
719             name => { multi => 1, required => 1 },
720             },
721             paths =>
722             [ [ { index => 0, name => 2 }, "{index}", "_alias", "{name}" ] ],
723             qs => [ "master_timeout", "timeout" ],
724             },
725              
726             'indices.delete_mapping' => {
727             doc => "indices-delete-mapping",
728             method => "DELETE",
729             parts => {
730             index => { multi => 1, required => 1 },
731             type => { multi => 1, required => 1 },
732             },
733             paths => [
734             [ { index => 0, type => 2 }, "{index}", "_mapping", "{type}" ]
735             ],
736             qs => ["master_timeout"],
737             },
738              
739             'indices.delete_template' => {
740             doc => "indices-templates",
741             method => "DELETE",
742             parts => { name => { required => 1 } },
743             paths => [ [ { name => 1 }, "_template", "{name}" ] ],
744             qs => [ "master_timeout", "timeout" ],
745             },
746              
747             'indices.delete_warmer' => {
748             doc => "indices-warmers",
749             method => "DELETE",
750             parts => {
751             index => { multi => 1, required => 1 },
752             name => { multi => 1, required => 1 },
753             },
754             paths =>
755             [ [ { index => 0, name => 2 }, "{index}", "_warmer", "{name}" ] ],
756             qs => ["master_timeout"],
757             },
758              
759             'indices.exists' => {
760             doc => "indices-get-settings",
761             method => "HEAD",
762             parts => { index => { multi => 1, required => 1 } },
763             paths => [ [ { index => 0 }, "{index}" ] ],
764             qs => [
765             "allow_no_indices", "expand_wildcards",
766             "ignore_unavailable", "local",
767             ],
768             },
769              
770             'indices.exists_alias' => {
771             doc => "indices-aliases",
772             method => "HEAD",
773             parts => { index => { multi => 1 }, name => { multi => 1 } },
774             paths => [
775             [ { index => 0, name => 2 }, "{index}", "_alias", "{name}" ],
776             [ { name => 1 }, "_alias", "{name}" ],
777             [ { index => 0 }, "{index}", "_alias" ],
778             ],
779             qs => [
780             "allow_no_indices", "expand_wildcards",
781             "ignore_unavailable", "local",
782             ],
783             },
784              
785             'indices.exists_template' => {
786             doc => "indices-templates",
787             method => "HEAD",
788             parts => { name => { required => 1 } },
789             paths => [ [ { name => 1 }, "_template", "{name}" ] ],
790             qs => ["local"],
791             },
792              
793             'indices.exists_type' => {
794             doc => "indices-types-exists",
795             method => "HEAD",
796             parts => {
797             index => { multi => 1, required => 1 },
798             type => { multi => 1, required => 1 },
799             },
800             paths => [ [ { index => 0, type => 1 }, "{index}", "{type}" ] ],
801             qs => [
802             "allow_no_indices", "expand_wildcards",
803             "ignore_unavailable", "local",
804             ],
805             },
806              
807             'indices.flush' => {
808             doc => "indices-flush",
809             method => "POST",
810             parts => { index => { multi => 1 } },
811             paths =>
812             [ [ { index => 0 }, "{index}", "_flush" ], [ {}, "_flush" ] ],
813             qs => [
814             "allow_no_indices", "expand_wildcards",
815             "force", "full",
816             "ignore_unavailable",
817             ],
818             },
819              
820             'indices.get_alias' => {
821             doc => "indices-aliases",
822             parts => { index => { multi => 1 }, name => { multi => 1 } },
823             paths => [
824             [ { index => 0, name => 2 }, "{index}", "_alias", "{name}" ],
825             [ { name => 1 }, "_alias", "{name}" ],
826             [ { index => 0 }, "{index}", "_alias" ],
827             [ {}, "_alias" ],
828             ],
829             qs => [
830             "allow_no_indices", "expand_wildcards",
831             "ignore_unavailable", "local",
832             ],
833             },
834              
835             'indices.get_aliases' => {
836             doc => "indices-aliases",
837             parts => { index => { multi => 1 }, name => { multi => 1 } },
838             paths => [
839             [ { index => 0, name => 2 }, "{index}", "_aliases", "{name}" ],
840             [ { name => 1 }, "_aliases", "{name}" ],
841             [ { index => 0 }, "{index}", "_aliases" ],
842             [ {}, "_aliases" ],
843             ],
844             qs => [ "local", "timeout" ],
845             },
846              
847             'indices.get_field_mapping' => {
848             doc => "indices-get-field-mapping",
849             parts => {
850             field => { multi => 1, required => 1 },
851             index => { multi => 1 },
852             type => { multi => 1 },
853             },
854             paths => [
855             [ { field => 4, index => 0, type => 2 }, "{index}",
856             "_mapping", "{type}",
857             "field", "{field}",
858             ],
859             [ { field => 3, index => 0 }, "{index}",
860             "_mapping", "field",
861             "{field}",
862             ],
863             [ { field => 3, type => 1 }, "_mapping",
864             "{type}", "field",
865             "{field}",
866             ],
867             [ { field => 2 }, "_mapping", "field", "{field}" ],
868             ],
869             qs => [
870             "allow_no_indices", "expand_wildcards",
871             "ignore_unavailable", "include_defaults",
872             "local",
873             ],
874             },
875              
876             'indices.get_mapping' => {
877             doc => "indices-get-mapping",
878             parts => { index => { multi => 1 }, type => { multi => 1 } },
879             paths => [
880             [ { index => 0, type => 2 }, "{index}", "_mapping", "{type}" ],
881             [ { type => 1 }, "_mapping", "{type}" ],
882             [ { index => 0 }, "{index}", "_mapping" ],
883             [ {}, "_mapping" ],
884             ],
885             qs => [
886             "allow_no_indices", "expand_wildcards",
887             "ignore_unavailable", "local",
888             ],
889             },
890              
891             'indices.get_settings' => {
892             doc => "indices-get-mapping",
893             parts => { index => { multi => 1 }, name => { multi => 1 } },
894             paths => [
895             [ { index => 0, name => 2 }, "{index}", "_settings", "{name}" ],
896             [ { name => 1 }, "_settings", "{name}" ],
897             [ { index => 0 }, "{index}", "_settings" ],
898             [ {}, "_settings" ],
899             ],
900             qs => [
901             "allow_no_indices", "expand_wildcards",
902             "flat_settings", "ignore_unavailable",
903             "local",
904             ],
905             },
906              
907             'indices.get_template' => {
908             doc => "indices-templates",
909             parts => { name => {} },
910             paths =>
911             [ [ { name => 1 }, "_template", "{name}" ], [ {}, "_template" ] ],
912             qs => [ "flat_settings", "local" ],
913             },
914              
915             'indices.get_warmer' => {
916             doc => "indices-warmers",
917             parts => {
918             index => { multi => 1 },
919             name => { multi => 1 },
920             type => { multi => 1 }
921             },
922             paths => [
923             [ { index => 0, name => 3, type => 1 },
924             "{index}", "{type}", "_warmer", "{name}",
925             ],
926             [ { name => 3, type => 1 }, "_all",
927             "{type}", "_warmer",
928             "{name}"
929             ],
930             [ { index => 0, name => 2 }, "{index}", "_warmer", "{name}" ],
931             [ { name => 1 }, "_warmer", "{name}" ],
932             [ { index => 0 }, "{index}", "_warmer" ],
933             [ {}, "_warmer" ],
934             ],
935             qs => [
936             "allow_no_indices", "expand_wildcards",
937             "ignore_unavailable", "local",
938             ],
939             },
940              
941             'indices.open' => {
942             doc => "indices-open-close",
943             method => "POST",
944             parts => { index => { required => 1 } },
945             paths => [ [ { index => 0 }, "{index}", "_open" ] ],
946             qs => [
947             "allow_no_indices", "expand_wildcards",
948             "ignore_unavailable", "master_timeout",
949             "timeout",
950             ],
951             },
952              
953             'indices.optimize' => {
954             doc => "indices-optimize",
955             method => "POST",
956             parts => { index => { multi => 1 } },
957             paths => [
958             [ { index => 0 }, "{index}", "_optimize" ],
959             [ {}, "_optimize" ]
960             ],
961             qs => [
962             "allow_no_indices", "expand_wildcards",
963             "flush", "ignore_unavailable",
964             "max_num_segments", "only_expunge_deletes",
965             "wait_for_merge",
966             ],
967             },
968              
969             'indices.put_alias' => {
970             body => {},
971             doc => "indices-aliases",
972             method => "PUT",
973             parts => { index => { multi => 1 }, name => { required => 1 } },
974             paths => [
975             [ { index => 0, name => 2 }, "{index}", "_alias", "{name}" ],
976             [ { name => 1 }, "_alias", "{name}" ],
977             ],
978             qs => [ "master_timeout", "timeout" ],
979             },
980              
981             'indices.put_mapping' => {
982             body => { required => 1 },
983             doc => "indices-put-mapping",
984             method => "PUT",
985             parts => { index => { multi => 1 }, type => { required => 1 } },
986             paths => [
987             [ { index => 0, type => 2 }, "{index}", "_mapping", "{type}" ],
988             [ { type => 1 }, "_mapping", "{type}" ],
989             ],
990             qs => [
991             "allow_no_indices", "expand_wildcards",
992             "ignore_conflicts", "ignore_unavailable",
993             "master_timeout", "timeout",
994             ],
995             },
996              
997             'indices.put_settings' => {
998             body => { required => 1 },
999             doc => "indices-update-settings",
1000             method => "PUT",
1001             parts => { index => { multi => 1 } },
1002             paths => [
1003             [ { index => 0 }, "{index}", "_settings" ],
1004             [ {}, "_settings" ]
1005             ],
1006             qs => [
1007             "allow_no_indices", "expand_wildcards",
1008             "flat_settings", "ignore_unavailable",
1009             "master_timeout",
1010             ],
1011             },
1012              
1013             'indices.put_template' => {
1014             body => { required => 1 },
1015             doc => "indices-templates",
1016             method => "PUT",
1017             parts => { name => { required => 1 } },
1018             paths => [ [ { name => 1 }, "_template", "{name}" ] ],
1019             qs => [ "flat_settings", "master_timeout", "order", "timeout" ],
1020             },
1021              
1022             'indices.put_warmer' => {
1023             body => { required => 1 },
1024             doc => "indices-warmers",
1025             method => "PUT",
1026             parts => {
1027             index => { multi => 1 },
1028             name => { required => 1 },
1029             type => { multi => 1 },
1030             },
1031             paths => [
1032             [ { index => 0, name => 3, type => 1 },
1033             "{index}", "{type}", "_warmer", "{name}",
1034             ],
1035             [ { name => 3, type => 1 }, "_all",
1036             "{type}", "_warmer",
1037             "{name}"
1038             ],
1039             [ { index => 0, name => 2 }, "{index}", "_warmer", "{name}" ],
1040             [ { name => 1 }, "_warmer", "{name}" ],
1041             ],
1042             qs => [
1043             "allow_no_indices", "expand_wildcards",
1044             "ignore_unavailable", "master_timeout",
1045             ],
1046             },
1047              
1048             'indices.refresh' => {
1049             doc => "indices-refresh",
1050             method => "POST",
1051             parts => { index => { multi => 1 } },
1052             paths =>
1053             [ [ { index => 0 }, "{index}", "_refresh" ], [ {}, "_refresh" ] ],
1054             qs => [
1055             "allow_no_indices", "expand_wildcards",
1056             "force", "ignore_unavailable",
1057             ],
1058             },
1059              
1060             'indices.segments' => {
1061             doc => "indices-segments",
1062             parts => { index => { multi => 1 } },
1063             paths => [
1064             [ { index => 0 }, "{index}", "_segments" ],
1065             [ {}, "_segments" ]
1066             ],
1067             qs => [
1068             "allow_no_indices", "expand_wildcards",
1069             "human", "ignore_unavailable",
1070             ],
1071             },
1072              
1073             'indices.snapshot_index' => {
1074             doc => "indices-gateway-snapshot",
1075             method => "POST",
1076             parts => { index => { multi => 1 } },
1077             paths => [
1078             [ { index => 0 }, "{index}", "_gateway", "snapshot" ],
1079             [ {}, "_gateway", "snapshot" ],
1080             ],
1081             qs =>
1082             [ "allow_no_indices", "expand_wildcards", "ignore_unavailable" ],
1083             },
1084              
1085             'indices.stats' => {
1086             doc => "indices-stats",
1087             parts => { index => { multi => 1 }, metric => { multi => 1 } },
1088             paths => [
1089             [ { index => 0, metric => 2 }, "{index}", "_stats", "{metric}" ],
1090             [ { metric => 1 }, "_stats", "{metric}" ],
1091             [ { index => 0 }, "{index}", "_stats" ],
1092             [ {}, "_stats" ],
1093             ],
1094             qs => [
1095             "completion_fields", "fielddata_fields",
1096             "fields", "groups",
1097             "human", "level",
1098             "types",
1099             ],
1100             },
1101              
1102             'indices.status' => {
1103             doc => "indices-status",
1104             parts => { index => { multi => 1 } },
1105             paths =>
1106             [ [ { index => 0 }, "{index}", "_status" ], [ {}, "_status" ] ],
1107             qs => [
1108             "allow_no_indices", "expand_wildcards",
1109             "human", "ignore_unavailable",
1110             "recovery", "snapshot",
1111             ],
1112             },
1113              
1114             'indices.update_aliases' => {
1115             body => { required => 1 },
1116             doc => "indices-aliases",
1117             method => "POST",
1118             parts => {},
1119             paths => [ [ {}, "_aliases" ] ],
1120             qs => [ "master_timeout", "timeout" ],
1121             },
1122              
1123             'indices.validate_query' => {
1124             body => {},
1125             doc => "search-validate",
1126             parts => { index => { multi => 1 }, type => { multi => 1 } },
1127             paths => [
1128             [ { index => 0, type => 1 }, "{index}",
1129             "{type}", "_validate",
1130             "query",
1131             ],
1132             [ { type => 1 }, "_all", "{type}", "_validate", "query" ],
1133             [ { index => 0 }, "{index}", "_validate", "query" ],
1134             [ {}, "_validate", "query" ],
1135             ],
1136             qs => [
1137             "allow_no_indices", "expand_wildcards",
1138             "explain", "ignore_unavailable",
1139             "q", "source",
1140             ],
1141             },
1142              
1143             'nodes.hot_threads' => {
1144             doc => "cluster-nodes-hot-threads",
1145             parts => { node_id => { multi => 1 } },
1146             paths => [
1147             [ { node_id => 1 }, "_nodes", "{node_id}", "hot_threads" ],
1148             [ {}, "_nodes", "hot_threads" ],
1149             ],
1150             qs => [ "interval", "snapshots", "threads", "type" ],
1151             },
1152              
1153             'nodes.info' => {
1154             doc => "cluster-nodes-info",
1155             parts => { metric => { multi => 1 }, node_id => { multi => 1 } },
1156             paths => [
1157             [ { metric => 2, node_id => 1 }, "_nodes",
1158             "{node_id}", "{metric}",
1159             ],
1160             [ { metric => 2 }, "_nodes", "_all", "{metric}" ],
1161             [ { node_id => 1 }, "_nodes", "{node_id}" ],
1162             [ {}, "_nodes" ],
1163             ],
1164             qs => [ "flat_settings", "human" ],
1165             },
1166              
1167             'nodes.shutdown' => {
1168             doc => "cluster-nodes-shutdown",
1169             method => "POST",
1170             parts => { node_id => { multi => 1 } },
1171             paths => [
1172             [ { node_id => 2 }, "_cluster",
1173             "nodes", "{node_id}",
1174             "_shutdown"
1175             ],
1176             [ {}, "_shutdown" ],
1177             ],
1178             qs => [ "delay", "exit" ],
1179             },
1180              
1181             'nodes.stats' => {
1182             doc => "cluster-nodes-stats",
1183             parts => {
1184             index_metric => { multi => 1 },
1185             metric => { multi => 1 },
1186             node_id => { multi => 1 },
1187             },
1188             paths => [
1189             [ { index_metric => 4, metric => 3, node_id => 1 },
1190             "_nodes", "{node_id}", "stats", "{metric}", "{index_metric}",
1191             ],
1192             [ { index_metric => 4, node_id => 1 },
1193             "_nodes", "{node_id}", "stats", "_all", "{index_metric}",
1194             ],
1195             [ { index_metric => 3, metric => 2 }, "_nodes",
1196             "stats", "{metric}",
1197             "{index_metric}",
1198             ],
1199             [ { index_metric => 3 }, "_nodes",
1200             "stats", "_all",
1201             "{index_metric}",
1202             ],
1203             [ { metric => 3, node_id => 1 }, "_nodes",
1204             "{node_id}", "stats",
1205             "{metric}",
1206             ],
1207             [ { metric => 2 }, "_nodes", "stats", "{metric}" ],
1208             [ { node_id => 1 }, "_nodes", "{node_id}", "stats" ],
1209             [ {}, "_nodes", "stats" ],
1210             ],
1211             qs => [
1212             "completion_fields", "fielddata_fields",
1213             "fields", "groups",
1214             "human", "level",
1215             "types",
1216             ],
1217             },
1218              
1219             'snapshot.create' => {
1220             body => {},
1221             doc => "modules-snapshots",
1222             method => "PUT",
1223             parts => {
1224             repository => { required => 1 },
1225             snapshot => { required => 1 }
1226             },
1227             paths => [
1228             [ { repository => 1, snapshot => 2 }, "_snapshot",
1229             "{repository}", "{snapshot}",
1230             ],
1231             ],
1232             qs => [ "master_timeout", "wait_for_completion" ],
1233             },
1234              
1235             'snapshot.create_repository' => {
1236             body => { required => 1 },
1237             doc => "modules-snapshots",
1238             method => "PUT",
1239             parts => { repository => { required => 1 } },
1240             paths => [ [ { repository => 1 }, "_snapshot", "{repository}" ] ],
1241             qs => [ "master_timeout", "timeout" ],
1242             },
1243              
1244             'snapshot.delete' => {
1245             doc => "modules-snapshots",
1246             method => "DELETE",
1247             parts => {
1248             repository => { required => 1 },
1249             snapshot => { required => 1 }
1250             },
1251             paths => [
1252             [ { repository => 1, snapshot => 2 }, "_snapshot",
1253             "{repository}", "{snapshot}",
1254             ],
1255             ],
1256             qs => ["master_timeout"],
1257             },
1258              
1259             'snapshot.delete_repository' => {
1260             doc => "modules-snapshots",
1261             method => "DELETE",
1262             parts => { repository => { multi => 1, required => 1 } },
1263             paths => [ [ { repository => 1 }, "_snapshot", "{repository}" ] ],
1264             qs => [ "master_timeout", "timeout" ],
1265             },
1266              
1267             'snapshot.get' => {
1268             doc => "modules-snapshots",
1269             parts => {
1270             repository => { required => 1 },
1271             snapshot => { multi => 1, required => 1 },
1272             },
1273             paths => [
1274             [ { repository => 1, snapshot => 2 }, "_snapshot",
1275             "{repository}", "{snapshot}",
1276             ],
1277             ],
1278             qs => ["master_timeout"],
1279             },
1280              
1281             'snapshot.get_repository' => {
1282             doc => "modules-snapshots",
1283             parts => { repository => { multi => 1 } },
1284             paths => [
1285             [ { repository => 1 }, "_snapshot", "{repository}" ],
1286             [ {}, "_snapshot" ],
1287             ],
1288             qs => [ "local", "master_timeout" ],
1289             },
1290              
1291             'snapshot.restore' => {
1292             body => {},
1293             doc => "modules-snapshots",
1294             method => "POST",
1295             parts => {
1296             repository => { required => 1 },
1297             snapshot => { required => 1 }
1298             },
1299             paths => [
1300             [ { repository => 1, snapshot => 2 }, "_snapshot",
1301             "{repository}", "{snapshot}",
1302             "_restore",
1303             ],
1304             ],
1305             qs => [ "master_timeout", "wait_for_completion" ],
1306             },
1307              
1308             #=== AUTOGEN - END ===
1309              
1310             );
1311              
1312             for ( values %API ) {
1313             $_->{qs_handlers} = qs_init( @{ $_->{qs} } );
1314             }
1315              
1316             1;
1317              
1318             =pod
1319              
1320             =encoding UTF-8
1321              
1322             =head1 NAME
1323              
1324             Elasticsearch::Role::API - This class contains the spec for the Elasticsearch APIs
1325              
1326             =head1 VERSION
1327              
1328             version 1.05
1329              
1330             =head1 DESCRIPTION
1331              
1332             All of the Elasticsearch APIs are defined in this role. The example given below
1333             is the definition for the L<Elasticsearch::Client::Direct/index()> method:
1334              
1335             'index' => {
1336             body => {
1337             desc => 'The document',
1338             required => 1
1339             },
1340              
1341             doc => '/api/index_/',
1342             method => 'PUT',
1343             path => '{index}/{type}/{id|blank}',
1344             qs => [
1345             'consistency', 'op_type', 'parent', 'percolate',
1346             'refresh', 'replication', 'routing', 'timeout',
1347             'timestamp', 'ttl', 'version', 'version_type'
1348             ],
1349             },
1350              
1351             These definitions can be used by different L<Elasticsearch::Role::Client>
1352             implementations to provide distinct user interfaces.
1353              
1354             =head1 METHODS
1355              
1356             =head2 C<api()>
1357              
1358             $defn = $api->api($name);
1359              
1360             The only method in this class is the C<api()> method which takes the name
1361             of the I<action> and returns its definition. Actions in the
1362             C<indices> or C<cluster> namespace use the namespace as a prefix, eg:
1363              
1364             $defn = $e->api('indices.create');
1365             $defn = $e->api('cluster.node_stats');
1366              
1367             =head1 SEE ALSO
1368              
1369             =over
1370              
1371             =item *
1372              
1373             L<Elasticsearch::Util::API::Path>
1374              
1375             =item *
1376              
1377             L<Elasticsearch::Util::API::QS>
1378              
1379             =item *
1380              
1381             L<Elasticsearch::Client::Direct>
1382              
1383             =back
1384              
1385             =head1 AUTHOR
1386              
1387             Clinton Gormley <drtech@cpan.org>
1388              
1389             =head1 COPYRIGHT AND LICENSE
1390              
1391             This software is Copyright (c) 2014 by Elasticsearch BV.
1392              
1393             This is free software, licensed under:
1394              
1395             The Apache License, Version 2.0, January 2004
1396              
1397             =cut
1398              
1399             __END__
1400              
1401             # ABSTRACT: This class contains the spec for the Elasticsearch APIs
1402