|
| 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 Actions |
| 21 | + # Open a point in time that can be used in subsequent searches |
| 22 | + # |
| 23 | + # @option arguments [List] :index A comma-separated list of index names to open point in time; use `_all` or empty string to perform the operation on all indices |
| 24 | + # @option arguments [String] :preference Specify the node or shard the operation should be performed on (default: random) |
| 25 | + # @option arguments [String] :routing Specific routing value |
| 26 | + # @option arguments [Boolean] :ignore_unavailable Whether specified concrete indices should be ignored when unavailable (missing or closed) |
| 27 | + # @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) |
| 28 | + # @option arguments [String] :keep_alive Specific the time to live for the point in time |
| 29 | + # @option arguments [Hash] :headers Custom HTTP headers |
| 30 | + # |
| 31 | + # @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/point-in-time-api.html |
| 32 | + # |
| 33 | + def open_point_in_time(arguments = {}) |
| 34 | + headers = arguments.delete(:headers) || {} |
| 35 | + |
| 36 | + arguments = arguments.clone |
| 37 | + |
| 38 | + _index = arguments.delete(:index) |
| 39 | + |
| 40 | + method = Elasticsearch::API::HTTP_POST |
| 41 | + path = if _index |
| 42 | + "#{Utils.__listify(_index)}/_pit" |
| 43 | + else |
| 44 | + "_pit" |
| 45 | + end |
| 46 | + params = Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__) |
| 47 | + |
| 48 | + body = nil |
| 49 | + perform_request(method, path, params, body, headers).body |
| 50 | + end |
| 51 | + |
| 52 | + # Register this action with its valid params when the module is loaded. |
| 53 | + # |
| 54 | + # @since 6.2.0 |
| 55 | + ParamsRegistry.register(:open_point_in_time, [ |
| 56 | + :preference, |
| 57 | + :routing, |
| 58 | + :ignore_unavailable, |
| 59 | + :expand_wildcards, |
| 60 | + :keep_alive |
| 61 | + ].freeze) |
| 62 | + end |
| 63 | + end |
| 64 | +end |
0 commit comments