|
| 1 | +module Elasticsearch |
| 2 | + module API |
| 3 | + module Indices |
| 4 | + module Actions |
| 5 | + |
| 6 | + # Return information about one or more indices |
| 7 | + # |
| 8 | + # @example Get information about all indices |
| 9 | + # |
| 10 | + # client.indices.status |
| 11 | + # |
| 12 | + # @example Get information about a specific index |
| 13 | + # |
| 14 | + # client.indices.status index: 'foo' |
| 15 | + # |
| 16 | + # @example Get information about shard recovery for a specific index |
| 17 | + # |
| 18 | + # client.indices.status index: 'foo', recovery: true |
| 19 | + # |
| 20 | + # @option arguments [List] :index A comma-separated list of index names; use `_all` or empty string |
| 21 | + # to perform the operation on all indices |
| 22 | + # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into |
| 23 | + # no concrete indices. (This includes `_all` string or when no |
| 24 | + # indices have been specified) |
| 25 | + # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that |
| 26 | + # are open, closed or both. (options: open, closed) |
| 27 | + # @option arguments [String] :ignore_indices When performed on multiple indices, allows to ignore |
| 28 | + # `missing` ones (options: none, missing) @until 1.0 |
| 29 | + # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when |
| 30 | + # unavailable (missing, closed, etc) |
| 31 | + # @option arguments [Boolean] :recovery Return information about shard recovery (progress, size, etc) |
| 32 | + # @option arguments [Boolean] :snapshot Return information about snapshots (when shared gateway is used) |
| 33 | + # |
| 34 | + # @see http://elasticsearch.org/guide/reference/api/admin-indices-status/ |
| 35 | + # |
| 36 | + def status(arguments={}) |
| 37 | + method = HTTP_GET |
| 38 | + path = Utils.__pathify Utils.__listify(arguments[:index]), '_status' |
| 39 | + |
| 40 | + params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) |
| 41 | + body = nil |
| 42 | + |
| 43 | + if Array(arguments[:ignore]).include?(404) |
| 44 | + Utils.__rescue_from_not_found { perform_request(method, path, params, body).body } |
| 45 | + else |
| 46 | + perform_request(method, path, params, body).body |
| 47 | + end |
| 48 | + end |
| 49 | + |
| 50 | + # Register this action with its valid params when the module is loaded. |
| 51 | + # |
| 52 | + # @since 6.2.0 |
| 53 | + ParamsRegistry.register(:status, [ |
| 54 | + :ignore_indices, |
| 55 | + :ignore_unavailable, |
| 56 | + :allow_no_indices, |
| 57 | + :expand_wildcards, |
| 58 | + :recovery, |
| 59 | + :snapshot ].freeze) |
| 60 | + end |
| 61 | + end |
| 62 | + end |
| 63 | +end |
0 commit comments