Skip to content

Commit 5a0aae4

Browse files
committed
[XPACK] Update APIs
1 parent fc880b3 commit 5a0aae4

File tree

13 files changed

+344
-22
lines changed

13 files changed

+344
-22
lines changed

elasticsearch-xpack/lib/elasticsearch/xpack.rb

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,10 @@ def eql
152152
def snapshot_lifecycle_management
153153
@snapshot_lifecycle_management ||= xpack.snapshot_lifecycle_management
154154
end
155+
156+
def text_structure
157+
@text_structure ||= xpack.text_structure
158+
end
155159
end
156160
end
157161
end if defined?(Elasticsearch::Transport::Client)

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/autoscaling/delete_autoscaling_policy.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ module XPack
2020
module API
2121
module Autoscaling
2222
module Actions
23-
# Deletes an autoscaling policy.
24-
# This functionality is Experimental and may be changed or removed
25-
# completely in a future release. Elastic will take a best effort approach
26-
# to fix any issues, but experimental features are not subject to the
27-
# support SLA of official GA features.
23+
# Deletes an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
2824
#
2925
# @option arguments [String] :name the name of the autoscaling policy
3026
# @option arguments [Hash] :headers Custom HTTP headers

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/autoscaling/get_autoscaling_capacity.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ module XPack
2020
module API
2121
module Autoscaling
2222
module Actions
23-
# Gets the current autoscaling capacity based on the configured autoscaling policy.
24-
# This functionality is Experimental and may be changed or removed
25-
# completely in a future release. Elastic will take a best effort approach
26-
# to fix any issues, but experimental features are not subject to the
27-
# support SLA of official GA features.
23+
# Gets the current autoscaling capacity based on the configured autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
2824
#
2925
# @option arguments [Hash] :headers Custom HTTP headers
3026
#

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/autoscaling/get_autoscaling_policy.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ module XPack
2020
module API
2121
module Autoscaling
2222
module Actions
23-
# Retrieves an autoscaling policy.
24-
# This functionality is Experimental and may be changed or removed
25-
# completely in a future release. Elastic will take a best effort approach
26-
# to fix any issues, but experimental features are not subject to the
27-
# support SLA of official GA features.
23+
# Retrieves an autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
2824
#
2925
# @option arguments [String] :name the name of the autoscaling policy
3026
# @option arguments [Hash] :headers Custom HTTP headers

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/autoscaling/put_autoscaling_policy.rb

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,11 +20,7 @@ module XPack
2020
module API
2121
module Autoscaling
2222
module Actions
23-
# Creates a new autoscaling policy.
24-
# This functionality is Experimental and may be changed or removed
25-
# completely in a future release. Elastic will take a best effort approach
26-
# to fix any issues, but experimental features are not subject to the
27-
# support SLA of official GA features.
23+
# Creates a new autoscaling policy. Designed for indirect use by ECE/ESS and ECK. Direct use is not supported.
2824
#
2925
# @option arguments [String] :name the name of the autoscaling policy
3026
# @option arguments [Hash] :headers Custom HTTP headers
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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 XPack
20+
module API
21+
module Eql
22+
module Actions
23+
# Returns the status of a previously submitted async or stored Event Query Language (EQL) search
24+
#
25+
# @option arguments [String] :id The async search ID
26+
# @option arguments [Hash] :headers Custom HTTP headers
27+
#
28+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/eql-search-api.html
29+
#
30+
def get_status(arguments = {})
31+
raise ArgumentError, "Required argument 'id' missing" unless arguments[:id]
32+
33+
headers = arguments.delete(:headers) || {}
34+
35+
arguments = arguments.clone
36+
37+
_id = arguments.delete(:id)
38+
39+
method = Elasticsearch::API::HTTP_GET
40+
path = "_eql/search/status/#{Elasticsearch::API::Utils.__listify(_id)}"
41+
params = {}
42+
43+
body = nil
44+
perform_request(method, path, params, body, headers).body
45+
end
46+
end
47+
end
48+
end
49+
end
50+
end

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/searchable_snapshots/mount.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@ module Actions
3030
# @option arguments [String] :snapshot The name of the snapshot of the index to mount
3131
# @option arguments [Time] :master_timeout Explicit operation timeout for connection to master node
3232
# @option arguments [Boolean] :wait_for_completion Should this request wait until the operation has completed before returning
33+
# @option arguments [String] :storage Selects the kind of local storage used to accelerate searches. Experimental, and defaults to `full_copy`
3334
# @option arguments [Hash] :headers Custom HTTP headers
3435
# @option arguments [Hash] :body The restore configuration for mounting the snapshot as searchable (*Required*)
3536
#
@@ -61,7 +62,8 @@ def mount(arguments = {})
6162
# @since 6.2.0
6263
ParamsRegistry.register(:mount, [
6364
:master_timeout,
64-
:wait_for_completion
65+
:wait_for_completion,
66+
:storage
6567
].freeze)
6668
end
6769
end

elasticsearch-xpack/lib/elasticsearch/xpack/api/actions/searchable_snapshots/stats.rb

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ module Actions
2727
# support SLA of official GA features.
2828
#
2929
# @option arguments [List] :index A comma-separated list of index names
30+
# @option arguments [String] :level Return stats aggregated at cluster, index or shard level (options: cluster, indices, shards)
3031
# @option arguments [Hash] :headers Custom HTTP headers
3132
#
3233
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/searchable-snapshots-apis.html
@@ -44,11 +45,18 @@ def stats(arguments = {})
4445
else
4546
"_searchable_snapshots/stats"
4647
end
47-
params = {}
48+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
4849

