|
| 1 | +# Licensed to Elasticsearch B.V. under one or more contributor |
| 2 | +# license agreements. See the NOTICE file distributed with |
| 3 | +# this work for additional information regarding copyright |
| 4 | +# ownership. Elasticsearch B.V. licenses this file to you under |
| 5 | +# the Apache License, Version 2.0 (the "License"); you may |
| 6 | +# not use this file except in compliance with the License. |
| 7 | +# You may obtain a copy of the License at |
| 8 | +# |
| 9 | +# http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | +# |
| 11 | +# Unless required by applicable law or agreed to in writing, |
| 12 | +# software distributed under the License is distributed on an |
| 13 | +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY |
| 14 | +# KIND, either express or implied. See the License for the |
| 15 | +# specific language governing permissions and limitations |
| 16 | +# under the License. |
| 17 | + |
| 18 | +module Elasticsearch |
| 19 | + module API |
| 20 | + module Indices |
| 21 | + module Actions |
| 22 | + # Analyzes the disk usage of each field of an index or data stream |
| 23 | + # This functionality is Experimental and may be changed or removed |
| 24 | + # completely in a future release. Elastic will take a best effort approach |
| 25 | + # to fix any issues, but experimental features are not subject to the |
| 26 | + # support SLA of official GA features. |
| 27 | + # |
| 28 | + # @option arguments [String] :index Comma-separated list of indices or data streams to analyze the disk usage |
| 29 | + # @option arguments [Boolean] :run_expensive_tasks Must be set to [true] in order for the task to be performed. Defaults to false. |
| 30 | + # @option arguments [Boolean] :flush Whether flush or not before analyzing the index disk usage. Defaults to true |
| 31 | + # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) |
| 32 | + # @option arguments [Boolean] :allow_no_indices Whether to ignore if a wildcard indices expression resolves into no concrete indices. (This includes `_all` string or when no indices have been specified) |
| 33 | + # @option arguments [String] :expand_wildcards Whether to expand wildcard expression to concrete indices that are open, closed or both. (options: open, closed, hidden, none, all) |
| 34 | + # @option arguments [Hash] :headers Custom HTTP headers |
| 35 | + # |
| 36 | + # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.14/indices-disk-usage.html |
| 37 | + # |
| 38 | + def disk_usage(arguments = {}) |
| 39 | + raise ArgumentError, "Required argument 'index' missing" unless arguments[:index] |
| 40 | + |
| 41 | + headers = arguments.delete(:headers) || {} |
| 42 | + |
| 43 | + arguments = arguments.clone |
| 44 | + |
| 45 | + _index = arguments.delete(:index) |
| 46 | + |
| 47 | + method = Elasticsearch::API::HTTP_POST |
| 48 | + path = "#{Utils.__listify(_index)}/_disk_usage" |
| 49 | + params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) |
| 50 | + |
| 51 | + body = nil |
| 52 | + perform_request(method, path, params, body, headers).body |
| 53 | + end |
| 54 | + |
| 55 | + # Register this action with its valid params when the module is loaded. |
| 56 | + # |
| 57 | + # @since 6.2.0 |
| 58 | + ParamsRegistry.register(:disk_usage, [ |
| 59 | + :run_expensive_tasks, |
| 60 | + :flush, |
| 61 | + :ignore_unavailable, |
| 62 | + :allow_no_indices, |
| 63 | + :expand_wildcards |
| 64 | + ].freeze) |
| 65 | + end |
| 66 | + end |
| 67 | + end |
| 68 | +end |
0 commit comments