flex 0.4.2 → 1.0.1

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 (78) hide show
  1. data/LICENSE +1 -1
  2. data/README.md +46 -7
  3. data/VERSION +1 -1
  4. data/flex.gemspec +13 -19
  5. data/lib/flex.rb +66 -392
  6. data/lib/flex/api_stubs.rb +1268 -0
  7. data/lib/flex/api_templates/cluster_api.yml +94 -0
  8. data/lib/flex/api_templates/core_api.yml +202 -0
  9. data/lib/flex/api_templates/indices_api.yml +304 -0
  10. data/lib/flex/class_proxy/base.rb +20 -6
  11. data/lib/flex/class_proxy/templates.rb +97 -0
  12. data/lib/flex/class_proxy/templates/doc.rb +91 -0
  13. data/lib/flex/class_proxy/templates/search.rb +72 -0
  14. data/lib/flex/configuration.rb +17 -49
  15. data/lib/flex/deprecation.rb +153 -0
  16. data/lib/flex/errors.rb +2 -1
  17. data/lib/flex/http_clients/base.rb +15 -0
  18. data/lib/flex/http_clients/loader.rb +51 -0
  19. data/lib/flex/http_clients/patron.rb +9 -7
  20. data/lib/flex/http_clients/rest_client.rb +6 -8
  21. data/lib/flex/logger.rb +24 -3
  22. data/lib/flex/prog_bar.rb +11 -6
  23. data/lib/flex/rails.rb +1 -13
  24. data/lib/flex/result.rb +8 -2
  25. data/lib/flex/result/document.rb +42 -13
  26. data/lib/flex/result/multi_get.rb +24 -0
  27. data/lib/flex/result/search.rb +1 -24
  28. data/lib/flex/struct/array.rb +25 -0
  29. data/lib/flex/struct/hash.rb +105 -0
  30. data/lib/flex/{result/collection.rb → struct/paginable.rb} +16 -9
  31. data/lib/flex/struct/prunable.rb +60 -0
  32. data/lib/flex/struct/symbolize.rb +27 -0
  33. data/lib/flex/tasks.rb +26 -86
  34. data/lib/flex/template.rb +60 -120
  35. data/lib/flex/template/common.rb +42 -0
  36. data/lib/flex/template/logger.rb +66 -0
  37. data/lib/flex/template/partial.rb +12 -15
  38. data/lib/flex/template/search.rb +6 -6
  39. data/lib/flex/template/slim_search.rb +1 -1
  40. data/lib/flex/template/tags.rb +19 -9
  41. data/lib/flex/templates.rb +20 -0
  42. data/lib/flex/utility_methods.rb +80 -89
  43. data/lib/flex/utils.rb +68 -25
  44. data/lib/flex/variables.rb +55 -4
  45. data/lib/tasks.rake +28 -0
  46. metadata +61 -85
  47. data/bin/flexes +0 -174
  48. data/lib/flex/api_methods.yml +0 -108
  49. data/lib/flex/class_proxy/loader.rb +0 -102
  50. data/lib/flex/class_proxy/model.rb +0 -45
  51. data/lib/flex/class_proxy/model_sync.rb +0 -23
  52. data/lib/flex/class_proxy/related_model.rb +0 -23
  53. data/lib/flex/instance_proxy/base.rb +0 -29
  54. data/lib/flex/instance_proxy/model.rb +0 -102
  55. data/lib/flex/instance_proxy/related_model.rb +0 -7
  56. data/lib/flex/loader.rb +0 -18
  57. data/lib/flex/manager.rb +0 -61
  58. data/lib/flex/model.rb +0 -24
  59. data/lib/flex/rails/engine.rb +0 -23
  60. data/lib/flex/rails/helper.rb +0 -16
  61. data/lib/flex/related_model.rb +0 -16
  62. data/lib/flex/result/indifferent_access.rb +0 -11
  63. data/lib/flex/result/source_document.rb +0 -63
  64. data/lib/flex/result/source_search.rb +0 -32
  65. data/lib/flex/structure/indifferent_access.rb +0 -44
  66. data/lib/flex/structure/mergeable.rb +0 -21
  67. data/lib/flex/template/base.rb +0 -41
  68. data/lib/flex/template/info.rb +0 -68
  69. data/lib/generators/flex/setup/setup_generator.rb +0 -48
  70. data/lib/generators/flex/setup/templates/flex_config.yml +0 -16
  71. data/lib/generators/flex/setup/templates/flex_dir/es.rb.erb +0 -18
  72. data/lib/generators/flex/setup/templates/flex_dir/es.yml.erb +0 -19
  73. data/lib/generators/flex/setup/templates/flex_dir/es_extender.rb.erb +0 -17
  74. data/lib/generators/flex/setup/templates/flex_initializer.rb.erb +0 -44
  75. data/lib/tasks/index.rake +0 -17
  76. data/test/flex.irt +0 -143
  77. data/test/flex/configuration.irt +0 -53
  78. data/test/irt_helper.rb +0 -12