4950
body = nil
5051
perform_request(method, path, params, body, headers).body
5152
end
53+
54+
# Register this action with its valid params when the module is loaded.
55+
#
56+
# @since 6.2.0
57+
ParamsRegistry.register(:stats, [
58+
:level
59+
].freeze)
5260
end
5361
end
5462
end
Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
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 XPack
20+
module API
21+
module TextStructure
22+
module Actions
23+
# Finds the structure of a text file. The text file must contain data that is suitable to be ingested into Elasticsearch.
24+
# This functionality is Experimental and may be changed or removed
25+
# completely in a future release. Elastic will take a best effort approach
26+
# to fix any issues, but experimental features are not subject to the
27+
# support SLA of official GA features.
28+
#
29+
# @option arguments [Int] :lines_to_sample How many lines of the file should be included in the analysis
30+
# @option arguments [Int] :line_merge_size_limit Maximum number of characters permitted in a single message when lines are merged to create messages.
31+
# @option arguments [Time] :timeout Timeout after which the analysis will be aborted
32+
# @option arguments [String] :charset Optional parameter to specify the character set of the file
33+
# @option arguments [String] :format Optional parameter to specify the high level file format (options: ndjson, xml, delimited, semi_structured_text)
34+
# @option arguments [Boolean] :has_header_row Optional parameter to specify whether a delimited file includes the column names in its first row
35+
# @option arguments [List] :column_names Optional parameter containing a comma separated list of the column names for a delimited file
36+
# @option arguments [String] :delimiter Optional parameter to specify the delimiter character for a delimited file - must be a single character
37+
# @option arguments [String] :quote Optional parameter to specify the quote character for a delimited file - must be a single character
38+
# @option arguments [Boolean] :should_trim_fields Optional parameter to specify whether the values between delimiters in a delimited file should have whitespace trimmed from them
39+
# @option arguments [String] :grok_pattern Optional parameter to specify the Grok pattern that should be used to extract fields from messages in a semi-structured text file
40+
# @option arguments [String] :timestamp_field Optional parameter to specify the timestamp field in the file
41+
# @option arguments [String] :timestamp_format Optional parameter to specify the timestamp format in the file - may be either a Joda or Java time format
42+
# @option arguments [Boolean] :explain Whether to include a commentary on how the structure was derived
43+
# @option arguments [Hash] :headers Custom HTTP headers
44+
# @option arguments [Hash] :body The contents of the file to be analyzed (*Required*)
45+
#
46+
# @see https://www.elastic.co/guide/en/elasticsearch/reference/7.x/find-structure.html
47+
#
48+
def find_structure(arguments = {})
49+
raise ArgumentError, "Required argument 'body' missing" unless arguments[:body]
50+
51+
headers = arguments.delete(:headers) || {}
52+
53+
arguments = arguments.clone
54+
55+
method = Elasticsearch::API::HTTP_POST
56+
path = "_text_structure/find_structure"
57+
params = Elasticsearch::API::Utils.__validate_and_extract_params arguments, ParamsRegistry.get(__method__)
58+
59+
body = arguments[:body]
60+
perform_request(method, path, params, body, headers).body
61+
end
62+
63+
# Register this action with its valid params when the module is loaded.
64+
#
65+
# @since 6.2.0
66+
ParamsRegistry.register(:find_structure, [
67+
:lines_to_sample,
68+
:line_merge_size_limit,
69+
:timeout,
70+
:charset,
71+
:format,
72+
:has_header_row,
73+
:column_names,
74+
:delimiter,
75+
:quote,
76+
:should_trim_fields,
77+
:grok_pattern,
78+
:timestamp_field,
79+
:timestamp_format,
80+
:explain
81+
].freeze)
82+
end
83+
end
84+
end
85+
end
86+
end
Lines changed: 62 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
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 XPack
20+
module API
21+
module TextStructure
22+
module Actions
23+
module ParamsRegistry
24+
extend self
25+
26+
# A Mapping of all the actions to their list of valid params.
27+
#
28+
# @since 7.4.0
29+
PARAMS = {}
30+
31+
# Register an action with its list of valid params.
32+
#
33+
# @example Register the action.
34+
# ParamsRegistry.register(:benchmark, [ :verbose ])
35+
#
36+
# @param [ Symbol ] action The action to register.
37+
# @param [ Array[Symbol] ] valid_params The list of valid params.
38+
#
39+
# @since 7.4.0
40+
def register(action, valid_params)
41+
PARAMS[action.to_sym] = valid_params
42+
end
43+
44+
# Get the list of valid params for a given action.
45+
#
46+
# @example Get the list of valid params.
47+
# ParamsRegistry.get(:benchmark)
48+
#
49+
# @param [ Symbol ] action The action.
50+
#
51+
# @return [ Array<Symbol> ] The list of valid params for the action.
52+
#
53+
# @since 7.4.0
54+
def get(action)
55+
PARAMS.fetch(action, [])
56+
end
57+
end
58+
end
59+
end
60+
end
61+
end
62+
end

0 commit comments

Comments
 (0)