@@ -0,0 +1,94 @@
1
+ # These methods are available as Flex.<method>(variable_hash)
2
+ # you can get the updated full reference and usage example of these methods
3
+ # by just doing in the console:
4
+ # >> Flex.doc
5
+
6
+
7
+
8
+ #-----------------------------------------------------------------------------#
9
+ ### Health ###
10
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-health/
11
+
12
+ # you can pass the params as the :params variable
13
+ cluster_health:
14
+ - GET
15
+ - /_cluster/health/<<index>>
16
+
17
+
18
+
19
+ #-----------------------------------------------------------------------------#
20
+ ### State ###
21
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-state/
22
+
23
+ # you can pass the params as the :params variable
24
+ cluster_state:
25
+ - GET
26
+ - /_cluster/state
27
+
28
+
29
+
30
+ #-----------------------------------------------------------------------------#
31
+ ### Update Settings ###
32
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-update-settings/
33
+
34
+ # you must pass the settings structure as the :data variable
35
+ put_cluster_settings:
36
+ - PUT
37
+ - /_cluster/settings
38
+
39
+ get_cluster_settings:
40
+ - GET
41
+ - /_cluster/settings
42
+
43
+
44
+
45
+ #-----------------------------------------------------------------------------#
46
+ ### Nodes Info ###
47
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-info/
48
+ # http://www.elasticsearch.org/guide/reference/api/
49
+
50
+ # uses the _nodes shortcut
51
+ cluster_nodes_info:
52
+ - GET
53
+ - /_nodes/<<nodes= ~ >>/<<endpoint= ~ >>
54
+
55
+
56
+
57
+ #-----------------------------------------------------------------------------#
58
+ ### Nodes Stats ###
59
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-stats/
60
+
61
+ cluster_nodes_stats:
62
+ - GET
63
+ - /_nodes/<<nodes= ~ >>/stats/<<endpoint= ~ >>
64
+
65
+
66
+
67
+ #-----------------------------------------------------------------------------#
68
+ ### Nodes Shutdown ###
69
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-shutdown/
70
+
71
+ cluster_nodes_shutdown:
72
+ - POST
73
+ - /_cluster/nodes/<<nodes= ~ >>/_shutdown
74
+
75
+
76
+
77
+ #-----------------------------------------------------------------------------#
78
+ ### Nodes Hot Threads ###
79
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-nodes-hot-threads/
80
+
81
+ cluster_nodes_hot_threads:
82
+ - GET
83
+ - /_nodes/<<nodes= ~ >>/hot_threads
84
+
85
+
86
+
87
+ #-----------------------------------------------------------------------------#
88
+ ### Cluster Reroute ###
89
+ # http://www.elasticsearch.org/guide/reference/api/admin-cluster-reroute.html
90
+
91
+ # you must pass the data structure as the :data variable
92
+ cluster_reroute:
93
+ - POST
94
+ - /_cluster/reroute
@@ -0,0 +1,202 @@
1
+ # These methods are available as Flex.<method>(variable_hash)
2
+ # you can get the updated full reference and usage example of these methods
3
+ # by just doing in the console:
4
+ # >> Flex.doc
5
+
6
+
7
+
8
+ #-----------------------------------------------------------------------------#
9
+ ### Index ###
10
+ # http://www.elasticsearch.org/guide/reference/api/index_/
11
+
12
+ # You must pass the :data variable
13
+ store: &store
14
+ - PUT
15
+ - /<<index>>/<<type>>/<<id>>
16
+
17
+ # alias for symmetry with post_store
18
+ put_store: *store
19
+
20
+ # id is assigned by ES; you must pass :data
21
+ post_store:
22
+ - POST
23
+ - /<<index>>/<<type>>
24
+
25
+
26
+
27
+ #-----------------------------------------------------------------------------#
28
+ ### Delete ###
29
+ # http://www.elasticsearch.org/guide/reference/api/delete/
30
+
31
+ delete: &delete
32
+ - DELETE
33
+ - /<<index>>/<<type>>/<<id>>
34
+
35
+ remove: *delete
36
+
37
+
38
+
39
+ #-----------------------------------------------------------------------------#
40
+ ### Get ###
41
+ # http://www.elasticsearch.org/guide/reference/api/get.html
42
+
43
+ get:
44
+ - GET
45
+ - /<<index>>/<<type>>/<<id>>
46
+
47
+ get_source:
48
+ - GET
49
+ - /<<index>>/<<type>>/<<id>>/_source
50
+
51
+
52
+
53
+ #-----------------------------------------------------------------------------#
54
+ ### Multi Get ###
55
+ # http://www.elasticsearch.org/guide/reference/api/multi-get.html
56
+
57
+ multi_get:
58
+ - GET
59
+ - /<<index>>/<<type>>/_mget
60
+ - ids: << ids >>
61
+
62
+
63
+
64
+ #-----------------------------------------------------------------------------#
65
+ ### Update ###
66
+ # http://www.elasticsearch.org/guide/reference/api/update/
67
+
68
+ # you must pass script or doc and the other options as the :data variable
69
+ update:
70
+ - POST
71
+ - /<<index>>/<<type>>/<<id>>/_update
72
+
73
+
74
+
75
+ #-----------------------------------------------------------------------------#
76
+ ### Search ###
77
+ # The search api is covered by the templating system
78
+
79
+
80
+
81
+ #-----------------------------------------------------------------------------#
82
+ ### Multi Search ###
83
+ # the Multi Search api is covered by the YourClass.multi_search method
84
+ # added by the Flex::Templates module
85
+
86
+
87
+
88
+ #-----------------------------------------------------------------------------#
89
+ ### Percolate ###
90
+ # http://www.elasticsearch.org/guide/reference/api/percolate.html
91
+
92
+ # You must pass the the document (and additional queries) as :data variable
93
+ percolate:
94
+ - GET
95
+ - /<<index>>/<<type>>/_percolate
96
+
97
+ # You must pass the the query (and additional fields) as :data variable
98
+ put_percolator:
99
+ - PUT
100
+ - /_percolator/<<index>>/<<percolator>>
101
+
102
+ # http://www.elasticsearch.org/guide/reference/api/percolate.html
103
+ delete_percolator:
104
+ - DELETE
105
+ - /_percolator/<<index>>/<<percolator>>
106
+
107
+
108
+
109
+ #-----------------------------------------------------------------------------#
110
+ ### Bulk ###
111
+ # http://www.elasticsearch.org/guide/reference/api/bulk.html
112
+
113
+ post_bulk_string: &bulk
114
+ - POST
115
+ - /_bulk
116
+ - << bulk_string >>
117
+
118
+ # Deprecated alias for backward compatibility
119
+ bulk: *bulk
120
+
121
+
122
+
123
+ #-----------------------------------------------------------------------------#
124
+ ### Count ###
125
+ # http://www.elasticsearch.org/guide/reference/api/count.html
126
+
127
+ count:
128
+ - GET
129
+ - /<<index>>/<<type>>/_count
130
+ # pass :data structure if you need
131
+
132
+
133
+
134
+ #-----------------------------------------------------------------------------#
135
+ ### Delete by query ###
136
+ # http://www.elasticsearch.org/guide/reference/api/delete-by-query.html
137
+
138
+ delete_by_query:
139
+ - DELETE
140
+ - /<<index>>/<<type>>/_query
141
+ # pass :data variable query if you need
142
+
143
+
144
+
145
+ #-----------------------------------------------------------------------------#
146
+ ### More Like This ###
147
+ # http://www.elasticsearch.org/guide/reference/api/more-like-this.html
148
+
149
+ # You can pass the search API (facets, from/to and so on) as :data variable
150
+ more_like_this: &mlt
151
+ - GET
152
+ - /<<index>>/<<type>>/<<id>>/_mlt
153
+
154
+ # aliased
155
+ mlt: *mlt
156
+
157
+
158
+
159
+ #-----------------------------------------------------------------------------#
160
+ ### Validate ###
161
+ # http://www.elasticsearch.org/guide/reference/api/validate/
162
+
163
+ # you must pass the query to validate as the :data variable
164
+ # you can pass the parameters as the :params variable
165
+ validate:
166
+ - GET
167
+ - /<<index>>/<<type>>/_validate/query
168
+
169
+
170
+
171
+ #-----------------------------------------------------------------------------#
172
+ ### Explain ###
173
+ # http://www.elasticsearch.org/guide/reference/api/explain/
174
+
175
+ # you must pass the query to explain as the :data variable
176
+ # you can pass the parameters as the :params variable
177
+ explain:
178
+ - GET
179
+ - /<<index>>/<<type>>/<<id>>/_explain
180
+
181
+
182
+
183
+ #-----------------------------------------------------------------------------#
184
+ ### Flex additions ###
185
+
186
+ # not a real API method, but handy
187
+ match_all:
188
+ - GET
189
+ - /<<index>>/<<type>>/_search
190
+ - query:
191
+ match_all: {}
192
+
193
+
194
+
195
+ #-----------------------------------------------------------------------------#
196
+ # get a document without using the get API (which doesn't support fields '*')
197
+ search_by_id:
198
+ - GET
199
+ - /<<index>>/<<type>>/_search
200
+ - query:
201
+ term:
202
+ _id: <<id>>
@@ -0,0 +1,304 @@
1
+ # These methods are available as Flex.<method>(variable_hash)
2
+ # you can get the updated full reference and usage example of these methods
3
+ # by just doing in the console:
4
+ # >> Flex.doc
5
+
6
+
7
+
8
+ #-----------------------------------------------------------------------------#
9
+ ### Aliases ###
10
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-aliases/
11
+
12
+ # this is the generic interface allowing all options
13
+ # you must pass the aliases API structure as :data variable
14
+ post_index_aliases:
15
+ - POST
16
+ - /_aliases
17
+
18
+ get_index_aliases:
19
+ - GET
20
+ - /<<index>>/_aliases
21
+
22
+ # this is the single index alias
23
+ # you can pass other options as :data variable
24
+ put_index_alias:
25
+ - PUT
26
+ - /<<index>>/_alias/<<alias>>
27
+
28
+ delete_index_alias:
29
+ - DELETE
30
+ - /<<index>>/_alias/<<alias>>
31
+
32
+ get_index_alias:
33
+ - GET
34
+ - /<<index>>/_alias/<<alias= '*' >>
35
+
36
+
37
+
38
+ #-----------------------------------------------------------------------------#
39
+ ### Analyze ###
40
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-analyze/
41
+
42
+ # you can pass the text to analyze as the :data variable (or the param :text)
43
+ # you can pass the parameters as the :params variable
44
+ analyze_index:
45
+ - GET
46
+ - /<<index>>/_analyze
47
+
48
+
49
+
50
+ #-----------------------------------------------------------------------------#
51
+ ### Create Index ###
52
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-create-index.html
53
+
54
+ put_index: &create
55
+ - PUT
56
+ - /<<index>>
57
+ - settings:
58
+ number_of_shards: <<number_of_shards= 5 >>
59
+ number_of_replicas: <<number_of_replicas= 1 >>
60
+
61
+ # aliased
62
+ create_index: *create
63
+
64
+ post_index:
65
+ - POST
66
+ - /<<index>>
67
+ - settings:
68
+ number_of_shards: <<number_of_shards= 5 >>
69
+ number_of_replicas: <<number_of_replicas= 1 >>
70
+
71
+
72
+
73
+ #-----------------------------------------------------------------------------#
74
+ ### Delete Index ###
75
+ # http://www.elasticsearch.org/guide/reference/api/delete.html
76
+
77
+ delete_index:
78
+ - DELETE
79
+ - /<<index>>
80
+
81
+
82
+
83
+ #-----------------------------------------------------------------------------#
84
+ ### Open/Close Index ###
85
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-open-close/
86
+
87
+ close_index:
88
+ - POST
89
+ - /<<index>>/_close
90
+
91
+ open_index:
92
+ - POST
93
+ - /<<index>>/_open
94
+
95
+
96
+
97
+ #-----------------------------------------------------------------------------#
98
+ ### Get Settings ###
99
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-get-settings.html
100
+
101
+ get_index_settings: &get_index_settings
102
+ - GET
103
+ - /<<index>>/_settings
104
+
105
+ # alias
106
+ get_settings: *get_index_settings
107
+
108
+
109
+
110
+ #-----------------------------------------------------------------------------#
111
+ ### Get Mappings ###
112
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-get-mapping.html
113
+
114
+ get_index_mapping: &get_index_mapping
115
+ - GET
116
+ - /<<index>>/<<type>>/_mapping
117
+
118
+ # alias
119
+ get_mapping: *get_index_mapping
120
+
121
+
122
+
123
+ #-----------------------------------------------------------------------------#
124
+ ### Put Mappings ###
125
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-put-mapping.html
126
+
127
+ put_index_mapping: &put_index_mapping
128
+ - PUT
129
+ - /<<index>>/<<type>>/_mapping
130
+ - <<type>>:
131
+ properties: <<properties>>
132
+
133
+ # alias
134
+ put_mapping: *put_index_mapping
135
+
136
+
137
+
138
+ #-----------------------------------------------------------------------------#
139
+ ### Delete Mappings ###
140
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-delete-mapping.html
141
+
142
+ delete_index_mapping: &delete_index_mapping
143
+ - DELETE
144
+ - /<<index>>/<<type>>
145
+
146
+ # alias
147
+ delete_mapping: *delete_index_mapping
148
+
149
+
150
+
151
+ #-----------------------------------------------------------------------------#
152
+ ### Refresh ###
153
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-refresh.html
154
+
155
+ refresh_index:
156
+ - POST
157
+ - /<<index>>/_refresh
158
+
159
+
160
+
161
+ #-----------------------------------------------------------------------------#
162
+ ### Optimize ###
163
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-optimize/
164
+
165
+ # you can pass the parameters as the :params variable
166
+ optimize_index:
167
+ - POST
168
+ - /<<index>>/_optimize
169
+
170
+
171
+
172
+ #-----------------------------------------------------------------------------#
173
+ ### Flush ###
174
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-flush/
175
+
176
+ # you can pass the parameters as the :params variable
177
+ flush_index:
178
+ - POST
179
+ - /<<index>>/_flush
180
+
181
+
182
+
183
+ #-----------------------------------------------------------------------------#
184
+ ### Snapshot ###
185
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-gateway-snapshot/
186
+
187
+ gateway_snapshot:
188
+ - POST
189
+ - /<<index>>/_gateway/snapshot
190
+
191
+
192
+
193
+ #-----------------------------------------------------------------------------#
194
+ ### Update Settings ###
195
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-update-settings/
196
+
197
+ # you can pass the settings structure as the :data variable
198
+ update_index_settings:
199
+ - PUT
200
+ - /<<index>>/_settings
201
+
202
+
203
+
204
+ #-----------------------------------------------------------------------------#
205
+ ### Templates ###
206
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-templates/
207
+
208
+ # you must pass the data structure as :data variable
209
+ put_index_template:
210
+ - PUT
211
+ - /_template/<<template>>
212
+
213
+ delete_index_template:
214
+ - DELETE
215
+ - /_template/<<template>>
216
+
217
+ get_index_template:
218
+ - GET
219
+ - /_template/<<template>>
220
+
221
+
222
+
223
+ #-----------------------------------------------------------------------------#
224
+ ### Warmers ###
225
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-warmers/
226
+
227
+ # you must pass the warmer structure as the :data variable
228
+ put_index_warmer:
229
+ - PUT
230
+ - /<<index>>/<<type>>/_warmer/<<warmer>>
231
+
232
+ delete_index_warmer:
233
+ - DELETE
234
+ - /<<index>>/_warmer/<<warmer= ~ >>
235
+
236
+ get_index_warmer:
237
+ - GET
238
+ - /<<index>>/_warmer/<<warmer= ~ >>
239
+
240
+
241
+
242
+ #-----------------------------------------------------------------------------#
243
+ ### Stats ###
244
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-stats.html
245
+
246
+ index_stats: &index_stats
247
+ - GET
248
+ - /<<index>>/_stats/<<endpoint= ~ >>/<<names= ~ >>
249
+
250
+ # alias
251
+ stats: *index_stats
252
+
253
+
254
+
255
+ #-----------------------------------------------------------------------------#
256
+ ### Status ###
257
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-status/
258
+
259
+ index_status:
260
+ - GET
261
+ - /<<index>>/_status
262
+
263
+
264
+
265
+ #-----------------------------------------------------------------------------#
266
+ ### Segments ###
267
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-segments/
268
+
269
+ index_segments:
270
+ - GET
271
+ - /<<index>>/_segments
272
+
273
+
274
+
275
+ #-----------------------------------------------------------------------------#
276
+ ### Clear Cache ###
277
+ #http://www.elasticsearch.org/guide/reference/api/admin-indices-clearcache/
278
+
279
+ index_clearcache:
280
+ - POST
281
+ - /<<index>>/_cache/clear
282
+
283
+
284
+
285
+ #-----------------------------------------------------------------------------#
286
+ ### Indices Exists ###
287
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-indices-exists.html
288
+
289
+ indices_exists: &exist
290
+ - HEAD
291
+ - /<<index>>
292
+
293
+ # aliased
294
+ exist?: *exist
295
+
296
+
297
+
298
+ #-----------------------------------------------------------------------------#
299
+ ### Types Exists ###
300
+ # http://www.elasticsearch.org/guide/reference/api/admin-indices-types-exists/
301
+
302
+ types_exists:
303
+ - HEAD
304
+ - /<<index>>/<<type>>